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 __CDRCOLLECTOR_H__
31 : #define __CDRCOLLECTOR_H__
32 :
33 : #include <map>
34 : #include <vector>
35 : #include <stack>
36 : #include <libwpg/libwpg.h>
37 : #include <libwpd-stream/libwpd-stream.h>
38 : #include <lcms2.h>
39 : #include "CDRTypes.h"
40 : #include "CDRPath.h"
41 : #include "CDROutputElementList.h"
42 : #include "libcdr_utils.h"
43 :
44 : namespace
45 : {
46 : #include "CDRColorProfiles.h"
47 : }
48 :
49 : namespace libcdr
50 : {
51 :
52 : class CDRParserState
53 : {
54 : public:
55 : CDRParserState();
56 : ~CDRParserState();
57 : std::map<unsigned, CDRFillStyle> m_fillStyles;
58 : std::map<unsigned, CDRLineStyle> m_lineStyles;
59 : std::map<unsigned, WPXBinaryData> m_bmps;
60 : std::map<unsigned, CDRPattern> m_patterns;
61 : std::map<unsigned, WPXBinaryData> m_vects;
62 : std::vector<CDRPage> m_pages;
63 : std::map<unsigned, CDRColor> m_documentPalette;
64 : std::map<unsigned, WPXString> m_fonts;
65 : std::map<unsigned, CDRText> m_texts;
66 :
67 : unsigned _getRGBColor(const CDRColor &color);
68 : unsigned getBMPColor(const CDRColor &color);
69 : WPXString getRGBColorString(const CDRColor &color);
70 : cmsHTRANSFORM m_colorTransformCMYK2RGB;
71 : cmsHTRANSFORM m_colorTransformLab2RGB;
72 : cmsHTRANSFORM m_colorTransformRGB2RGB;
73 :
74 : void setColorTransform(const std::vector<unsigned char> &profile);
75 : void setColorTransform(WPXInputStream *input);
76 :
77 : private:
78 : CDRParserState(const CDRParserState &);
79 : CDRParserState &operator=(const CDRParserState &);
80 : };
81 :
82 : class CDRCollector
83 : {
84 : public:
85 0 : CDRCollector() {}
86 0 : virtual ~CDRCollector() {}
87 :
88 : // collector functions
89 : virtual void collectPage(unsigned level) = 0;
90 : virtual void collectObject(unsigned level) = 0;
91 : virtual void collectGroup(unsigned level) = 0;
92 : virtual void collectVect(unsigned level) = 0;
93 : virtual void collectOtherList() = 0;
94 : virtual void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y) = 0;
95 : virtual void collectQuadraticBezier(double x1, double y1, double x, double y) = 0;
96 : virtual void collectMoveTo(double x, double y) = 0;
97 : virtual void collectLineTo(double x, double y) = 0;
98 : virtual void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y) = 0;
99 : virtual void collectClosePath() = 0;
100 : virtual void collectLevel(unsigned level) = 0;
101 : virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) = 0;
102 : virtual void collectFildId(unsigned id) = 0;
103 : virtual void collectOutlId(unsigned id) = 0;
104 : virtual void collectFild(unsigned id, unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0;
105 : virtual void collectOutl(unsigned id, unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
106 : double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
107 : unsigned startMarkerId, unsigned endMarkerId) = 0;
108 : virtual void collectRotate(double angle, double cx, double cy) = 0;
109 : virtual void collectFlags(unsigned flags, bool considerFlags) = 0;
110 : virtual void collectPageSize(double width, double height, double offsetX, double offsetY) = 0;
111 : virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) = 0;
112 : virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) = 0;
113 : virtual void collectBmp(unsigned imageId, unsigned colorModel, unsigned width, unsigned height, unsigned bpp, const std::vector<unsigned> &palette, const std::vector<unsigned char> &bitmap) = 0;
114 : virtual void collectBmp(unsigned imageId, const std::vector<unsigned char> &bitmap) = 0;
115 : virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector<unsigned char> &pattern) = 0;
116 : virtual void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) = 0;
117 : virtual void collectFillTransform(const CDRTransforms &fillTrafos) = 0;
118 : virtual void collectFillOpacity(double opacity) = 0;
119 : virtual void collectPolygon() = 0;
120 : virtual void collectSpline() = 0;
121 : virtual void collectColorProfile(const std::vector<unsigned char> &profile) = 0;
122 : virtual void collectBBox(double x0, double y0, double x1, double y1) = 0;
123 : virtual void collectSpnd(unsigned spnd) = 0;
124 : virtual void collectVectorPattern(unsigned id, const WPXBinaryData &data) = 0;
125 : virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color) = 0;
126 : virtual void collectFont(unsigned fontId, unsigned short fontEncoding, const WPXString &font) = 0;
127 : virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
128 : const std::vector<uint64_t> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides) = 0;
129 : virtual void collectArtisticText() = 0;
130 : virtual void collectParagraphText() = 0;
131 : virtual void collectStlt(const std::map<unsigned, CDRCharacterStyle> &charStyles) = 0;
132 : };
133 :
134 : } // namespace libcdr
135 :
136 : #endif /* __CDRCOLLECTOR_H__ */
137 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|