CDRContentCollector.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libcdr project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef __CDRCONTENTCOLLECTOR_H__
11 #define __CDRCONTENTCOLLECTOR_H__
12
13 #include <map>
14 #include <vector>
15 #include <stack>
16 #include <queue>
17 #include <librevenge/librevenge.h>
18 #include <lcms2.h>
19 #include "CDRTypes.h"
20 #include "CDRPath.h"
21 #include "CDROutputElementList.h"
22 #include "CDRCollector.h"
23
24 namespace libcdr
25 {
26
27 class CDRContentCollector : public CDRCollector
28 {
29 public:
30 CDRContentCollector(CDRParserState &ps, ::librevenge::RVNGDrawingInterface *painter, bool reverseOrder = true);
31 virtual ~CDRContentCollector();
32
33 // collector functions
34 void collectPage(unsigned level);
35 void collectObject(unsigned level);
36 void collectGroup(unsigned level);
37 void collectVect(unsigned level);
38 void collectOtherList();
39 void collectPath(const CDRPath &path);
40 void collectLevel(unsigned level);
41 void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform);
42 void collectFillStyle(unsigned,const CDRFillStyle &) {}
43 void collectFillStyleId(unsigned id);
44 void collectLineStyle(unsigned,const CDRLineStyle &) {}
45 void collectLineStyleId(unsigned id);
46 void collectRotate(double angle, double cx, double cy);
47 void collectFlags(unsigned flags, bool considerFlags);
48 void collectPageSize(double, double, double, double) {}
49 void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy);
50 void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2);
51 void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector<unsigned> &, const std::vector<unsigned char> &) {}
52 void collectBmp(unsigned, const std::vector<unsigned char> &) {}
53 void collectBmpf(unsigned, unsigned, unsigned, const std::vector<unsigned char> &) {}
54 void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector);
55 void collectFillTransform(const CDRTransforms &fillTrafo);
56 void collectFillOpacity(double opacity);
57 void collectPolygon();
58 void collectSpline();
59 void collectColorProfile(const std::vector<unsigned char> &) {}
60 void collectBBox(double x0, double y0, double x1, double y1);
61 void collectSpnd(unsigned spnd);
62 void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data);
63 void collectPaletteEntry(unsigned, unsigned, const CDRColor &) {}
64 void collectText(unsigned, unsigned, const std::vector<unsigned char> &,
65 const std::vector<unsigned char> &, const std::map<unsigned, CDRStyle> &) {}
66 void collectArtisticText(double x, double y);
67 void collectParagraphText(double x, double y, double width, double height);
68 void collectStld(unsigned, const CDRStyle &) {}
69 void collectStyleId(unsigned styleId);
70
71 private:
72 CDRContentCollector(const CDRContentCollector &);
73 CDRContentCollector &operator=(const CDRContentCollector &);
74
75 // helper functions
76 void _startDocument();
77 void _endDocument();
78 void _startPage(double width, double height);
79 void _endPage();
80 void _flushCurrentPath();
81
82 void _fillProperties(librevenge::RVNGPropertyList &propList);
83 void _lineProperties(librevenge::RVNGPropertyList &propList);
84 void _generateBitmapFromPattern(librevenge::RVNGBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor);
85
86 librevenge::RVNGDrawingInterface *m_painter;
87
88 bool m_isDocumentStarted;
89 bool m_isPageProperties;
90 bool m_isPageStarted;
91 bool m_ignorePage;
92
93 CDRPage m_page;
94 unsigned m_pageIndex;
95 CDRFillStyle m_currentFillStyle;
96 CDRLineStyle m_currentLineStyle;
97 unsigned m_spnd;
98 unsigned m_currentObjectLevel, m_currentGroupLevel, m_currentVectLevel, m_currentPageLevel, m_currentStyleId;
99 CDRImage m_currentImage;
100 const std::vector<CDRTextLine> *m_currentText;
101 CDRBox m_currentBBox;
102 CDRBox m_currentTextBox;
103
104 CDRPath m_currentPath;
105 CDRTransforms m_currentTransforms;
106 CDRTransforms m_fillTransforms;
107 CDRPolygon *m_polygon;
108 bool m_isInPolygon;
109 bool m_isInSpline;
110 std::stack<CDROutputElementList> *m_outputElementsStack;
111 std::stack<CDROutputElementList> m_contentOutputElementsStack;
112 std::stack<CDROutputElementList> m_fillOutputElementsStack;
113 std::queue<CDROutputElementList> *m_outputElementsQueue;
114 std::queue<CDROutputElementList> m_contentOutputElementsQueue;
115 std::queue<CDROutputElementList> m_fillOutputElementsQueue;
116 std::stack<unsigned> m_groupLevels;
117 std::stack<CDRTransforms> m_groupTransforms;
118 CDRSplineData m_splineData;
119 double m_fillOpacity;
120 bool m_reverseOrder;
121
122 CDRParserState &m_ps;
123 };
124
125 } // namespace libcdr
126
127 #endif /* __CDRCOLLECTOR_H__ */
128 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libcdr::CDRContentCollector::m_currentText
const std::vector< CDRTextLine > * m_currentText
Definition: CDRContentCollector.h:100
libcdr::CDRContentCollector::m_pageIndex
unsigned m_pageIndex
Definition: CDRContentCollector.h:94
libcdr::CDRContentCollector::_flushCurrentPath
void _flushCurrentPath()
Definition: CDRContentCollector.cpp:212
libcdr::CDRContentCollector::collectOtherList
void collectOtherList()
Definition: CDRContentCollector.cpp:201
libcdr::CDRContentCollector::collectColorProfile
void collectColorProfile(const std::vector< unsigned char > &)
Definition: CDRContentCollector.h:59
libcdr::CDRContentCollector::m_currentFillStyle
CDRFillStyle m_currentFillStyle
Definition: CDRContentCollector.h:95
libcdr::CDRContentCollector::m_groupLevels
std::stack< unsigned > m_groupLevels
Definition: CDRContentCollector.h:116
libcdr::CDRBox
Definition: CDRTypes.h:23
libcdr::CDRContentCollector::m_fillTransforms
CDRTransforms m_fillTransforms
Definition: CDRContentCollector.h:106
libcdr::CDRPath
Definition: CDRPath.h:34
libcdr::CDRContentCollector::collectLineStyle
void collectLineStyle(unsigned, const CDRLineStyle &)
Definition: CDRContentCollector.h:44
libcdr::CDRContentCollector::collectStld
void collectStld(unsigned, const CDRStyle &)
Definition: CDRContentCollector.h:68
libcdr::CDRContentCollector::m_page
CDRPage m_page
Definition: CDRContentCollector.h:93
libcdr::CDRContentCollector::collectFillOpacity
void collectFillOpacity(double opacity)
Definition: CDRContentCollector.cpp:1242
libcdr::CDRContentCollector::m_groupTransforms
std::stack< CDRTransforms > m_groupTransforms
Definition: CDRContentCollector.h:117
libcdr::CDRContentCollector::m_outputElementsStack
std::stack< CDROutputElementList > * m_outputElementsStack
Definition: CDRContentCollector.h:110
libcdr::CDRContentCollector::m_currentImage
CDRImage m_currentImage
Definition: CDRContentCollector.h:99
libcdr::CDRPage
Definition: CDRTypes.h:238
libcdr::CDRContentCollector::_generateBitmapFromPattern
void _generateBitmapFromPattern(librevenge::RVNGBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor)
Definition: CDRContentCollector.cpp:1159
libcdr::CDRContentCollector::m_contentOutputElementsQueue
std::queue< CDROutputElementList > m_contentOutputElementsQueue
Definition: CDRContentCollector.h:114
libcdr::CDRContentCollector::collectParagraphText
void collectParagraphText(double x, double y, double width, double height)
Definition: CDRContentCollector.cpp:1322
libcdr::CDRContentCollector::m_currentPageLevel
unsigned m_currentPageLevel
Definition: CDRContentCollector.h:98
libcdr::CDRContentCollector::m_contentOutputElementsStack
std::stack< CDROutputElementList > m_contentOutputElementsStack
Definition: CDRContentCollector.h:111
libcdr::CDRContentCollector::m_currentObjectLevel
unsigned m_currentObjectLevel
Definition: CDRContentCollector.h:98
libcdr::CDRContentCollector::m_isInPolygon
bool m_isInPolygon
Definition: CDRContentCollector.h:108
libcdr::CDRContentCollector::collectFillStyle
void collectFillStyle(unsigned, const CDRFillStyle &)
Definition: CDRContentCollector.h:42
libcdr::CDRContentCollector::collectBmp
void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector< unsigned > &, const std::vector< unsigned char > &)
Definition: CDRContentCollector.h:51
libcdr::CDRContentCollector::collectText
void collectText(unsigned, unsigned, const std::vector< unsigned char > &, const std::vector< unsigned char > &, const std::map< unsigned, CDRStyle > &)
Definition: CDRContentCollector.h:64
libcdr::CDRContentCollector::collectPpdt
void collectPpdt(const std::vector< std::pair< double, double > > &points, const std::vector< unsigned > &knotVector)
Definition: CDRContentCollector.cpp:1237
libcdr::CDRContentCollector::m_spnd
unsigned m_spnd
Definition: CDRContentCollector.h:97
libcdr::CDRSplineData
Definition: CDRTypes.h:249
libcdr::CDRContentCollector::collectFillStyleId
void collectFillStyleId(unsigned id)
Definition: CDRContentCollector.cpp:644
libcdr::CDRContentCollector::m_reverseOrder
bool m_reverseOrder
Definition: CDRContentCollector.h:120
libcdr::CDRContentCollector::m_currentVectLevel
unsigned m_currentVectLevel
Definition: CDRContentCollector.h:98
libcdr::CDRFillStyle
Definition: CDRTypes.h:100
libcdr::CDRContentCollector::collectPath
void collectPath(const CDRPath &path)
Definition: CDRContentCollector.cpp:206
libcdr::CDRContentCollector::collectPage
void collectPage(unsigned level)
Definition: CDRContentCollector.cpp:137
libcdr::CDRContentCollector::collectVect
void collectVect(unsigned level)
Definition: CDRContentCollector.cpp:178
libcdr::CDRContentCollector::collectGroup
void collectGroup(unsigned level)
Definition: CDRContentCollector.cpp:157
libcdr::CDRPolygon
Definition: CDRTypes.h:177
libcdr::CDRContentCollector::collectSpline
void collectSpline()
Definition: CDRContentCollector.cpp:673
libcdr::CDRContentCollector::collectTransform
void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform)
Definition: CDRContentCollector.cpp:546
libcdr::CDRContentCollector::m_ignorePage
bool m_ignorePage
Definition: CDRContentCollector.h:91
libcdr::CDRContentCollector::collectPaletteEntry
void collectPaletteEntry(unsigned, unsigned, const CDRColor &)
Definition: CDRContentCollector.h:63
libcdr::CDRContentCollector::collectRotate
void collectRotate(double angle, double cx, double cy)
Definition: CDRContentCollector.cpp:658
libcdr::CDRContentCollector::m_isInSpline
bool m_isInSpline
Definition: CDRContentCollector.h:109
libcdr::CDRContentCollector::_endDocument
void _endDocument()
Definition: CDRContentCollector.cpp:93
libcdr::CDRContentCollector::m_ps
CDRParserState & m_ps
Definition: CDRContentCollector.h:122
libcdr::CDRContentCollector::collectPolygon
void collectPolygon()
Definition: CDRContentCollector.cpp:668
libcdr::CDRContentCollector::collectFlags
void collectFlags(unsigned flags, bool considerFlags)
Definition: CDRContentCollector.cpp:189
libcdr::CDRContentCollector::collectBitmap
void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2)
Definition: CDRContentCollector.cpp:1230
libcdr
Definition: CDRCollector.h:29
libcdr::CDRContentCollector::m_fillOutputElementsQueue
std::queue< CDROutputElementList > m_fillOutputElementsQueue
Definition: CDRContentCollector.h:115
libcdr::CDRContentCollector::collectStyleId
void collectStyleId(unsigned styleId)
Definition: CDRContentCollector.cpp:1333
libcdr::CDRContentCollector::_fillProperties
void _fillProperties(librevenge::RVNGPropertyList &propList)
Definition: CDRContentCollector.cpp:685
libcdr::CDRContentCollector::collectPolygonTransform
void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)
Definition: CDRContentCollector.cpp:678
libcdr::CDRContentCollector::m_currentLineStyle
CDRLineStyle m_currentLineStyle
Definition: CDRContentCollector.h:96
libcdr::CDRContentCollector::m_currentStyleId
unsigned m_currentStyleId
Definition: CDRContentCollector.h:98
libcdr::CDRContentCollector::collectSpnd
void collectSpnd(unsigned spnd)
Definition: CDRContentCollector.cpp:1260
CDROutputElementList.h
libcdr::CDRContentCollector::m_currentTextBox
CDRBox m_currentTextBox
Definition: CDRContentCollector.h:102
libcdr::CDRContentCollector::collectBBox
void collectBBox(double x0, double y0, double x1, double y1)
Definition: CDRContentCollector.cpp:1247
libcdr::CDRContentCollector::m_polygon
CDRPolygon * m_polygon
Definition: CDRContentCollector.h:107
libcdr::CDRContentCollector::m_fillOpacity
double m_fillOpacity
Definition: CDRContentCollector.h:119
libcdr::CDRContentCollector::operator=
CDRContentCollector & operator=(const CDRContentCollector &)
libcdr::CDRContentCollector::m_currentGroupLevel
unsigned m_currentGroupLevel
Definition: CDRContentCollector.h:98
libcdr::CDRContentCollector::collectVectorPattern
void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data)
Definition: CDRContentCollector.cpp:1268
libcdr::CDRContentCollector::collectArtisticText
void collectArtisticText(double x, double y)
Definition: CDRContentCollector.cpp:1313
libcdr::CDRContentCollector::m_isPageProperties
bool m_isPageProperties
Definition: CDRContentCollector.h:89
libcdr::CDRContentCollector::m_outputElementsQueue
std::queue< CDROutputElementList > * m_outputElementsQueue
Definition: CDRContentCollector.h:113
libcdr::CDRContentCollector::_startPage
void _startPage(double width, double height)
Definition: CDRContentCollector.cpp:104
libcdr::CDRContentCollector::_lineProperties
void _lineProperties(librevenge::RVNGPropertyList &propList)
Definition: CDRContentCollector.cpp:1005
libcdr::CDRContentCollector
Definition: CDRContentCollector.h:27
CDRCollector.h
CDRTypes.h
libcdr::CDRContentCollector::_startDocument
void _startDocument()
Definition: CDRContentCollector.cpp:83
libcdr::CDRLineStyle
Definition: CDRTypes.h:112
libcdr::CDRContentCollector::collectLevel
void collectLevel(unsigned level)
Definition: CDRContentCollector.cpp:559
libcdr::CDRContentCollector::_endPage
void _endPage()
Definition: CDRContentCollector.cpp:118
libcdr::CDRContentCollector::CDRContentCollector
CDRContentCollector(CDRParserState &ps, ::librevenge::RVNGDrawingInterface *painter, bool reverseOrder=true)
libcdr::CDRContentCollector::m_isPageStarted
bool m_isPageStarted
Definition: CDRContentCollector.h:90
libcdr::CDRContentCollector::collectFillTransform
void collectFillTransform(const CDRTransforms &fillTrafo)
Definition: CDRContentCollector.cpp:554
libcdr::CDRContentCollector::collectObject
void collectObject(unsigned level)
Definition: CDRContentCollector.cpp:146
libcdr::CDRParserState
Definition: CDRCollector.h:32
libcdr::CDRContentCollector::m_fillOutputElementsStack
std::stack< CDROutputElementList > m_fillOutputElementsStack
Definition: CDRContentCollector.h:112
libcdr::CDRColor
Definition: CDRTypes.h:52
libcdr::CDRContentCollector::m_currentTransforms
CDRTransforms m_currentTransforms
Definition: CDRContentCollector.h:105
libcdr::CDRPattern
Definition: CDRTypes.h:215
libcdr::CDRContentCollector::m_currentBBox
CDRBox m_currentBBox
Definition: CDRContentCollector.h:101
libcdr::CDRContentCollector::m_currentPath
CDRPath m_currentPath
Definition: CDRContentCollector.h:104
libcdr::CDRContentCollector::m_splineData
CDRSplineData m_splineData
Definition: CDRContentCollector.h:118
libcdr::CDRImage
Definition: CDRTypes.h:191
libcdr::CDRContentCollector::~CDRContentCollector
virtual ~CDRContentCollector()
Definition: CDRContentCollector.cpp:75
libcdr::CDRContentCollector::collectBmpf
void collectBmpf(unsigned, unsigned, unsigned, const std::vector< unsigned char > &)
Definition: CDRContentCollector.h:53
libcdr::CDRContentCollector::collectBmp
void collectBmp(unsigned, const std::vector< unsigned char > &)
Definition: CDRContentCollector.h:52
CDRPath.h
libcdr::CDRContentCollector::collectPageSize
void collectPageSize(double, double, double, double)
Definition: CDRContentCollector.h:48
libcdr::CDRStyle
Definition: CDRTypes.h:136
libcdr::CDRTransforms
Definition: CDRTransforms.h:50
libcdr::CDRContentCollector::m_painter
librevenge::RVNGDrawingInterface * m_painter
Definition: CDRContentCollector.h:86
libcdr::CDRCollector
Definition: CDRCollector.h:63
libcdr::CDRContentCollector::m_isDocumentStarted
bool m_isDocumentStarted
Definition: CDRContentCollector.h:88
libcdr::CDRContentCollector::collectLineStyleId
void collectLineStyleId(unsigned id)
Definition: CDRContentCollector.cpp:651