- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

CDRTypes.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 * All Rights Reserved.
19 *
20 * For minor contributions see the git repository.
21 *
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26 * instead of those above.
27 */
28
29 #ifndef __CDRTYPES_H__
30 #define __CDRTYPES_H__
31
32 #include <vector>
33 #include <math.h>
34 #include <libwpd/libwpd.h>
35
36 namespace libcdr
37 {
38 class CDRPath;
39
40 struct CDRTransform
41 {
42 double m_v0;
43 double m_v1;
44 double m_x0;
45 double m_v3;
46 double m_v4;
47 double m_y0;
48 CDRTransform()
49 : m_v0(1.0), m_v1(0.0), m_x0(0.0),
50 m_v3(0.0), m_v4(1.0), m_y0(0.0) {}
51 CDRTransform(double v0, double v1, double x0, double v3, double v4, double y0)
52 : m_v0(v0), m_v1(v1), m_x0(x0), m_v3(v3), m_v4(v4), m_y0(y0) {}
53
54 void applyToPoint(double &x, double &y) const;
55 void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const;
56 };
57
58 struct CDRColor
59 {
60 unsigned short m_colorModel;
61 unsigned m_colorValue;
62 CDRColor() : m_colorModel(0), m_colorValue(0) {}
63 CDRColor(unsigned short colorModel, unsigned colorValue)
64 : m_colorModel(colorModel), m_colorValue(colorValue) {}
65 CDRColor(const CDRColor &color)
66 : m_colorModel(color.m_colorModel), m_colorValue(color.m_colorValue) {}
67 };
68
69 struct CDRGradientStop
70 {
71 CDRColor m_color;
72 double m_offset;
73 CDRGradientStop() : m_color(), m_offset(0.0) {}
74 CDRGradientStop(const CDRColor &color, double offset)
75 : m_color(color), m_offset(offset) {}
76 CDRGradientStop(const CDRGradientStop &stop)
77 : m_color(stop.m_color), m_offset(stop.m_offset) {}
78 };
79
80 struct CDRGradient
81 {
82 unsigned char m_type;
83 unsigned char m_mode;
84 double m_angle;
85 double m_midPoint;
86 int m_edgeOffset;
87 int m_centerXOffset;
88 int m_centerYOffset;
89 std::vector<CDRGradientStop> m_stops;
90 CDRGradient()
91 : m_type(0), m_mode(0), m_angle(0.0), m_midPoint(0.0), m_edgeOffset(0), m_centerXOffset(0), m_centerYOffset(0), m_stops() {}
92 CDRGradient(const CDRGradient &gradient)
93 : m_type(gradient.m_type), m_mode(gradient.m_mode), m_angle(gradient.m_angle), m_midPoint(gradient.m_midPoint),
94 m_edgeOffset(gradient.m_edgeOffset), m_centerXOffset(gradient.m_centerXOffset), m_centerYOffset(gradient.m_centerYOffset),
95 m_stops(gradient.m_stops) {}
96 };
97
98 struct CDRImageFill
99 {
100 unsigned id;
101 double width;
102 double height;
103 bool isRelative;
104 double xOffset;
105 double yOffset;
106 double rcpOffset;
107 unsigned char flags;
108 bool refPoint;
109 CDRImageFill() : id(0), width(0.0), height(0.0), isRelative(false), xOffset(0.0), yOffset(0.0), rcpOffset(0.0), flags(0), refPoint(false) {}
110 CDRImageFill(unsigned i, double w, double h, bool r, double x, double y, double o, unsigned char f, bool rp)
111 : id(i), width(w), height(h), isRelative(r), xOffset(x), yOffset(y), rcpOffset(o), flags(f), refPoint(rp) {}
112 };
113
114 struct CDRFillStyle
115 {
116 unsigned short fillType;
117 CDRColor color1, color2;
118 CDRGradient gradient;
119 CDRImageFill imageFill;
120 CDRFillStyle()
121 : fillType(0), color1(), color2(), gradient(), imageFill() {}
122 CDRFillStyle(unsigned short ft, CDRColor c1, CDRColor c2, const CDRGradient &gr, const CDRImageFill &img)
123 : fillType(ft), color1(c1), color2(c2), gradient(gr), imageFill(img) {}
124 CDRFillStyle(const CDRFillStyle &style)
125 : fillType(style.fillType), color1(style.color1), color2(style.color2), gradient(style.gradient), imageFill(style.imageFill) {}
126 };
127
128 struct CDRLineStyle
129 {
130 unsigned short lineType;
131 unsigned short capsType;
132 unsigned short joinType;
133 double lineWidth;
134 double stretch;
135 double angle;
136 CDRColor color;
137 std::vector<unsigned short> dashArray;
138 unsigned startMarkerId;
139 unsigned endMarkerId;
140 CDRLineStyle()
141 : lineType(0), capsType(0), joinType(0), lineWidth(0.0),
142 stretch(0.0), angle(0.0), color(), dashArray(),
143 startMarkerId(0), endMarkerId(0) {}
144 CDRLineStyle(unsigned short lt, unsigned short ct, unsigned short jt,
145 double lw, double st, double a, const CDRColor &c, const std::vector<unsigned short> &da,
146 unsigned smi, unsigned emi)
147 : lineType(lt), capsType(ct), joinType(jt), lineWidth(lw),
148 stretch(st), angle(a), color(c), dashArray(da),
149 startMarkerId(smi), endMarkerId(emi) {}
150 };
151
152 struct CDRPolygon
153 {
154 unsigned m_numAngles;
155 unsigned m_nextPoint;
156 double m_rx;
157 double m_ry;
158 double m_cx;
159 double m_cy;
160 CDRPolygon() : m_numAngles(0), m_nextPoint(0), m_rx(0.0), m_ry(0.0), m_cx(0.0), m_cy(0.0) {}
161 CDRPolygon(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)
162 : m_numAngles(numAngles), m_nextPoint(nextPoint), m_rx(rx), m_ry(ry), m_cx(cx), m_cy(cy) {}
163 void create(CDRPath &path) const;
164 };
165
166 struct CDRImage
167 {
168 WPXBinaryData m_image;
169 double m_x1;
170 double m_x2;
171 double m_y1;
172 double m_y2;
173 CDRImage() : m_image(), m_x1(0.0), m_x2(0.0), m_y1(0.0), m_y2(0.0) {}
174 CDRImage(const WPXBinaryData &image, double x1, double x2, double y1, double y2)
175 : m_image(image), m_x1(x1), m_x2(x2), m_y1(y1), m_y2(y2) {}
176 double getMiddleX() const
177 {
178 return (m_x1 + m_x2) / 2.0;
179 }
180 double getMiddleY() const
181 {
182 return (m_y1 + m_y2) / 2.0;
183 }
184 double getWidth() const
185 {
186 return fabs(m_x1 - m_x2);
187 }
188 double getHeight() const
189 {
190 return fabs(m_y1 - m_y2);
191 }
192 const WPXBinaryData &getImage() const
193 {
194 return m_image;
195 }
196 };
197
198 struct CDRPattern
199 {
200 unsigned width;
201 unsigned height;
202 std::vector<unsigned char> pattern;
203 CDRPattern() : width(0), height(0), pattern() {}
204 CDRPattern(unsigned w, unsigned h, const std::vector<unsigned char> &p)
205 : width(w), height(h), pattern(p) {}
206 };
207
208 struct CDRSplineData
209 {
210 std::vector<std::pair<double, double> > points;
211 std::vector<unsigned> knotVector;
212 CDRSplineData() : points(), knotVector() {}
213 CDRSplineData(const std::vector<std::pair<double, double> > &ps, const std::vector<unsigned> &kntv)
214 : points(ps), knotVector(kntv) {}
215 CDRSplineData(const CDRSplineData &data)
216 : points(data.points), knotVector(data.knotVector) {}
217 void clear()
218 {
219 points.clear();
220 knotVector.clear();
221 }
222 bool empty()
223 {
224 return (points.empty() || knotVector.empty());
225 }
226 void create(CDRPath &path) const;
227 };
228
229 } // namespace libcdr
230
231 #endif /* __CDRTYPES_H__ */
232 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libcdr::CDRImage::getMiddleX
double getMiddleX() const
Definition: CDRTypes.h:176
libcdr::CDRGradient::m_centerYOffset
int m_centerYOffset
Definition: CDRTypes.h:88
libcdr::CDRImage::CDRImage
CDRImage()
Definition: CDRTypes.h:173
libcdr::CDRTransform::m_v1
double m_v1
Definition: CDRTypes.h:43
libcdr::CDRSplineData::create
void create(CDRPath &path) const
Definition: CDRTypes.cpp:142
libcdr::CDRPolygon::m_nextPoint
unsigned m_nextPoint
Definition: CDRTypes.h:155
libcdr::CDRTransform::m_x0
double m_x0
Definition: CDRTypes.h:44
libcdr::CDRImageFill::CDRImageFill
CDRImageFill(unsigned i, double w, double h, bool r, double x, double y, double o, unsigned char f, bool rp)
Definition: CDRTypes.h:110
libcdr::CDRImage::m_x1
double m_x1
Definition: CDRTypes.h:169
libcdr::CDRImageFill::yOffset
double yOffset
Definition: CDRTypes.h:105
libcdr::CDRLineStyle::CDRLineStyle
CDRLineStyle(unsigned short lt, unsigned short ct, unsigned short jt, double lw, double st, double a, const CDRColor &c, const std::vector< unsigned short > &da, unsigned smi, unsigned emi)
Definition: CDRTypes.h:144
libcdr::CDRImage::getMiddleY
double getMiddleY() const
Definition: CDRTypes.h:180
libcdr::CDRPattern::width
unsigned width
Definition: CDRTypes.h:200
libcdr::CDRLineStyle::color
CDRColor color
Definition: CDRTypes.h:136
libcdr::CDRPattern::CDRPattern
CDRPattern()
Definition: CDRTypes.h:203
libcdr::CDRGradientStop::CDRGradientStop
CDRGradientStop(const CDRGradientStop &stop)
Definition: CDRTypes.h:76
libcdr::CDRImageFill::width
double width
Definition: CDRTypes.h:101
libcdr::CDRFillStyle::color1
CDRColor color1
Definition: CDRTypes.h:117
libcdr::CDRFillStyle::color2
CDRColor color2
Definition: CDRTypes.h:117
libcdr::CDRPath
Definition: CDRPath.h:52
libcdr::CDRLineStyle::angle
double angle
Definition: CDRTypes.h:135
libcdr::CDRSplineData::CDRSplineData
CDRSplineData(const CDRSplineData &data)
Definition: CDRTypes.h:215
libcdr::CDRImage::CDRImage
CDRImage(const WPXBinaryData &image, double x1, double x2, double y1, double y2)
Definition: CDRTypes.h:174
libcdr::CDRImage::m_x2
double m_x2
Definition: CDRTypes.h:170
libcdr::CDRTransform::m_v0
double m_v0
Definition: CDRTypes.h:42
libcdr::CDRTransform::m_y0
double m_y0
Definition: CDRTypes.h:47
libcdr::CDRTransform::applyToArc
void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const
Definition: CDRTypes.cpp:42
libcdr::CDRSplineData::CDRSplineData
CDRSplineData()
Definition: CDRTypes.h:212
libcdr::CDRImageFill
Definition: CDRTypes.h:98
libcdr::CDRPolygon::m_cy
double m_cy
Definition: CDRTypes.h:159
libcdr::CDRColor::CDRColor
CDRColor(const CDRColor &color)
Definition: CDRTypes.h:65
libcdr::CDRFillStyle::CDRFillStyle
CDRFillStyle(const CDRFillStyle &style)
Definition: CDRTypes.h:124
libcdr::CDRImageFill::isRelative
bool isRelative
Definition: CDRTypes.h:103
libcdr::CDRImageFill::CDRImageFill
CDRImageFill()
Definition: CDRTypes.h:109
libcdr::CDRSplineData
Definition: CDRTypes.h:208
libcdr::CDRGradientStop::m_color
CDRColor m_color
Definition: CDRTypes.h:71
libcdr::CDRLineStyle::capsType
unsigned short capsType
Definition: CDRTypes.h:131
libcdr::CDRTransform::m_v3
double m_v3
Definition: CDRTypes.h:45
libcdr::CDRFillStyle
Definition: CDRTypes.h:114
libcdr::CDRImageFill::refPoint
bool refPoint
Definition: CDRTypes.h:108
libcdr::CDRImageFill::height
double height
Definition: CDRTypes.h:102
libcdr::CDRPolygon::CDRPolygon
CDRPolygon(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)
Definition: CDRTypes.h:161
libcdr::CDRLineStyle::endMarkerId
unsigned endMarkerId
Definition: CDRTypes.h:139
libcdr::CDRLineStyle::CDRLineStyle
CDRLineStyle()
Definition: CDRTypes.h:140
libcdr::CDRPolygon
Definition: CDRTypes.h:152
libcdr::CDRLineStyle::joinType
unsigned short joinType
Definition: CDRTypes.h:132
libcdr::CDRImage::m_image
WPXBinaryData m_image
Definition: CDRTypes.h:168
libcdr::CDRImageFill::rcpOffset
double rcpOffset
Definition: CDRTypes.h:106
libcdr::CDRFillStyle::gradient
CDRGradient gradient
Definition: CDRTypes.h:118
libcdr::CDRFillStyle::CDRFillStyle
CDRFillStyle(unsigned short ft, CDRColor c1, CDRColor c2, const CDRGradient &gr, const CDRImageFill &img)
Definition: CDRTypes.h:122
libcdr::CDRLineStyle::dashArray
std::vector< unsigned short > dashArray
Definition: CDRTypes.h:137
libcdr::CDRImageFill::xOffset
double xOffset
Definition: CDRTypes.h:104
libcdr::CDRPolygon::m_cx
double m_cx
Definition: CDRTypes.h:158
libcdr::CDRGradient::m_mode
unsigned char m_mode
Definition: CDRTypes.h:83
libcdr::CDRColor::CDRColor
CDRColor()
Definition: CDRTypes.h:62
libcdr::CDRFillStyle::CDRFillStyle
CDRFillStyle()
Definition: CDRTypes.h:120
libcdr::CDRImage::getWidth
double getWidth() const
Definition: CDRTypes.h:184
libcdr::CDRGradientStop::CDRGradientStop
CDRGradientStop(const CDRColor &color, double offset)
Definition: CDRTypes.h:74
libcdr::CDRColor::m_colorModel
unsigned short m_colorModel
Definition: CDRTypes.h:60
libcdr::CDRImage::getImage
const WPXBinaryData & getImage() const
Definition: CDRTypes.h:192
libcdr::CDRGradient::CDRGradient
CDRGradient(const CDRGradient &gradient)
Definition: CDRTypes.h:92
libcdr::CDRGradient::m_edgeOffset
int m_edgeOffset
Definition: CDRTypes.h:86
libcdr::CDRTransform::CDRTransform
CDRTransform()
Definition: CDRTypes.h:48
libcdr::CDRPolygon::m_ry
double m_ry
Definition: CDRTypes.h:157
libcdr::CDRLineStyle::lineType
unsigned short lineType
Definition: CDRTypes.h:130
libcdr::CDRSplineData::empty
bool empty()
Definition: CDRTypes.h:222
libcdr::CDRGradientStop::CDRGradientStop
CDRGradientStop()
Definition: CDRTypes.h:73
libcdr::CDRTransform::CDRTransform
CDRTransform(double v0, double v1, double x0, double v3, double v4, double y0)
Definition: CDRTypes.h:51
libcdr::CDRSplineData::clear
void clear()
Definition: CDRTypes.h:217
libcdr::CDRGradient::m_stops
std::vector< CDRGradientStop > m_stops
Definition: CDRTypes.h:89
libcdr::CDRGradient::m_type
unsigned char m_type
Definition: CDRTypes.h:82
libcdr::CDRImageFill::id
unsigned id
Definition: CDRTypes.h:100
libcdr::CDRTransform::m_v4
double m_v4
Definition: CDRTypes.h:46
libcdr::CDRImage::m_y1
double m_y1
Definition: CDRTypes.h:171
libcdr::CDRPolygon::m_rx
double m_rx
Definition: CDRTypes.h:156
libcdr::CDRGradient::m_midPoint
double m_midPoint
Definition: CDRTypes.h:85
libcdr::CDRFillStyle::fillType
unsigned short fillType
Definition: CDRTypes.h:116
libcdr::CDRGradient::CDRGradient
CDRGradient()
Definition: CDRTypes.h:90
libcdr::CDRFillStyle::imageFill
CDRImageFill imageFill
Definition: CDRTypes.h:119
libcdr::CDRPattern::height
unsigned height
Definition: CDRTypes.h:201
libcdr::CDRLineStyle::stretch
double stretch
Definition: CDRTypes.h:134
libcdr::CDRPattern::pattern
std::vector< unsigned char > pattern
Definition: CDRTypes.h:202
libcdr::CDRLineStyle::startMarkerId
unsigned startMarkerId
Definition: CDRTypes.h:138
libcdr::CDRImage::m_y2
double m_y2
Definition: CDRTypes.h:172
libcdr::CDRColor::m_colorValue
unsigned m_colorValue
Definition: CDRTypes.h:61
libcdr::CDRLineStyle
Definition: CDRTypes.h:128
libcdr::CDRGradient::m_centerXOffset
int m_centerXOffset
Definition: CDRTypes.h:87
libcdr::CDRImage::getHeight
double getHeight() const
Definition: CDRTypes.h:188
libcdr::CDRPolygon::m_numAngles
unsigned m_numAngles
Definition: CDRTypes.h:154
libcdr::CDRPolygon::create
void create(CDRPath &path) const
Definition: CDRTypes.cpp:105
libcdr::CDRImageFill::flags
unsigned char flags
Definition: CDRTypes.h:107
libcdr::CDRColor
Definition: CDRTypes.h:58
libcdr::CDRPolygon::CDRPolygon
CDRPolygon()
Definition: CDRTypes.h:160
libcdr::CDRPattern
Definition: CDRTypes.h:198
libcdr::CDRSplineData::knotVector
std::vector< unsigned > knotVector
Definition: CDRTypes.h:211
libcdr::CDRPattern::CDRPattern
CDRPattern(unsigned w, unsigned h, const std::vector< unsigned char > &p)
Definition: CDRTypes.h:204
libcdr::CDRGradient
Definition: CDRTypes.h:80
libcdr::CDRImage
Definition: CDRTypes.h:166
libcdr::CDRTransform
Definition: CDRTypes.h:40
libcdr::CDRGradientStop::m_offset
double m_offset
Definition: CDRTypes.h:72
libcdr::CDRLineStyle::lineWidth
double lineWidth
Definition: CDRTypes.h:133
libcdr::CDRGradientStop
Definition: CDRTypes.h:69
libcdr::CDRGradient::m_angle
double m_angle
Definition: CDRTypes.h:84
libcdr::CDRSplineData::CDRSplineData
CDRSplineData(const std::vector< std::pair< double, double > > &ps, const std::vector< unsigned > &kntv)
Definition: CDRTypes.h:213
libcdr::CDRColor::CDRColor
CDRColor(unsigned short colorModel, unsigned colorValue)
Definition: CDRTypes.h:63
libcdr::CDRTransform::applyToPoint
void applyToPoint(double &x, double &y) const
Definition: CDRTypes.cpp:35
libcdr::CDRSplineData::points
std::vector< std::pair< double, double > > points
Definition: CDRTypes.h:210