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