CDRContentCollector.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libcdr project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __CDRCONTENTCOLLECTOR_H__
00011 #define __CDRCONTENTCOLLECTOR_H__
00012 
00013 #include <map>
00014 #include <vector>
00015 #include <stack>
00016 #include <librevenge/librevenge.h>
00017 #include <lcms2.h>
00018 #include "CDRTypes.h"
00019 #include "CDRPath.h"
00020 #include "CDROutputElementList.h"
00021 #include "CDRCollector.h"
00022 
00023 namespace libcdr
00024 {
00025 
00026 class CDRContentCollector : public CDRCollector
00027 {
00028 public:
00029   CDRContentCollector(CDRParserState &ps, ::librevenge::RVNGDrawingInterface *painter);
00030   virtual ~CDRContentCollector();
00031 
00032   // collector functions
00033   void collectPage(unsigned level);
00034   void collectObject(unsigned level);
00035   void collectGroup(unsigned level);
00036   void collectVect(unsigned level);
00037   void collectOtherList();
00038   void collectPath(const CDRPath &path);
00039   void collectLevel(unsigned level);
00040   void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform);
00041   void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill);
00042   void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
00043                         double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
00044                         const CDRPath &startMarker, const CDRPath &endMarker);
00045   void collectRotate(double angle, double cx, double cy);
00046   void collectFlags(unsigned flags, bool considerFlags);
00047   void collectPageSize(double, double, double, double) {}
00048   void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy);
00049   void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2);
00050   void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector<unsigned> &, const std::vector<unsigned char> &) {}
00051   void collectBmp(unsigned, const std::vector<unsigned char> &) {}
00052   void collectBmpf(unsigned, unsigned, unsigned, const std::vector<unsigned char> &) {}
00053   void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector);
00054   void collectFillTransform(const CDRTransforms &fillTrafo);
00055   void collectFillOpacity(double opacity);
00056   void collectPolygon();
00057   void collectSpline();
00058   void collectColorProfile(const std::vector<unsigned char> &) {}
00059   void collectBBox(double x0, double y0, double x1, double y1);
00060   void collectSpnd(unsigned spnd);
00061   void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data);
00062   void collectPaletteEntry(unsigned, unsigned, const CDRColor &) {}
00063   void collectText(unsigned, unsigned, const std::vector<unsigned char> &,
00064                    const std::vector<unsigned char> &, const std::map<unsigned, CDRCharacterStyle> &) {}
00065   void collectArtisticText(double x, double y);
00066   void collectParagraphText(double x, double y, double width, double height);
00067   void collectStld(unsigned, const CDRCharacterStyle &) {}
00068 
00069 private:
00070   CDRContentCollector(const CDRContentCollector &);
00071   CDRContentCollector &operator=(const CDRContentCollector &);
00072 
00073   // helper functions
00074   void _startDocument();
00075   void _endDocument();
00076   void _startPage(double width, double height);
00077   void _endPage();
00078   void _flushCurrentPath();
00079 
00080   void _fillProperties(librevenge::RVNGPropertyList &propList);
00081   void _lineProperties(librevenge::RVNGPropertyList &propList);
00082   void _generateBitmapFromPattern(librevenge::RVNGBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor);
00083 
00084   librevenge::RVNGDrawingInterface *m_painter;
00085 
00086   bool m_isDocumentStarted;
00087   bool m_isPageProperties;
00088   bool m_isPageStarted;
00089   bool m_ignorePage;
00090 
00091   CDRPage m_page;
00092   unsigned m_pageIndex;
00093   CDRFillStyle m_currentFillStyle;
00094   CDRLineStyle m_currentLineStyle;
00095   unsigned m_spnd;
00096   unsigned m_currentObjectLevel, m_currentGroupLevel, m_currentVectLevel, m_currentPageLevel;
00097   CDRImage m_currentImage;
00098   const std::vector<CDRTextLine> *m_currentText;
00099   CDRBox m_currentBBox;
00100   CDRBox m_currentTextBox;
00101 
00102   CDRPath m_currentPath;
00103   CDRTransforms m_currentTransforms;
00104   CDRTransforms m_fillTransforms;
00105   CDRPolygon *m_polygon;
00106   bool m_isInPolygon;
00107   bool m_isInSpline;
00108   std::stack<CDROutputElementList> *m_outputElements;
00109   std::stack<CDROutputElementList> m_contentOutputElements;
00110   std::stack<CDROutputElementList> m_fillOutputElements;
00111   std::stack<unsigned> m_groupLevels;
00112   std::stack<CDRTransforms> m_groupTransforms;
00113   CDRSplineData m_splineData;
00114   double m_fillOpacity;
00115 
00116   CDRParserState &m_ps;
00117 };
00118 
00119 } // namespace libcdr
00120 
00121 #endif /* __CDRCOLLECTOR_H__ */
00122 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */