00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __CDRCONTENTCOLLECTOR_H__
00031 #define __CDRCONTENTCOLLECTOR_H__
00032
00033 #include <map>
00034 #include <vector>
00035 #include <stack>
00036 #include <libwpg/libwpg.h>
00037 #include <lcms2.h>
00038 #include "CDRTypes.h"
00039 #include "CDRPath.h"
00040 #include "CDROutputElementList.h"
00041 #include "CDRCollector.h"
00042
00043 namespace libcdr
00044 {
00045
00046 class CDRContentCollector : public CDRCollector
00047 {
00048 public:
00049 CDRContentCollector(CDRParserState &ps, ::libwpg::WPGPaintInterface *painter);
00050 virtual ~CDRContentCollector();
00051
00052
00053 void collectPage(unsigned level);
00054 void collectObject(unsigned level);
00055 void collectGroup(unsigned level);
00056 void collectVect(unsigned level);
00057 void collectOtherList();
00058 void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y);
00059 void collectQuadraticBezier(double x1, double y1, double x, double y);
00060 void collectMoveTo(double x, double y);
00061 void collectLineTo(double x, double y);
00062 void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y);
00063 void collectClosePath();
00064 void collectLevel(unsigned level);
00065 void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform);
00066 void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill);
00067 void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
00068 double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
00069 unsigned startMarkerId, unsigned endMarkerId);
00070 void collectRotate(double angle, double cx, double cy);
00071 void collectFlags(unsigned flags, bool considerFlags);
00072 void collectPageSize(double, double, double, double) {}
00073 void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy);
00074 void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2);
00075 void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector<unsigned> &, const std::vector<unsigned char> &) {}
00076 void collectBmp(unsigned, const std::vector<unsigned char> &) {}
00077 void collectBmpf(unsigned, unsigned, unsigned, const std::vector<unsigned char> &) {}
00078 void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector);
00079 void collectFillTransform(const CDRTransforms &fillTrafo);
00080 void collectFillOpacity(double opacity);
00081 void collectPolygon();
00082 void collectSpline();
00083 void collectColorProfile(const std::vector<unsigned char> &) {}
00084 void collectBBox(double x0, double y0, double x1, double y1);
00085 void collectSpnd(unsigned spnd);
00086 void collectVectorPattern(unsigned id, const WPXBinaryData &data);
00087 void collectPaletteEntry(unsigned, unsigned, const CDRColor &) {}
00088 void collectText(unsigned, unsigned, const std::vector<unsigned char> &,
00089 const std::vector<unsigned char> &, const std::map<unsigned, CDRCharacterStyle> &) {}
00090 void collectArtisticText(double x, double y);
00091 void collectParagraphText(double x, double y, double width, double height);
00092 void collectStld(unsigned, const CDRCharacterStyle &) {}
00093
00094 private:
00095 CDRContentCollector(const CDRContentCollector &);
00096 CDRContentCollector &operator=(const CDRContentCollector &);
00097
00098
00099 void _startPage(double width, double height);
00100 void _endPage();
00101 void _flushCurrentPath();
00102
00103 void _fillProperties(WPXPropertyList &propList, WPXPropertyListVector &vec);
00104 void _lineProperties(WPXPropertyList &propList);
00105 void _generateBitmapFromPattern(WPXBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor);
00106
00107 libwpg::WPGPaintInterface *m_painter;
00108
00109 bool m_isPageProperties;
00110 bool m_isPageStarted;
00111 bool m_ignorePage;
00112
00113 CDRPage m_page;
00114 unsigned m_pageIndex;
00115 CDRFillStyle m_currentFillStyle;
00116 CDRLineStyle m_currentLineStyle;
00117 unsigned m_spnd;
00118 unsigned m_currentObjectLevel, m_currentGroupLevel, m_currentVectLevel, m_currentPageLevel;
00119 CDRImage m_currentImage;
00120 const std::vector<CDRTextLine> *m_currentText;
00121 CDRBox m_currentBBox;
00122 CDRBox m_currentTextBox;
00123
00124 CDRPath m_currentPath;
00125 CDRTransforms m_currentTransforms;
00126 CDRTransforms m_fillTransforms;
00127 CDRPolygon *m_polygon;
00128 bool m_isInPolygon;
00129 bool m_isInSpline;
00130 std::stack<CDROutputElementList> *m_outputElements;
00131 std::stack<CDROutputElementList> m_contentOutputElements;
00132 std::stack<CDROutputElementList> m_fillOutputElements;
00133 std::stack<unsigned> m_groupLevels;
00134 std::stack<CDRTransforms> m_groupTransforms;
00135 CDRSplineData m_splineData;
00136 double m_fillOpacity;
00137
00138 CDRParserState &m_ps;
00139 };
00140
00141 }
00142
00143 #endif
00144