QXPTypes.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*
3 * This file is part of the libqxp project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef QXPTYPES_H_INCLUDED
11#define QXPTYPES_H_INCLUDED
12
13#include "libqxp_utils.h"
14#include <boost/optional.hpp>
15#include <boost/variant.hpp>
16
17#include <memory>
18#include <vector>
19#include <utility>
20
21namespace libqxp
22{
23
24struct Point
25{
26 double x;
27 double y;
28
30 : x(0.0), y(0.0)
31 { }
32
33 Point(double xVal, double yVal)
34 : x(xVal), y(yVal)
35 { }
36
37 Point move(double dx, double dy) const;
38 Point rotateDeg(double rotationDeg, const Point &center) const;
39
40 double distance(const Point &p2) const;
41};
42
43bool operator==(const Point &lhs, const Point &rhs);
44bool operator!=(const Point &lhs, const Point &rhs);
45
46struct Rect
47{
48 double top;
49 double right;
50 double bottom;
51 double left;
52
53 Rect();
54 Rect(double t, double r, double b, double l);
55
56 double width() const;
57 double height() const;
58
59 Point center() const;
60 Point topLeft() const;
61 Point topRight() const;
62 Point bottomRight() const;
63 Point bottomLeft() const;
64
65 Rect shrink(const double diff) const;
66};
67
68struct Color
69{
70 uint8_t red;
71 uint8_t green;
72 uint8_t blue;
73
75 : red(0), green(0), blue(0)
76 { }
77
78 Color(uint8_t r, uint8_t g, uint8_t b)
79 : red(r), green(g), blue(b)
80 { }
81
82 librevenge::RVNGString toString() const;
83
84 Color applyShade(double shade) const;
85};
86
87enum class GradientType
88{
89 LINEAR,
92 DIAMOND,
95};
96
98{
102 double angle;
103
105 : type(), color1(), color2(), angle(0.0)
106 { }
107};
108
109typedef boost::variant<Color, Gradient> Fill;
110
111enum class LineCapType
112{
113 BUTT,
114 ROUND,
115 RECT,
116 STRETCH
117};
118
119enum class LineJoinType
120{
121 MITER,
122 ROUND,
123 BEVEL
124};
125
127{
128 std::vector<double> segmentLengths;
134
138
139 LineStyle(std::vector<double> segments, bool proportional, double pattern, LineCapType endcap, LineJoinType join)
140 : segmentLengths(std::move(segments)), isStripe(false), isProportional(proportional), patternLength(pattern), endcapType(endcap), joinType(join)
141 { }
142};
143
145{
146 librevenge::RVNGString fontName;
147 double fontSize;
150 bool bold;
151 bool italic;
154 bool shadow;
158 bool strike;
162
164
166 : fontName("Arial"), fontSize(12.0), baselineShift(0.0), color(0, 0, 0),
167 bold(false), italic(false), underline(false), outline(false), shadow(false), superscript(false), subscript(false), superior(false),
168 strike(false), allCaps(false), smallCaps(false), wordUnderline(false),
169 isControlChars(false)
170 { }
171};
172
173struct HJ
174{
176 : hyphenate(true)
177 , minBefore(3)
178 , minAfter(2)
179 , maxInRow(0)
180 , singleWordJustify(true)
181 {
182 }
183
185 unsigned minBefore;
186 unsigned minAfter;
187 unsigned maxInRow;
189};
190
192{
193 LEFT,
194 CENTER,
195 RIGHT,
196 JUSTIFIED,
197 FORCED
198};
199
201{
202 TOP,
203 CENTER,
204 BOTTOM,
206};
207
208enum class TabStopType
209{
210 LEFT,
211 CENTER,
212 RIGHT,
213 ALIGN
214};
215
217{
219 double position;
220 librevenge::RVNGString fillChar;
221 librevenge::RVNGString alignChar;
222
223 bool isDefined() const
224 {
225 return position >= 0;
226 }
227
230 { }
231};
232
234{
235 double width;
240 double offset;
241
243 : width(1.0), color(0, 0, 0), lineStyle(nullptr), leftMargin(0), rightMargin(0), offset(0)
244 { }
245};
246
248{
252 double leading;
254 std::shared_ptr<ParagraphRule> ruleAbove;
255 std::shared_ptr<ParagraphRule> ruleBelow;
256 std::vector<TabStop> tabStops;
257 std::shared_ptr<HJ> hj;
258
261 ruleAbove(nullptr), ruleBelow(nullptr), tabStops(), hj(nullptr)
262 { }
263};
264
265enum class ContentType
266{
267 UNKNOWN,
268 OBJECTS, // group
269 NONE,
270 TEXT,
271 PICTURE
272};
273
275{
276 const unsigned startIndex;
277 const unsigned length;
278
279 unsigned endIndex() const
280 {
281 return startIndex + length - 1;
282 }
283
284 unsigned afterEndIndex() const
285 {
286 return startIndex + length;
287 }
288
289 bool overlaps(const TextSpec &other) const;
290
291protected:
292 TextSpec(unsigned start, unsigned len)
293 : startIndex(start), length(len)
294 { }
295};
296
298{
299 std::shared_ptr<CharFormat> format;
300
301 CharFormatSpec(const std::shared_ptr<CharFormat> &f, unsigned start, unsigned len)
302 : TextSpec(start, len), format(f)
303 { }
304};
305
306struct ParagraphSpec : public TextSpec
307{
308 std::shared_ptr<ParagraphFormat> format;
309
310 ParagraphSpec(const std::shared_ptr<ParagraphFormat> &f, unsigned start, unsigned len)
311 : TextSpec(start, len), format(f)
312 { }
313};
314
315struct Text
316{
317 std::string text;
318 const char *encoding;
319 std::vector<ParagraphSpec> paragraphs;
320 std::vector<CharFormatSpec> charFormats;
321
322 double maxFontSize() const;
323 double maxFontSize(const ParagraphSpec &paragraph) const;
324
326 : text(), encoding("cp1252"), paragraphs(), charFormats()
327 { }
328
329 Text(const Text &other) = default;
330 Text &operator=(const Text &other) = default;
331};
332
333struct Arrow
334{
335 const std::string path;
336 const std::string viewbox;
337 const double scale;
338
339 explicit Arrow(const std::string &d, const std::string &vbox = "0 0 10 10", double s = 3)
340 : path(d), viewbox(vbox), scale(s)
341 { }
342};
343
344struct Frame
345{
346 double width;
347 boost::optional<Color> color;
348 boost::optional<Color> gapColor;
352
354 : width(1.0), color(), gapColor(), lineStyle(nullptr), startArrow(nullptr), endArrow(nullptr)
355 { }
356
357 Frame(const Frame &other) = default;
358 Frame &operator=(const Frame &other) = default;
359};
360
362{
363 unsigned linkId;
365 unsigned linkedIndex;
367 boost::optional<unsigned> textLength;
368
372};
373
375{
377 boost::optional<std::shared_ptr<Text>> text;
378
380 : linkSettings(), text()
381 { }
382
383 bool isLinked() const;
384};
385
399
401{
402 ASCENT,
403 CENTER,
404 BASELINE,
405 DESCENT
406};
407
409{
410 TOP,
411 CENTER,
412 BOTTOM
413};
414
426
428{
430 std::vector<Point> points;
431
433 : boundingBox(), points()
434 { }
435};
436
437struct Object
438{
440 bool runaround; // we probably don't need other runaround properties because ODF doesn't support them
441 unsigned zIndex;
442
443protected:
445 : boundingBox(), runaround(false), zIndex(0)
446 { }
447};
448
449struct Line : Object
450{
451 double rotation;
453 std::vector<CurveComponent> curveComponents;
454
457 { }
458};
459
461{
463
465 : settings()
466 { }
467};
468
469enum class CornerType
470{
471 DEFAULT,
472 ROUNDED,
473 BEVELED,
474 CONCAVE
475};
476
477enum class BoxType
478{
479 UNKNOWN,
480 RECTANGLE,
481 OVAL,
482 POLYGON,
483 BEZIER
484};
485
486struct Box : Object
487{
488 boost::optional<Fill> fill;
493 double rotation;
494 std::vector<Point> customPoints;
495 std::vector<CurveComponent> curveComponents;
496
501};
502
504{
506
508 : settings()
509 { }
510};
511
513{
517 double offsetTop;
518 double scaleHor;
519 double scaleVert;
520
522 : pictureRotation(0.0), pictureSkew(0.0),
523 offsetLeft(0.0), offsetTop(0.0), scaleHor(0.0), scaleVert(0.0)
524 { }
525};
526
527struct Group : Object
528{
529 std::vector<unsigned> objectsIndexes;
530
533 { }
534};
535
537{
539
541 : offset()
542 { }
543};
544
545struct Page
546{
547 std::vector<PageSettings> pageSettings;
548 unsigned objectsCount;
549
552 { }
553
554 bool isFacing() const
555 {
556 return pageSettings.size() == 2;
557 }
558};
559
561{
563 : superscriptOffset(1.0 / 3)
564 , superscriptHScale(1.0)
565 , superscriptVScale(1.0)
566 , subscriptOffset(-1.0 / 3)
567 , subscriptHScale(1.0)
568 , subscriptVScale(1.0)
569 , superiorHScale(0.5)
570 , superiorVScale(0.5)
571 , m_autoLeading(0.2)
572 {
573 }
574
583
584 void setAutoLeading(const double val);
585 double autoLeading() const;
586
587 // there should be a flag to detect this...
589 {
590 return autoLeading() < 0 || autoLeading() > 1;
591 }
592
593private:
595};
596
597}
598
599#endif // QXPTYPES_H_INCLUDED
600
601/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition libqxp_utils.cpp:25
VerticalAlignment
Definition QXPTypes.h:201
LineJoinType
Definition QXPTypes.h:120
TextPathLineAlignment
Definition QXPTypes.h:409
bool operator!=(const Point &lhs, const Point &rhs)
Definition QXPTypes.cpp:23
TextPathAlignment
Definition QXPTypes.h:401
CornerType
Definition QXPTypes.h:470
boost::variant< Color, Gradient > Fill
Definition QXPTypes.h:109
BoxType
Definition QXPTypes.h:478
@ UNKNOWN
Definition QXPHeader.h:24
bool operator==(const Point &lhs, const Point &rhs)
Definition QXPTypes.cpp:18
LineCapType
Definition QXPTypes.h:112
ContentType
Definition QXPTypes.h:266
HorizontalAlignment
Definition QXPTypes.h:192
GradientType
Definition QXPTypes.h:88
TabStopType
Definition QXPTypes.h:209
Definition QXPTypes.h:334
const std::string path
Definition QXPTypes.h:335
const std::string viewbox
Definition QXPTypes.h:336
const double scale
Definition QXPTypes.h:337
Arrow(const std::string &d, const std::string &vbox="0 0 10 10", double s=3)
Definition QXPTypes.h:339
Definition QXPTypes.h:487
std::vector< CurveComponent > curveComponents
Definition QXPTypes.h:495
double rotation
Definition QXPTypes.h:493
boost::optional< Fill > fill
Definition QXPTypes.h:488
Frame frame
Definition QXPTypes.h:489
std::vector< Point > customPoints
Definition QXPTypes.h:494
CornerType cornerType
Definition QXPTypes.h:491
Box()
Definition QXPTypes.h:497
BoxType boxType
Definition QXPTypes.h:490
double cornerRadius
Definition QXPTypes.h:492
Definition QXPTypes.h:298
CharFormatSpec(const std::shared_ptr< CharFormat > &f, unsigned start, unsigned len)
Definition QXPTypes.h:301
std::shared_ptr< CharFormat > format
Definition QXPTypes.h:299
Definition QXPTypes.h:145
bool strike
Definition QXPTypes.h:158
bool allCaps
Definition QXPTypes.h:159
Color color
Definition QXPTypes.h:149
bool shadow
Definition QXPTypes.h:154
bool italic
Definition QXPTypes.h:151
bool underline
Definition QXPTypes.h:152
bool bold
Definition QXPTypes.h:150
librevenge::RVNGString fontName
Definition QXPTypes.h:146
bool wordUnderline
Definition QXPTypes.h:161
double baselineShift
Definition QXPTypes.h:148
CharFormat()
Definition QXPTypes.h:165
double fontSize
Definition QXPTypes.h:147
bool outline
Definition QXPTypes.h:153
bool smallCaps
Definition QXPTypes.h:160
bool subscript
Definition QXPTypes.h:156
bool isControlChars
Definition QXPTypes.h:163
bool superior
Definition QXPTypes.h:157
bool superscript
Definition QXPTypes.h:155
Definition QXPTypes.h:69
librevenge::RVNGString toString() const
Definition QXPTypes.cpp:98
uint8_t red
Definition QXPTypes.h:70
Color(uint8_t r, uint8_t g, uint8_t b)
Definition QXPTypes.h:78
uint8_t blue
Definition QXPTypes.h:72
uint8_t green
Definition QXPTypes.h:71
Color()
Definition QXPTypes.h:74
Color applyShade(double shade) const
Definition QXPTypes.cpp:105
Definition QXPTypes.h:428
CurveComponent()
Definition QXPTypes.h:432
std::vector< Point > points
Definition QXPTypes.h:430
Rect boundingBox
Definition QXPTypes.h:429
Definition QXPTypes.h:345
double width
Definition QXPTypes.h:346
const LineStyle * lineStyle
Definition QXPTypes.h:349
const Arrow * startArrow
Definition QXPTypes.h:350
boost::optional< Color > color
Definition QXPTypes.h:347
Frame & operator=(const Frame &other)=default
Frame()
Definition QXPTypes.h:353
const Arrow * endArrow
Definition QXPTypes.h:351
boost::optional< Color > gapColor
Definition QXPTypes.h:348
Frame(const Frame &other)=default
Definition QXPTypes.h:98
Color color1
Definition QXPTypes.h:100
Color color2
Definition QXPTypes.h:101
Gradient()
Definition QXPTypes.h:104
GradientType type
Definition QXPTypes.h:99
double angle
Definition QXPTypes.h:102
Definition QXPTypes.h:528
std::vector< unsigned > objectsIndexes
Definition QXPTypes.h:529
Group()
Definition QXPTypes.h:531
Definition QXPTypes.h:174
HJ()
Definition QXPTypes.h:175
unsigned minBefore
Definition QXPTypes.h:185
unsigned minAfter
Definition QXPTypes.h:186
bool singleWordJustify
Definition QXPTypes.h:188
unsigned maxInRow
Definition QXPTypes.h:187
bool hyphenate
Definition QXPTypes.h:184
Definition QXPTypes.h:127
LineJoinType joinType
Definition QXPTypes.h:133
LineCapType endcapType
Definition QXPTypes.h:132
LineStyle()
Definition QXPTypes.h:135
double patternLength
Definition QXPTypes.h:131
LineStyle(std::vector< double > segments, bool proportional, double pattern, LineCapType endcap, LineJoinType join)
Definition QXPTypes.h:139
bool isStripe
Definition QXPTypes.h:129
bool isProportional
Definition QXPTypes.h:130
std::vector< double > segmentLengths
Definition QXPTypes.h:128
Definition QXPTypes.h:450
Frame style
Definition QXPTypes.h:452
double rotation
Definition QXPTypes.h:451
std::vector< CurveComponent > curveComponents
Definition QXPTypes.h:453
Line()
Definition QXPTypes.h:455
Definition QXPTypes.h:362
boost::optional< unsigned > textLength
Definition QXPTypes.h:367
unsigned nextLinkedIndex
Definition QXPTypes.h:366
unsigned offsetIntoText
Definition QXPTypes.h:364
LinkedTextSettings()
Definition QXPTypes.h:369
unsigned linkId
Definition QXPTypes.h:363
unsigned linkedIndex
Definition QXPTypes.h:365
Definition QXPTypes.h:438
Rect boundingBox
Definition QXPTypes.h:439
bool runaround
Definition QXPTypes.h:440
unsigned zIndex
Definition QXPTypes.h:441
Object()
Definition QXPTypes.h:444
Definition QXPTypes.h:537
PageSettings()
Definition QXPTypes.h:540
Rect offset
Definition QXPTypes.h:538
Definition QXPTypes.h:546
std::vector< PageSettings > pageSettings
Definition QXPTypes.h:547
bool isFacing() const
Definition QXPTypes.h:554
unsigned objectsCount
Definition QXPTypes.h:548
Page()
Definition QXPTypes.h:550
Definition QXPTypes.h:248
std::shared_ptr< ParagraphRule > ruleBelow
Definition QXPTypes.h:255
ParagraphFormat()
Definition QXPTypes.h:259
Rect margin
Definition QXPTypes.h:250
double firstLineIndent
Definition QXPTypes.h:251
HorizontalAlignment alignment
Definition QXPTypes.h:249
bool incrementalLeading
Definition QXPTypes.h:253
double leading
Definition QXPTypes.h:252
std::shared_ptr< HJ > hj
Definition QXPTypes.h:257
std::vector< TabStop > tabStops
Definition QXPTypes.h:256
std::shared_ptr< ParagraphRule > ruleAbove
Definition QXPTypes.h:254
Definition QXPTypes.h:234
Color color
Definition QXPTypes.h:236
double offset
Definition QXPTypes.h:240
ParagraphRule()
Definition QXPTypes.h:242
double leftMargin
Definition QXPTypes.h:238
double rightMargin
Definition QXPTypes.h:239
double width
Definition QXPTypes.h:235
const LineStyle * lineStyle
Definition QXPTypes.h:237
Definition QXPTypes.h:307
ParagraphSpec(const std::shared_ptr< ParagraphFormat > &f, unsigned start, unsigned len)
Definition QXPTypes.h:310
std::shared_ptr< ParagraphFormat > format
Definition QXPTypes.h:308
Definition QXPTypes.h:513
double scaleVert
Definition QXPTypes.h:519
double offsetTop
Definition QXPTypes.h:517
PictureBox()
Definition QXPTypes.h:521
double offsetLeft
Definition QXPTypes.h:516
double pictureSkew
Definition QXPTypes.h:515
double scaleHor
Definition QXPTypes.h:518
double pictureRotation
Definition QXPTypes.h:514
Definition QXPTypes.h:25
double y
Definition QXPTypes.h:27
Point move(double dx, double dy) const
Definition QXPTypes.cpp:28
double x
Definition QXPTypes.h:26
Point rotateDeg(double rotationDeg, const Point &center) const
Definition QXPTypes.cpp:33
Point()
Definition QXPTypes.h:29
Point(double xVal, double yVal)
Definition QXPTypes.h:33
double distance(const Point &p2) const
Definition QXPTypes.cpp:45
Definition QXPTypes.h:561
double superscriptOffset
Definition QXPTypes.h:575
bool isIncrementalAutoLeading() const
Definition QXPTypes.h:588
double autoLeading() const
Definition QXPTypes.cpp:171
QXPDocumentProperties()
Definition QXPTypes.h:562
double m_autoLeading
Definition QXPTypes.h:594
double superiorVScale
Definition QXPTypes.h:582
double superscriptHScale
Definition QXPTypes.h:576
double superiorHScale
Definition QXPTypes.h:581
double subscriptHScale
Definition QXPTypes.h:579
double subscriptVScale
Definition QXPTypes.h:580
void setAutoLeading(const double val)
Definition QXPTypes.cpp:159
double subscriptOffset
Definition QXPTypes.h:578
double superscriptVScale
Definition QXPTypes.h:577
Definition QXPTypes.h:47
Point topLeft() const
Definition QXPTypes.cpp:73
Point bottomRight() const
Definition QXPTypes.cpp:83
Point center() const
Definition QXPTypes.cpp:68
Point topRight() const
Definition QXPTypes.cpp:78
double right
Definition QXPTypes.h:49
Rect shrink(const double diff) const
Definition QXPTypes.cpp:93
double height() const
Definition QXPTypes.cpp:63
Point bottomLeft() const
Definition QXPTypes.cpp:88
double bottom
Definition QXPTypes.h:50
double left
Definition QXPTypes.h:51
double top
Definition QXPTypes.h:48
Rect()
Definition QXPTypes.cpp:50
double width() const
Definition QXPTypes.cpp:58
Definition QXPTypes.h:217
bool isDefined() const
Definition QXPTypes.h:223
TabStopType type
Definition QXPTypes.h:218
TabStop()
Definition QXPTypes.h:228
librevenge::RVNGString alignChar
Definition QXPTypes.h:221
double position
Definition QXPTypes.h:219
librevenge::RVNGString fillChar
Definition QXPTypes.h:220
Definition QXPTypes.h:504
TextSettings settings
Definition QXPTypes.h:505
TextBox()
Definition QXPTypes.h:507
Definition QXPTypes.h:375
boost::optional< std::shared_ptr< Text > > text
Definition QXPTypes.h:377
TextObject()
Definition QXPTypes.h:379
LinkedTextSettings linkSettings
Definition QXPTypes.h:376
bool isLinked() const
Definition QXPTypes.cpp:154
Definition QXPTypes.h:416
TextPathSettings()
Definition QXPTypes.h:422
TextPathAlignment alignment
Definition QXPTypes.h:419
bool rotate
Definition QXPTypes.h:417
bool skew
Definition QXPTypes.h:418
TextPathLineAlignment lineAlignment
Definition QXPTypes.h:420
Definition QXPTypes.h:461
TextPath()
Definition QXPTypes.h:464
TextPathSettings settings
Definition QXPTypes.h:462
Definition QXPTypes.h:387
Rect inset
Definition QXPTypes.h:391
unsigned columnsCount
Definition QXPTypes.h:388
double rotation
Definition QXPTypes.h:392
VerticalAlignment verticalAlignment
Definition QXPTypes.h:390
double skew
Definition QXPTypes.h:393
double gutterWidth
Definition QXPTypes.h:389
TextSettings()
Definition QXPTypes.h:395
Definition QXPTypes.h:275
bool overlaps(const TextSpec &other) const
Definition QXPTypes.cpp:118
unsigned endIndex() const
Definition QXPTypes.h:279
const unsigned startIndex
Definition QXPTypes.h:276
const unsigned length
Definition QXPTypes.h:277
TextSpec(unsigned start, unsigned len)
Definition QXPTypes.h:292
unsigned afterEndIndex() const
Definition QXPTypes.h:284
Definition QXPTypes.h:316
const char * encoding
Definition QXPTypes.h:318
std::vector< ParagraphSpec > paragraphs
Definition QXPTypes.h:319
Text(const Text &other)=default
double maxFontSize() const
Definition QXPTypes.cpp:123
std::string text
Definition QXPTypes.h:317
Text()
Definition QXPTypes.h:325
std::vector< CharFormatSpec > charFormats
Definition QXPTypes.h:320
Text & operator=(const Text &other)=default

Generated for libqxp by doxygen 1.12.0