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 #include "CDRTransforms.h"
36 
37 namespace libcdr
38 {
39 class CDRPath;
40 
41 struct CDRBBox
42 {
43  double m_x;
44  double m_y;
45  double m_w;
46  double m_h;
48  : m_x(0.0), m_y(0.0), m_w(0.0), m_h(0.0) {}
49  CDRBBox(double x0, double y0, double x1, double y1)
50  : m_x(x0 < x1 ? x0 : x1), m_y(y0 < y1 ? y0 : y1), m_w(fabs(x1-x0)), m_h(fabs(y1-y0)) {}
51  double getWidth() const
52  {
53  return m_w;
54  }
55  double getHeight() const
56  {
57  return m_h;
58  }
59  double getMinX() const
60  {
61  return m_x;
62  }
63  double getMinY() const
64  {
65  return m_y;
66  }
67 
68 };
69 
70 struct CDRColor
71 {
72  unsigned short m_colorModel;
73  unsigned m_colorValue;
75  CDRColor(unsigned short colorModel, unsigned colorValue)
76  : m_colorModel(colorModel), m_colorValue(colorValue) {}
77 };
78 
80 {
82  double m_offset;
84  CDRGradientStop(const CDRColor &color, double offset)
85  : m_color(color), m_offset(offset) {}
86 };
87 
89 {
90  unsigned char m_type;
91  unsigned char m_mode;
92  double m_angle;
93  double m_midPoint;
97  std::vector<CDRGradientStop> m_stops;
99  : 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() {}
100 };
101 
103 {
104  unsigned id;
105  double width;
106  double height;
108  double xOffset;
109  double yOffset;
110  double rcpOffset;
111  unsigned char flags;
112  CDRImageFill() : id(0), width(0.0), height(0.0), isRelative(false), xOffset(0.0), yOffset(0.0), rcpOffset(0.0), flags(0)
113  {}
114  CDRImageFill(unsigned i, double w, double h, bool r, double x, double y, double o, unsigned char f)
115  : id(i), width(w), height(h), isRelative(r), xOffset(x), yOffset(y), rcpOffset(o), flags(f) {}
116 };
117 
119 {
120  unsigned short fillType;
125  : fillType(0), color1(), color2(), gradient(), imageFill() {}
126  CDRFillStyle(unsigned short ft, CDRColor c1, CDRColor c2, const CDRGradient &gr, const CDRImageFill &img)
127  : fillType(ft), color1(c1), color2(c2), gradient(gr), imageFill(img) {}
128 };
129 
131 {
132  unsigned short lineType;
133  unsigned short capsType;
134  unsigned short joinType;
135  double lineWidth;
136  double stretch;
137  double angle;
139  std::vector<unsigned> dashArray;
140  unsigned startMarkerId;
141  unsigned endMarkerId;
143  : lineType(0), capsType(0), joinType(0), lineWidth(0.0),
144  stretch(0.0), angle(0.0), color(), dashArray(),
145  startMarkerId(0), endMarkerId(0) {}
146  CDRLineStyle(unsigned short lt, unsigned short ct, unsigned short jt,
147  double lw, double st, double a, const CDRColor &c, const std::vector<unsigned> &da,
148  unsigned smi, unsigned emi)
149  : lineType(lt), capsType(ct), joinType(jt), lineWidth(lw),
150  stretch(st), angle(a), color(c), dashArray(da),
151  startMarkerId(smi), endMarkerId(emi) {}
152 };
153 
155 {
156  unsigned short m_charSet;
157  unsigned short m_fontId;
158  double m_fontSize;
160  : m_charSet(0), m_fontId(0), m_fontSize(0.0) {}
161  CDRCharacterStyle(unsigned short charSet, unsigned short fontId, double fontSize)
162  : m_charSet(charSet), m_fontId(fontId), m_fontSize(fontSize) {}
164  {
165  if (override.m_charSet)
166  m_charSet = override.m_charSet;
167  if (override.m_fontId)
168  m_fontId = override.m_fontId;
169  if (override.m_fontSize > 0.0)
170  m_fontSize = override.m_fontSize;
171  }
172 };
173 
175 {
176  unsigned m_numAngles;
177  unsigned m_nextPoint;
178  double m_rx;
179  double m_ry;
180  double m_cx;
181  double m_cy;
182  CDRPolygon() : m_numAngles(0), m_nextPoint(0), m_rx(0.0), m_ry(0.0), m_cx(0.0), m_cy(0.0) {}
183  CDRPolygon(unsigned numAngles, unsigned nextPoint, double rx, double ry, double cx, double cy)
184  : m_numAngles(numAngles), m_nextPoint(nextPoint), m_rx(rx), m_ry(ry), m_cx(cx), m_cy(cy) {}
185  void create(CDRPath &path) const;
186 };
187 
188 struct CDRImage
189 {
190  WPXBinaryData m_image;
191  double m_x1;
192  double m_x2;
193  double m_y1;
194  double m_y2;
195  CDRImage() : m_image(), m_x1(0.0), m_x2(0.0), m_y1(0.0), m_y2(0.0) {}
196  CDRImage(const WPXBinaryData &image, double x1, double x2, double y1, double y2)
197  : m_image(image), m_x1(x1), m_x2(x2), m_y1(y1), m_y2(y2) {}
198  double getMiddleX() const
199  {
200  return (m_x1 + m_x2) / 2.0;
201  }
202  double getMiddleY() const
203  {
204  return (m_y1 + m_y2) / 2.0;
205  }
206  const WPXBinaryData &getImage() const
207  {
208  return m_image;
209  }
210 };
211 
213 {
214  unsigned width;
215  unsigned height;
216  std::vector<unsigned char> pattern;
217  CDRPattern() : width(0), height(0), pattern() {}
218  CDRPattern(unsigned w, unsigned h, const std::vector<unsigned char> &p)
219  : width(w), height(h), pattern(p) {}
220 };
221 
222 struct CDRPage
223 {
224  double width;
225  double height;
226  double offsetX;
227  double offsetY;
228  CDRPage() : width(0.0), height(0.0), offsetX(0.0), offsetY(0.0) {}
229  CDRPage(double w, double h, double ox, double oy)
230  : width(w), height(h), offsetX(ox), offsetY(oy) {}
231 };
232 
234 {
235  std::vector<std::pair<double, double> > points;
236  std::vector<unsigned> knotVector;
238  CDRSplineData(const std::vector<std::pair<double, double> > &ps, const std::vector<unsigned> &kntv)
239  : points(ps), knotVector(kntv) {}
240  void clear()
241  {
242  points.clear();
243  knotVector.clear();
244  }
245  bool empty()
246  {
247  return (points.empty() || knotVector.empty());
248  }
249  void create(CDRPath &path) const;
250 };
251 
253 {
254  WaldoRecordInfo(unsigned char t, unsigned i, unsigned o)
255  : type(t), id(i), offset(o) {}
256  WaldoRecordInfo() : type(0), id(0), offset(0) {}
257  unsigned char type;
258  unsigned id;
259  unsigned offset;
260 };
261 
263 {
264  WaldoRecordType1(unsigned id, unsigned short next, unsigned short previous,
265  unsigned short child, unsigned short parent, unsigned short flags,
266  double x0, double y0, double x1, double y1, const CDRTransform &trafo)
267  : m_id(id), m_next(next), m_previous(previous), m_child(child), m_parent(parent),
268  m_flags(flags), m_x0(x0), m_y0(y0), m_x1(x1), m_y1(y1), m_trafo(trafo) {}
270  : m_id(0), m_next(0), m_previous(0), m_child(0), m_parent(0), m_flags(0),
271  m_x0(0.0), m_y0(0.0), m_x1(0.0), m_y1(0.0), m_trafo() {}
272  unsigned m_id;
273  unsigned short m_next;
274  unsigned short m_previous;
275  unsigned short m_child;
276  unsigned short m_parent;
277  unsigned short m_flags;
278  double m_x0;
279  double m_y0;
280  double m_x1;
281  double m_y1;
283 };
284 
286 {
287  CDRCMYKColor(unsigned colorValue, bool percentage = true);
288  CDRCMYKColor(double cyan, double magenta, double yellow, double black)
289  : c(cyan), m(magenta), y(yellow), k(black) {}
291  double c;
292  double m;
293  double y;
294  double k;
295  void applyTint(double tint);
296  unsigned getColorValue() const;
297 };
298 
300 {
301  CDRRGBColor(unsigned colorValue);
302  CDRRGBColor(double red, double green, double blue)
303  : r(red), g(green), b(blue) {}
305  double r;
306  double g;
307  double b;
308  void applyTint(double tint);
309  unsigned getColorValue() const;
310 };
311 
313 {
314  CDRLab2Color(unsigned colorValue);
315  CDRLab2Color(double l, double A, double B)
316  : L(l), a(A), b(B) {}
318  double L;
319  double a;
320  double b;
321  void applyTint(double tint);
322  unsigned getColorValue() const;
323 };
324 
326 {
327  CDRLab4Color(unsigned colorValue);
328  CDRLab4Color(double l, double A, double B)
329  : L(l), a(A), b(B) {}
331  double L;
332  double a;
333  double b;
334  void applyTint(double tint);
335  unsigned getColorValue() const;
336 };
337 
338 struct CDRText
339 {
341  CDRText(const WPXString &text, const CDRCharacterStyle &charStyle)
342  : m_text(text), m_charStyle(charStyle) {}
343  WPXString m_text;
345 };
346 
347 struct CDRFont
348 {
349  CDRFont() : m_name(), m_encoding(0) {}
350  CDRFont(const WPXString &name, unsigned short encoding)
351  : m_name(name), m_encoding(encoding) {}
352  CDRFont(const CDRFont &font)
353  : m_name(font.m_name), m_encoding(font.m_encoding) {}
354  WPXString m_name;
355  unsigned short m_encoding;
356 };
357 
358 } // namespace libcdr
359 
360 #endif /* __CDRTYPES_H__ */
361 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libcdr by doxygen 1.8.3