Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* libcdr
3 : * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17 : *
18 : *
19 : * All Rights Reserved.
20 : *
21 : * For minor contributions see the git repository.
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25 : * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26 : * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27 : * instead of those above.
28 : */
29 :
30 : #ifndef __CDRCONTENTCOLLECTOR_H__
31 : #define __CDRCONTENTCOLLECTOR_H__
32 :
33 : #include <map>
34 : #include <vector>
35 : #include <stack>
36 : #include <libwpg/libwpg.h>
37 : #include <lcms2.h>
38 : #include "CDRTypes.h"
39 : #include "CDRPath.h"
40 : #include "CDROutputElementList.h"
41 : #include "CDRCollector.h"
42 :
43 : namespace libcdr
44 : {
45 :
46 : class CDRContentCollector : public CDRCollector
47 : {
48 : public:
49 : CDRContentCollector(CDRParserState &ps, ::libwpg::WPGPaintInterface *painter);
50 : virtual ~CDRContentCollector();
51 :
52 : // collector functions
53 : void collectPage(unsigned level);
54 : void collectObject(unsigned level);
55 : void collectGroup(unsigned level);
56 : void collectVect(unsigned level);
57 : void collectOtherList();
58 : void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y);
59 : void collectQuadraticBezier(double x1, double y1, double x, double y);
60 : void collectMoveTo(double x, double y);
61 : void collectLineTo(double x, double y);
62 : void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y);
63 : void collectClosePath();
64 : void collectLevel(unsigned level);
65 : void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform);
66 : void collectFildId(unsigned id);
67 : void collectOutlId(unsigned id);
68 0 : void collectFild(unsigned, unsigned short, const CDRColor &, const CDRColor &, const CDRGradient &, const CDRImageFill &) {}
69 0 : void collectOutl(unsigned, unsigned short, unsigned short, unsigned short, double, double, double, const CDRColor &,
70 0 : const std::vector<unsigned> &, unsigned, unsigned) {}
71 : void collectRotate(double angle, double cx, double cy);
72 : void collectFlags(unsigned flags, bool considerFlags);
73 0 : void collectPageSize(double, double, double, double) {}
74 : void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy);
75 : void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2);
76 0 : void collectBmp(unsigned, unsigned, unsigned, unsigned, unsigned, const std::vector<unsigned>&, const std::vector<unsigned char>&) {}
77 0 : void collectBmp(unsigned, const std::vector<unsigned char>&) {}
78 0 : void collectBmpf(unsigned, unsigned, unsigned, const std::vector<unsigned char> &) {}
79 : void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector);
80 : void collectFillTransform(const CDRTransforms &fillTrafo);
81 : void collectFillOpacity(double opacity);
82 : void collectPolygon();
83 : void collectSpline();
84 0 : void collectColorProfile(const std::vector<unsigned char> &) {}
85 : void collectBBox(double x0, double y0, double x1, double y1);
86 : void collectSpnd(unsigned spnd);
87 : void collectVectorPattern(unsigned id, const WPXBinaryData &data);
88 0 : void collectPaletteEntry(unsigned, unsigned, const CDRColor &) {}
89 0 : void collectFont(unsigned, unsigned short, const WPXString &) {}
90 0 : void collectText(unsigned, unsigned, const std::vector<unsigned char>&,
91 0 : const std::vector<uint64_t>&, const std::map<unsigned, CDRCharacterStyle>&) {}
92 : void collectArtisticText();
93 : void collectParagraphText();
94 0 : void collectStlt(const std::map<unsigned, CDRCharacterStyle> &) {}
95 :
96 : private:
97 : CDRContentCollector(const CDRContentCollector &);
98 : CDRContentCollector &operator=(const CDRContentCollector &);
99 :
100 : // helper functions
101 : void _startPage(double width, double height);
102 : void _endPage();
103 : void _flushCurrentPath();
104 :
105 : void _fillProperties(WPXPropertyList &propList, WPXPropertyListVector &vec);
106 : void _lineProperties(WPXPropertyList &propList);
107 : void _generateBitmapFromPattern(WPXBinaryData &bitmap, const CDRPattern &pattern, const CDRColor &fgColor, const CDRColor &bgColor);
108 :
109 : libwpg::WPGPaintInterface *m_painter;
110 :
111 : bool m_isPageProperties;
112 : bool m_isPageStarted;
113 : bool m_ignorePage;
114 :
115 : CDRPage m_page;
116 : unsigned m_pageIndex;
117 : unsigned m_currentFildId, m_currentOutlId;
118 : unsigned m_spnd;
119 : unsigned m_currentObjectLevel, m_currentGroupLevel, m_currentVectLevel, m_currentPageLevel;
120 : CDRImage m_currentImage;
121 : CDRText m_currentText;
122 : double m_currentTextOffsetX;
123 : double m_currentTextOffsetY;
124 : CDRBBox m_currentBBox;
125 :
126 : CDRPath m_currentPath;
127 : CDRTransforms m_currentTransforms;
128 : CDRTransforms m_fillTransforms;
129 : CDRPolygon *m_polygon;
130 : bool m_isInPolygon;
131 : bool m_isInSpline;
132 : std::stack<CDROutputElementList> *m_outputElements;
133 : std::stack<CDROutputElementList> m_contentOutputElements;
134 : std::stack<CDROutputElementList> m_fillOutputElements;
135 : std::stack<unsigned> m_groupLevels;
136 : std::stack<CDRTransforms> m_groupTransforms;
137 : CDRSplineData m_splineData;
138 : double m_fillOpacity;
139 :
140 : CDRParserState &m_ps;
141 : };
142 :
143 : } // namespace libcdr
144 :
145 : #endif /* __CDRCOLLECTOR_H__ */
146 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|