CDRContentCollector.h Source File documentation

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 <memory>
15 #include <utility>
16 #include <vector>
17 #include <stack>
18 #include <queue>
19
20 #include <librevenge/librevenge.h>
21
22 #include "CDROutputElementList.h"
23 #include "CDRTransforms.h"
24 #include "CDRTypes.h"
25 #include "CDRPath.h"
26 #include "CDRCollector.h"
27
28 namespace libcdr
29 {
30
31 class CDRContentCollector : public CDRCollector
32 {
33 public:
34 CDRContentCollector(CDRParserState &ps, librevenge::RVNGDrawingInterface *painter, bool reverseOrder = true);
35 ~CDRContentCollector() override;
36
37 // collector functions
38 void collectPage(unsigned level) override;
39 void collectObject(unsigned level) override;
40 void collectGroup(unsigned level) override;
41 void collectVect(unsigned level) override;
42 void collectOtherList() override;
43 void collectPath(const CDRPath &path) override;
44 void collectLevel(unsigned level) override;
45 void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) override;
46 void collectFillStyle(unsigned,const CDRFillStyle &) override {}
47 void collectFillStyleId(unsigned id) override;
48 void collectLineStyle(unsigned,const CDRLineStyle &) override {}
49 void collectLineStyleId(unsigned id) override;
50 void collectRotate(double angle, double cx, double cy) override;
51 void collectFlags(unsigned flags, bool considerFlags) override;
52 void collectPageSize(double, double, double, double) override {}
53 void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) override;
54 void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) override;
55 void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector<unsigned> &, const std::vector<unsigned char> &) override {}
56 void collectBmp(unsigned, const std::vector<unsigned char> &) override {}
57 void collectBmpf(unsigned, unsigned, unsigned, const std::vector<unsigned char> &) override {}
58 void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) override;
59 void collectFillTransform(const CDRTransforms &fillTrafo) override;
60 void collectFillOpacity(double opacity) override;
61 void collectPolygon() override;
62 void collectSpline() override;
63 void collectColorProfile(const std::vector<unsigned char> &) override {}
64 void collectBBox(double x0, double y0, double x1, double y1) override;
65 void collectSpnd(unsigned spnd) override;
66 void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data) override;
67 void collectPaletteEntry(unsigned, unsigned, const CDRColor &) override {}
68 void collectText(unsigned, unsigned, const std::vector<unsigned char> &,
69 const std::vector<unsigned char> &, const std::map<unsigned, CDRStyle> &) override {}
70 void collectArtisticText(double x, double y) override;
71 void collectParagraphText(double x, double y, double width, double height) override;
72 void collectStld(unsigned, const CDRStyle &) override {}
73 void collectStyleId(unsigned styleId) override;
74
75 private:
76 CDRContentCollector(const CDRContentCollector &);
77 CDRContentCollector &operator=(const CDRContentCollector &);
78
79 // helper functions
80 void _startDocument();
81 void _endDocument();
82 void _startPage(double width, double height);
83 void _endPage();
84 void _flushCurrentPath();
85
86 void _fillProperties(librevenge::RVNGPropertyList &propList);
87 void _lineProperties(librevenge::RVNGPropertyList &propList);
88 void _generateBitmapFromPattern(librevenge::RVNGBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor);
89
90 librevenge::RVNGDrawingInterface *m_painter;
91
92 bool m_isDocumentStarted;
93 bool m_isPageProperties;
94 bool m_isPageStarted;
95 bool m_ignorePage;
96
97 CDRPage m_page;
98 unsigned m_pageIndex;
99 CDRFillStyle m_currentFillStyle;
100 CDRLineStyle m_currentLineStyle;
101 unsigned m_spnd;
102 unsigned m_currentObjectLevel, m_currentGroupLevel, m_currentVectLevel, m_currentPageLevel, m_currentStyleId;
103 CDRImage m_currentImage;
104 const std::vector<CDRTextLine> *m_currentText;
105 CDRBox m_currentBBox;
106 CDRBox m_currentTextBox;
107
108 CDRPath m_currentPath;
109 CDRTransforms m_currentTransforms;
110 CDRTransforms m_fillTransforms;
111 std::unique_ptr<CDRPolygon> m_polygon;
112 bool m_isInPolygon;
113 bool m_isInSpline;
114 std::stack<CDROutputElementList> *m_outputElementsStack;
115 std::stack<CDROutputElementList> m_contentOutputElementsStack;
116 std::stack<CDROutputElementList> m_fillOutputElementsStack;
117 std::queue<CDROutputElementList> *m_outputElementsQueue;
118 std::queue<CDROutputElementList> m_contentOutputElementsQueue;
119 std::queue<CDROutputElementList> m_fillOutputElementsQueue;
120 std::stack<unsigned> m_groupLevels;
121 std::stack<CDRTransforms> m_groupTransforms;
122 CDRSplineData m_splineData;
123 double m_fillOpacity;
124 bool m_reverseOrder;
125
126 CDRParserState &m_ps;
127 };
128
129 } // namespace libcdr
130
131 #endif /* __CDRCOLLECTOR_H__ */
132 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libcdr::CDRContentCollector::collectLineStyleId
void collectLineStyleId(unsigned id) override
Definition: CDRContentCollector.cpp:651
libcdr::CDRContentCollector::collectOtherList
void collectOtherList() override
Definition: CDRContentCollector.cpp:205
libcdr::CDRContentCollector::m_currentText
const std::vector< CDRTextLine > * m_currentText
Definition: CDRContentCollector.h:104
libcdr::CDRContentCollector::m_pageIndex
unsigned m_pageIndex
Definition: CDRContentCollector.h:98
libcdr::CDRContentCollector::_flushCurrentPath
void _flushCurrentPath()
Definition: CDRContentCollector.cpp:216
libcdr::CDRContentCollector::m_currentFillStyle
CDRFillStyle m_currentFillStyle
Definition: CDRContentCollector.h:99
libcdr::CDRContentCollector::collectVect
void collectVect(unsigned level) override
Definition: CDRContentCollector.cpp:182
libcdr::CDRContentCollector::~CDRContentCollector
~CDRContentCollector() override
Definition: CDRContentCollector.cpp:79
libcdr::CDRContentCollector::m_groupLevels
std::stack< unsigned > m_groupLevels
Definition: CDRContentCollector.h:120
libcdr::CDRBox
Definition: CDRTypes.h:24
libcdr::CDRContentCollector::m_fillTransforms
CDRTransforms m_fillTransforms
Definition: CDRContentCollector.h:110
libcdr::CDRContentCollector::collectBmp
void collectBmp(unsigned, const std::vector< unsigned char > &) override
Definition: CDRContentCollector.h:56
libcdr::CDRPath
Definition: CDRPath.h:36
libcdr::CDRContentCollector::m_page
CDRPage m_page
Definition: CDRContentCollector.h:97
libcdr::CDRContentCollector::m_groupTransforms
std::stack< CDRTransforms > m_groupTransforms
Definition: CDRContentCollector.h:121
libcdr::CDRContentCollector::m_outputElementsStack
std::stack< CDROutputElementList > * m_outputElementsStack
Definition: CDRContentCollector.h:114
libcdr::CDRContentCollector::m_currentImage
CDRImage m_currentImage
Definition: CDRContentCollector.h:103
libcdr::CDRContentCollector::collectPpdt
void collectPpdt(const std::vector< std::pair< double, double > > &points, const std::vector< unsigned > &knotVector) override
Definition: CDRContentCollector.cpp:1221
libcdr::CDRPage
Definition: CDRTypes.h:239
libcdr::CDRContentCollector::collectFlags
void collectFlags(unsigned flags, bool considerFlags) override
Definition: CDRContentCollector.cpp:193
libcdr::CDRContentCollector::_generateBitmapFromPattern
void _generateBitmapFromPattern(librevenge::RVNGBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor)
Definition: CDRContentCollector.cpp:1143
libcdr::CDRContentCollector::collectStld
void collectStld(unsigned, const CDRStyle &) override
Definition: CDRContentCollector.h:72
libcdr::CDRContentCollector::m_contentOutputElementsQueue
std::queue< CDROutputElementList > m_contentOutputElementsQueue
Definition: CDRContentCollector.h:118
libcdr::CDRContentCollector::m_currentPageLevel
unsigned m_currentPageLevel
Definition: CDRContentCollector.h:102
libcdr::CDRContentCollector::m_contentOutputElementsStack
std::stack< CDROutputElementList > m_contentOutputElementsStack
Definition: CDRContentCollector.h:115
libcdr::CDRContentCollector::collectBmpf
void collectBmpf(unsigned, unsigned, unsigned, const std::vector< unsigned char > &) override
Definition: CDRContentCollector.h:57
libcdr::CDRContentCollector::m_currentObjectLevel
unsigned m_currentObjectLevel
Definition: CDRContentCollector.h:102
libcdr::CDRContentCollector::m_isInPolygon
bool m_isInPolygon
Definition: CDRContentCollector.h:112
CDRTransforms.h
libcdr::CDRContentCollector::m_spnd
unsigned m_spnd
Definition: CDRContentCollector.h:101
libcdr::CDRSplineData
Definition: CDRTypes.h:250
libcdr::CDRContentCollector::m_reverseOrder
bool m_reverseOrder
Definition: CDRContentCollector.h:124
libcdr::CDRContentCollector::m_currentVectLevel
unsigned m_currentVectLevel
Definition: CDRContentCollector.h:102
libcdr::CDRFillStyle
Definition: CDRTypes.h:101
libcdr::CDRContentCollector::collectBBox
void collectBBox(double x0, double y0, double x1, double y1) override
Definition: CDRContentCollector.cpp:1231
libcdr::CDRContentCollector::collectPolygonTransform
void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) override
Definition: CDRContentCollector.cpp:678
libcdr::CDRContentCollector::m_ignorePage
bool m_ignorePage
Definition: CDRContentCollector.h:95
libcdr::CDRContentCollector::m_isInSpline
bool m_isInSpline
Definition: CDRContentCollector.h:113
libcdr::CDRContentCollector::_endDocument
void _endDocument()
Definition: CDRContentCollector.cpp:97
libcdr::CDRContentCollector::m_ps
CDRParserState & m_ps
Definition: CDRContentCollector.h:126
libcdr::CDRContentCollector::collectArtisticText
void collectArtisticText(double x, double y) override
Definition: CDRContentCollector.cpp:1297
libcdr
Definition: CDRCollector.h:24
libcdr::CDRContentCollector::m_fillOutputElementsQueue
std::queue< CDROutputElementList > m_fillOutputElementsQueue
Definition: CDRContentCollector.h:119
libcdr::CDRContentCollector::collectFillOpacity
void collectFillOpacity(double opacity) override
Definition: CDRContentCollector.cpp:1226
libcdr::CDRContentCollector::_fillProperties
void _fillProperties(librevenge::RVNGPropertyList &propList)
Definition: CDRContentCollector.cpp:683
libcdr::CDRContentCollector::m_currentLineStyle
CDRLineStyle m_currentLineStyle
Definition: CDRContentCollector.h:100
libcdr::CDRContentCollector::m_currentStyleId
unsigned m_currentStyleId
Definition: CDRContentCollector.h:102
libcdr::CDRContentCollector::collectTransform
void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) override
Definition: CDRContentCollector.cpp:546
CDROutputElementList.h
libcdr::CDRContentCollector::collectSpnd
void collectSpnd(unsigned spnd) override
Definition: CDRContentCollector.cpp:1244
libcdr::CDRContentCollector::m_currentTextBox
CDRBox m_currentTextBox
Definition: CDRContentCollector.h:106
libcdr::CDRContentCollector::collectFillStyle
void collectFillStyle(unsigned, const CDRFillStyle &) override
Definition: CDRContentCollector.h:46
libcdr::CDRContentCollector::m_fillOpacity
double m_fillOpacity
Definition: CDRContentCollector.h:123
libcdr::CDRContentCollector::operator=
CDRContentCollector & operator=(const CDRContentCollector &)
libcdr::CDRContentCollector::m_currentGroupLevel
unsigned m_currentGroupLevel
Definition: CDRContentCollector.h:102
libcdr::CDRContentCollector::collectVectorPattern
void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data) override
Definition: CDRContentCollector.cpp:1252
libcdr::CDRContentCollector::collectPaletteEntry
void collectPaletteEntry(unsigned, unsigned, const CDRColor &) override
Definition: CDRContentCollector.h:67
libcdr::CDRContentCollector::collectBmp
void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector< unsigned > &, const std::vector< unsigned char > &) override
Definition: CDRContentCollector.h:55
libcdr::CDRContentCollector::collectRotate
void collectRotate(double angle, double cx, double cy) override
Definition: CDRContentCollector.cpp:658
libcdr::CDRContentCollector::collectLevel
void collectLevel(unsigned level) override
Definition: CDRContentCollector.cpp:559
libcdr::CDRContentCollector::collectGroup
void collectGroup(unsigned level) override
Definition: CDRContentCollector.cpp:161
libcdr::CDRContentCollector::collectParagraphText
void collectParagraphText(double x, double y, double width, double height) override
Definition: CDRContentCollector.cpp:1306
libcdr::CDRContentCollector::m_isPageProperties
bool m_isPageProperties
Definition: CDRContentCollector.h:93
libcdr::CDRContentCollector::collectFillTransform
void collectFillTransform(const CDRTransforms &fillTrafo) override
Definition: CDRContentCollector.cpp:554
libcdr::CDRContentCollector::m_outputElementsQueue
std::queue< CDROutputElementList > * m_outputElementsQueue
Definition: CDRContentCollector.h:117
libcdr::CDRContentCollector::collectBitmap
void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) override
Definition: CDRContentCollector.cpp:1214
libcdr::CDRContentCollector::CDRContentCollector
CDRContentCollector(CDRParserState &ps, librevenge::RVNGDrawingInterface *painter, bool reverseOrder=true)
Definition: CDRContentCollector.cpp:63
libcdr::CDRContentCollector::_startPage
void _startPage(double width, double height)
Definition: CDRContentCollector.cpp:108
libcdr::CDRContentCollector::collectSpline
void collectSpline() override
Definition: CDRContentCollector.cpp:673
libcdr::CDRContentCollector::_lineProperties
void _lineProperties(librevenge::RVNGPropertyList &propList)
Definition: CDRContentCollector.cpp:989
libcdr::CDRContentCollector
Definition: CDRContentCollector.h:31
libcdr::CDRContentCollector::collectPage
void collectPage(unsigned level) override
Definition: CDRContentCollector.cpp:141
libcdr::CDRContentCollector::collectColorProfile
void collectColorProfile(const std::vector< unsigned char > &) override
Definition: CDRContentCollector.h:63
CDRCollector.h
CDRTypes.h
libcdr::CDRContentCollector::_startDocument
void _startDocument()
Definition: CDRContentCollector.cpp:87
libcdr::CDRLineStyle
Definition: CDRTypes.h:113
libcdr::CDRContentCollector::collectPolygon
void collectPolygon() override
Definition: CDRContentCollector.cpp:668
libcdr::CDRContentCollector::_endPage
void _endPage()
Definition: CDRContentCollector.cpp:122
libcdr::CDRContentCollector::m_isPageStarted
bool m_isPageStarted
Definition: CDRContentCollector.h:94
libcdr::CDRParserState
Definition: CDRCollector.h:30
libcdr::CDRContentCollector::m_fillOutputElementsStack
std::stack< CDROutputElementList > m_fillOutputElementsStack
Definition: CDRContentCollector.h:116
libcdr::CDRColor
Definition: CDRTypes.h:53
libcdr::CDRContentCollector::collectPageSize
void collectPageSize(double, double, double, double) override
Definition: CDRContentCollector.h:52
libcdr::CDRContentCollector::m_currentTransforms
CDRTransforms m_currentTransforms
Definition: CDRContentCollector.h:109
libcdr::CDRContentCollector::collectLineStyle
void collectLineStyle(unsigned, const CDRLineStyle &) override
Definition: CDRContentCollector.h:48
libcdr::CDRPattern
Definition: CDRTypes.h:216
libcdr::CDRContentCollector::m_currentBBox
CDRBox m_currentBBox
Definition: CDRContentCollector.h:105
libcdr::CDRContentCollector::m_polygon
std::unique_ptr< CDRPolygon > m_polygon
Definition: CDRContentCollector.h:111
libcdr::CDRContentCollector::collectObject
void collectObject(unsigned level) override
Definition: CDRContentCollector.cpp:150
libcdr::CDRContentCollector::m_currentPath
CDRPath m_currentPath
Definition: CDRContentCollector.h:108
libcdr::CDRContentCollector::m_splineData
CDRSplineData m_splineData
Definition: CDRContentCollector.h:122
libcdr::CDRImage
Definition: CDRTypes.h:192
libcdr::CDRContentCollector::collectFillStyleId
void collectFillStyleId(unsigned id) override
Definition: CDRContentCollector.cpp:644
libcdr::CDRContentCollector::collectText
void collectText(unsigned, unsigned, const std::vector< unsigned char > &, const std::vector< unsigned char > &, const std::map< unsigned, CDRStyle > &) override
Definition: CDRContentCollector.h:68
CDRPath.h
libcdr::CDRContentCollector::collectPath
void collectPath(const CDRPath &path) override
Definition: CDRContentCollector.cpp:210
libcdr::CDRContentCollector::collectStyleId
void collectStyleId(unsigned styleId) override
Definition: CDRContentCollector.cpp:1317
libcdr::CDRStyle
Definition: CDRTypes.h:137
libcdr::CDRTransforms
Definition: CDRTransforms.h:48
libcdr::CDRContentCollector::m_painter
librevenge::RVNGDrawingInterface * m_painter
Definition: CDRContentCollector.h:90
libcdr::CDRCollector
Definition: CDRCollector.h:61
libcdr::CDRContentCollector::m_isDocumentStarted
bool m_isDocumentStarted
Definition: CDRContentCollector.h:92