- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

CDRCollector.h
Go to the documentation of this file.
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 <lcms2.h>
38 #include "CDRTypes.h"
39 #include "CDRPath.h"
40 #include "CDROutputElementList.h"
41
42 namespace
43 {
44 int cdr_round(double d)
45 {
46 return (d>0) ? int(d+0.5) : int(d-0.5);
47 }
48
49 void writeU16(WPXBinaryData &buffer, const int value)
50 {
51 buffer.append((unsigned char)(value & 0xFF));
52 buffer.append((unsigned char)((value >> 8) & 0xFF));
53 }
54
55 void writeU32(WPXBinaryData &buffer, const int value)
56 {
57 buffer.append((unsigned char)(value & 0xFF));
58 buffer.append((unsigned char)((value >> 8) & 0xFF));
59 buffer.append((unsigned char)((value >> 16) & 0xFF));
60 buffer.append((unsigned char)((value >> 24) & 0xFF));
61 }
62
63 void writeU8(WPXBinaryData &buffer, const int value)
64 {
65 buffer.append((unsigned char)(value & 0xFF));
66 }
67
68 #include "CDRColorProfiles.h"
69
70 }
71
72 namespace libcdr
73 {
74
75 class CDRParserState
76 {
77 public:
78 CDRParserState();
79 ~CDRParserState();
80 std::map<unsigned, CDRFillStyle> m_fillStyles;
81 std::map<unsigned, CDRLineStyle> m_lineStyles;
82 std::map<unsigned, WPXBinaryData> m_bmps;
83 std::map<unsigned, CDRPattern> m_patterns;
84
85 unsigned _getRGBColor(const CDRColor &color);
86 unsigned getBMPColor(const CDRColor &color);
87 WPXString getRGBColorString(const CDRColor &color);
88 cmsHTRANSFORM m_colorTransformCMYK2RGB;
89 cmsHTRANSFORM m_colorTransformLab2RGB;
90
91 private:
92 CDRParserState(const CDRParserState &);
93 CDRParserState &operator=(const CDRParserState &);
94 };
95
96 class CDRCollector
97 {
98 public:
99 CDRCollector() {};
100 virtual ~CDRCollector() {};
101
102 // collector functions
103 virtual void collectPage(unsigned level) = 0;
104 virtual void collectObject(unsigned level) = 0;
105 virtual void collectOtherList() = 0;
106 virtual void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y) = 0;
107 virtual void collectQuadraticBezier(double x1, double y1, double x, double y) = 0;
108 virtual void collectMoveTo(double x, double y) = 0;
109 virtual void collectLineTo(double x, double y) = 0;
110 virtual void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y) = 0;
111 virtual void collectClosePath() = 0;
112 virtual void collectLevel(unsigned level) = 0;
113 virtual void collectTransform(double v0, double v1, double x, double v3, double v4, double y) = 0;
114 virtual void collectFildId(unsigned id) = 0;
115 virtual void collectOutlId(unsigned id) = 0;
116 virtual void collectFild(unsigned id, unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0;
117 virtual void collectOutl(unsigned id, unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
118 double stretch, double angle, const CDRColor &color, const std::vector<unsigned short> &dashArray,
119 unsigned startMarkerId, unsigned endMarkerId) = 0;
120 virtual void collectRotate(double angle) = 0;
121 virtual void collectFlags(unsigned flags) = 0;
122 virtual void collectPageSize(double width, double height) = 0;
123 virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy) = 0;
124 virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2) = 0;
125 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;
126 virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector<unsigned char> &pattern) = 0;
127 virtual void collectPpdt(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned> &knotVector) = 0;
128 virtual void collectFillTransform(double v0, double v1, double x, double v3, double v4, double y) = 0;
129 virtual void collectFillOpacity(double opacity) = 0;
130 virtual void collectPolygon() = 0;
131 virtual void collectSpline() = 0;
132 };
133
134 } // namespace libcdr
135
136 #endif /* __CDRCOLLECTOR_H__ */
137 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libcdr::CDRCollector::collectFlags
virtual void collectFlags(unsigned flags)=0
libcdr::CDRCollector::collectCubicBezier
virtual void collectCubicBezier(double x1, double y1, double x2, double y2, double x, double y)=0
libcdr::CDRCollector::collectArcTo
virtual void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y)=0
libcdr::CDRCollector::collectBitmap
virtual void collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2)=0
CDRColorProfiles.h
libcdr::CDRParserState::m_lineStyles
std::map< unsigned, CDRLineStyle > m_lineStyles
Definition: CDRCollector.h:81
libcdr::CDRParserState::m_bmps
std::map< unsigned, WPXBinaryData > m_bmps
Definition: CDRCollector.h:82
libcdr::CDRCollector::collectObject
virtual void collectObject(unsigned level)=0
libcdr::CDRCollector::collectPage
virtual void collectPage(unsigned level)=0
libcdr::CDRParserState::getBMPColor
unsigned getBMPColor(const CDRColor &color)
Definition: CDRCollector.cpp:55
libcdr::CDRParserState::_getRGBColor
unsigned _getRGBColor(const CDRColor &color)
Definition: CDRCollector.cpp:88
libcdr::CDRCollector::collectFillOpacity
virtual void collectFillOpacity(double opacity)=0
libcdr::CDRParserState::m_colorTransformLab2RGB
cmsHTRANSFORM m_colorTransformLab2RGB
Definition: CDRCollector.h:89
libcdr::CDRImageFill
Definition: CDRTypes.h:98
libcdr::CDRParserState::m_colorTransformCMYK2RGB
cmsHTRANSFORM m_colorTransformCMYK2RGB
Definition: CDRCollector.h:88
libcdr::CDRCollector::collectMoveTo
virtual void collectMoveTo(double x, double y)=0
libcdr::CDRCollector::~CDRCollector
virtual ~CDRCollector()
Definition: CDRCollector.h:100
libcdr::CDRCollector::collectPolygonTransform
virtual void collectPolygonTransform(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)=0
libcdr::CDRCollector::collectFild
virtual void collectFild(unsigned id, unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill)=0
libcdr::CDRCollector::collectOutl
virtual void collectOutl(unsigned id, unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth, double stretch, double angle, const CDRColor &color, const std::vector< unsigned short > &dashArray, unsigned startMarkerId, unsigned endMarkerId)=0
libcdr::CDRCollector::collectOtherList
virtual void collectOtherList()=0
libcdr::CDRCollector::collectRotate
virtual void collectRotate(double angle)=0
libcdr::CDRParserState::getRGBColorString
WPXString getRGBColorString(const CDRColor &color)
Definition: CDRCollector.cpp:328
libcdr::CDRCollector::collectOutlId
virtual void collectOutlId(unsigned id)=0
libcdr::CDRCollector::collectPageSize
virtual void collectPageSize(double width, double height)=0
libcdr::CDRCollector::collectFildId
virtual void collectFildId(unsigned id)=0
CDROutputElementList.h
libcdr::CDRCollector::collectPpdt
virtual void collectPpdt(const std::vector< std::pair< double, double > > &points, const std::vector< unsigned > &knotVector)=0
libcdr::CDRCollector::CDRCollector
CDRCollector()
Definition: CDRCollector.h:99
libcdr::CDRCollector::collectFillTransform
virtual void collectFillTransform(double v0, double v1, double x, double v3, double v4, double y)=0
libcdr::CDRParserState::m_fillStyles
std::map< unsigned, CDRFillStyle > m_fillStyles
Definition: CDRCollector.h:80
libcdr::CDRParserState::operator=
CDRParserState & operator=(const CDRParserState &)
libcdr::CDRCollector::collectBmp
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
libcdr::CDRCollector::collectSpline
virtual void collectSpline()=0
libcdr::CDRCollector::collectQuadraticBezier
virtual void collectQuadraticBezier(double x1, double y1, double x, double y)=0
libcdr::CDRCollector::collectTransform
virtual void collectTransform(double v0, double v1, double x, double v3, double v4, double y)=0
libcdr::CDRCollector::collectLevel
virtual void collectLevel(unsigned level)=0
libcdr::CDRParserState::~CDRParserState
~CDRParserState()
Definition: CDRCollector.cpp:47
libcdr::CDRCollector::collectLineTo
virtual void collectLineTo(double x, double y)=0
CDRTypes.h
libcdr::CDRParserState::CDRParserState
CDRParserState()
Definition: CDRCollector.cpp:33
libcdr::CDRCollector::collectBmpf
virtual void collectBmpf(unsigned patternId, unsigned width, unsigned height, const std::vector< unsigned char > &pattern)=0
libcdr::CDRParserState
Definition: CDRCollector.h:75
libcdr::CDRParserState::m_patterns
std::map< unsigned, CDRPattern > m_patterns
Definition: CDRCollector.h:83
libcdr::CDRColor
Definition: CDRTypes.h:58
libcdr::CDRCollector::collectPolygon
virtual void collectPolygon()=0
libcdr::CDRGradient
Definition: CDRTypes.h:80
libcdr::CDRCollector::collectClosePath
virtual void collectClosePath()=0
CDRPath.h
libcdr::CDRCollector
Definition: CDRCollector.h:96