VSDTypes.h Source File documentation

VSDTypes.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 libvisio 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 VSDTYPES_H
11#define VSDTYPES_H
12
13#include <vector>
14#include <map>
15#include <librevenge/librevenge.h>
16
17#define ASSIGN_OPTIONAL(t, u) if(!!t) u = t.get()
18#define MINUS_ONE (unsigned)-1
19
20namespace libvisio
21{
22 struct XForm
23{
24 double pinX;
25 double pinY;
26 double height;
27 double width;
28 double pinLocX;
29 double pinLocY;
30 double angle;
31 bool flipX;
32 bool flipY;
33 double x;
34 double y;
35 XForm() : pinX(0.0), pinY(0.0), height(0.0), width(0.0),
36 pinLocX(0.0), pinLocY(0.0), angle(0.0),
37 flipX(false), flipY(false), x(0.0), y(0.0) {}
38 XForm(const XForm &xform) = default;
39 XForm &operator=(const XForm &xform) = default;
40};
41
42 struct XForm1D
43{
44 double beginX;
45 double beginY;
46 unsigned beginId;
47 double endX;
48 double endY;
49 unsigned endId;
50 XForm1D() : beginX(0.0), beginY(0.0), beginId(MINUS_ONE),
51 endX(0.0), endY(0.0), endId(MINUS_ONE) {}
52 XForm1D(const XForm1D &xform1d) : beginX(xform1d.beginX),
53 beginY(xform1d.beginY), beginId(xform1d.beginId),
54 endX(xform1d.endX), endY(xform1d.endY), endId(xform1d.endId) {}
55};
56
57// Utilities
58 struct ChunkHeader
59{
60 ChunkHeader() : chunkType(0), id(0), list(0), dataLength(0), level(0), unknown(0), trailer(0) {}
61 unsigned chunkType; // 4 bytes
62 unsigned id; // 4 bytes
63 unsigned list; // 4 bytes
64 unsigned dataLength; // 4 bytes
65 unsigned short level; // 2 bytes
66 unsigned char unknown; // 1 byte
67 unsigned trailer; // Derived
68};
69
70 struct Colour
71{
72 Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
73 : r(red), g(green), b(blue), a(alpha) {}
74 Colour() : r(0), g(0), b(0), a(0) {}
75 inline bool operator==(const Colour &col) const
76 {
77 return ((r == col.r) && (g == col.g) && (b == col.b) && (a == col.a));
78 }
79 inline bool operator!=(const Colour &col) const
80 {
81 return !operator==(col);
82 }
83 inline bool operator!() const
84 {
85 return (!r && !g && !b && !a);
86 }
87 unsigned char r;
88 unsigned char g;
89 unsigned char b;
90 unsigned char a;
91};
92
93 struct NURBSData
94{
95 double lastKnot;
96 unsigned degree;
97 unsigned char xType;
98 unsigned char yType;
99 std::vector<double> knots;
100 std::vector<double> weights;
101 std::vector<std::pair<double, double> > points;
102 NURBSData()
103 : lastKnot(0.0),
104 degree(0),
105 xType(0x00),
106 yType(0x00),
107 knots(),
108 weights(),
109 points() {}
110 NURBSData(const NURBSData &data) = default;
111 NURBSData &operator=(const NURBSData &data) = default;
112};
113
114 struct PolylineData
115{
116 unsigned char xType;
117 unsigned char yType;
118 std::vector<std::pair<double, double> > points;
119 PolylineData()
120 : xType(0x00),
121 yType(0x00),
122 points() {}
123};
124
125
126 struct ForeignData
127{
128 unsigned typeId;
129 unsigned dataId;
130 unsigned type;
131 unsigned format;
132 double offsetX;
133 double offsetY;
134 double width;
135 double height;
136 librevenge::RVNGBinaryData data;
137 ForeignData()
138 : typeId(0),
139 dataId(0),
140 type(0),
141 format(0),
142 offsetX(0.0),
143 offsetY(0.0),
144 width(0.0),
145 height(0.0),
146 data() {}
147};
148
149 enum TextFormat
150{
151 VSD_TEXT_ANSI = 0,
152 VSD_TEXT_SYMBOL,
153 VSD_TEXT_GREEK,
154 VSD_TEXT_TURKISH,
155 VSD_TEXT_VIETNAMESE,
156 VSD_TEXT_HEBREW,
157 VSD_TEXT_ARABIC,
158 VSD_TEXT_BALTIC,
159 VSD_TEXT_RUSSIAN,
160 VSD_TEXT_THAI,
161 VSD_TEXT_CENTRAL_EUROPE,
162 VSD_TEXT_JAPANESE,
163 VSD_TEXT_KOREAN,
164 VSD_TEXT_CHINESE_SIMPLIFIED,
165 VSD_TEXT_CHINESE_TRADITIONAL,
166 VSD_TEXT_UTF8,
167 VSD_TEXT_UTF16
168};
169
170 class VSDName
171{
172public:
173 VSDName(const librevenge::RVNGBinaryData &data, TextFormat format)
174 : m_data(data),
175 m_format(format) {}
176 VSDName() : m_data(), m_format(VSD_TEXT_ANSI) {}
177 VSDName(const VSDName &name) = default;
178 VSDName &operator=(const VSDName &name) = default;
179 bool empty() const
180 {
181 return !m_data.size();
182 }
183 void clear()
184 {
185 m_data.clear();
186 m_format = VSD_TEXT_ANSI;
187 }
188 librevenge::RVNGBinaryData m_data;
189 TextFormat m_format;
190};
191
192 struct VSDFont
193{
194 librevenge::RVNGString m_name;
195 TextFormat m_encoding;
196 VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
197 VSDFont(const librevenge::RVNGString &name, const TextFormat &encoding) :
198 m_name(name), m_encoding(encoding) {}
199 VSDFont(const VSDFont &font) :
200 m_name(font.m_name), m_encoding(font.m_encoding) {}
201};
202
203 struct VSDMisc
204{
205 bool m_hideText;
206 VSDMisc() : m_hideText(false) {}
207 VSDMisc(const VSDMisc &misc) = default;
208 VSDMisc &operator=(const VSDMisc &misc) = default;
209};
210
211 struct VSDTabStop
212{
213 double m_position;
214 unsigned char m_alignment;
215 unsigned char m_leader;
216 VSDTabStop() : m_position(0.0), m_alignment(0), m_leader(0) {}
217 VSDTabStop(const VSDTabStop &tabStop) :
218 m_position(tabStop.m_position), m_alignment(tabStop.m_alignment),
219 m_leader(tabStop.m_leader) {}
220};
221
222 struct VSDTabSet
223{
224 unsigned m_numChars;
225 std::map<unsigned, VSDTabStop> m_tabStops;
226 VSDTabSet() : m_numChars(0), m_tabStops() {}
227 VSDTabSet(const VSDTabSet &tabSet) :
228 m_numChars(tabSet.m_numChars), m_tabStops(tabSet.m_tabStops) {}
229};
230
231 struct VSDBullet
232{
233 librevenge::RVNGString m_bulletStr;
234 librevenge::RVNGString m_bulletFont;
235 double m_bulletFontSize;
236 double m_textPosAfterBullet;
237 VSDBullet()
238 : m_bulletStr(),
239 m_bulletFont(),
240 m_bulletFontSize(0.0),
241 m_textPosAfterBullet(0.0) {}
242 VSDBullet(const VSDBullet &bullet) = default;
243 VSDBullet &operator=(const VSDBullet &bullet) = default;
244 inline bool operator==(const VSDBullet &bullet) const
245 {
246 return ((m_bulletStr == bullet.m_bulletStr) &&
247 (m_bulletFont == bullet.m_bulletFont) &&
248 (m_bulletFontSize == bullet.m_bulletFontSize) &&
249 (m_textPosAfterBullet == bullet.m_textPosAfterBullet));
250 }
251 inline bool operator!=(const VSDBullet &bullet) const
252 {
253 return !operator==(bullet);
254 }
255 inline bool operator!() const
256 {
257 return m_bulletStr.empty();
258 }
259};
260
261} // namespace libvisio
262
263#endif /* VSDTYPES_H */
264/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
MINUS_ONE
#define MINUS_ONE
Definition VSDTypes.h:18
libvisio::VSDName
Definition VSDTypes.h:171
libvisio::VSDName::VSDName
VSDName(const VSDName &name)=default
libvisio::VSDName::m_format
TextFormat m_format
Definition VSDTypes.h:189
libvisio::VSDName::VSDName
VSDName(const librevenge::RVNGBinaryData &data, TextFormat format)
Definition VSDTypes.h:173
libvisio::VSDName::operator=
VSDName & operator=(const VSDName &name)=default
libvisio::VSDName::m_data
librevenge::RVNGBinaryData m_data
Definition VSDTypes.h:188
libvisio::VSDName::empty
bool empty() const
Definition VSDTypes.h:179
libvisio::VSDName::VSDName
VSDName()
Definition VSDTypes.h:176
libvisio::VSDName::clear
void clear()
Definition VSDTypes.h:183
libvisio
Definition libvisio_utils.h:49
libvisio::TextFormat
TextFormat
Definition VSDTypes.h:150
libvisio::VSD_TEXT_ARABIC
@ VSD_TEXT_ARABIC
Definition VSDTypes.h:157
libvisio::VSD_TEXT_HEBREW
@ VSD_TEXT_HEBREW
Definition VSDTypes.h:156
libvisio::VSD_TEXT_CHINESE_SIMPLIFIED
@ VSD_TEXT_CHINESE_SIMPLIFIED
Definition VSDTypes.h:164
libvisio::VSD_TEXT_CENTRAL_EUROPE
@ VSD_TEXT_CENTRAL_EUROPE
Definition VSDTypes.h:161
libvisio::VSD_TEXT_THAI
@ VSD_TEXT_THAI
Definition VSDTypes.h:160
libvisio::VSD_TEXT_TURKISH
@ VSD_TEXT_TURKISH
Definition VSDTypes.h:154
libvisio::VSD_TEXT_SYMBOL
@ VSD_TEXT_SYMBOL
Definition VSDTypes.h:152
libvisio::VSD_TEXT_RUSSIAN
@ VSD_TEXT_RUSSIAN
Definition VSDTypes.h:159
libvisio::VSD_TEXT_BALTIC
@ VSD_TEXT_BALTIC
Definition VSDTypes.h:158
libvisio::VSD_TEXT_KOREAN
@ VSD_TEXT_KOREAN
Definition VSDTypes.h:163
libvisio::VSD_TEXT_JAPANESE
@ VSD_TEXT_JAPANESE
Definition VSDTypes.h:162
libvisio::VSD_TEXT_CHINESE_TRADITIONAL
@ VSD_TEXT_CHINESE_TRADITIONAL
Definition VSDTypes.h:165
libvisio::VSD_TEXT_UTF8
@ VSD_TEXT_UTF8
Definition VSDTypes.h:166
libvisio::VSD_TEXT_ANSI
@ VSD_TEXT_ANSI
Definition VSDTypes.h:151
libvisio::VSD_TEXT_VIETNAMESE
@ VSD_TEXT_VIETNAMESE
Definition VSDTypes.h:155
libvisio::VSD_TEXT_GREEK
@ VSD_TEXT_GREEK
Definition VSDTypes.h:153
libvisio::VSD_TEXT_UTF16
@ VSD_TEXT_UTF16
Definition VSDTypes.h:167
libvisio::ChunkHeader
Definition VSDTypes.h:59
libvisio::ChunkHeader::chunkType
unsigned chunkType
Definition VSDTypes.h:61
libvisio::ChunkHeader::level
unsigned short level
Definition VSDTypes.h:65
libvisio::ChunkHeader::unknown
unsigned char unknown
Definition VSDTypes.h:66
libvisio::ChunkHeader::id
unsigned id
Definition VSDTypes.h:62
libvisio::ChunkHeader::trailer
unsigned trailer
Definition VSDTypes.h:67
libvisio::ChunkHeader::ChunkHeader
ChunkHeader()
Definition VSDTypes.h:60
libvisio::ChunkHeader::dataLength
unsigned dataLength
Definition VSDTypes.h:64
libvisio::ChunkHeader::list
unsigned list
Definition VSDTypes.h:63
libvisio::Colour
Definition VSDTypes.h:71
libvisio::Colour::r
unsigned char r
Definition VSDTypes.h:87
libvisio::Colour::a
unsigned char a
Definition VSDTypes.h:90
libvisio::Colour::operator==
bool operator==(const Colour &col) const
Definition VSDTypes.h:75
libvisio::Colour::Colour
Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
Definition VSDTypes.h:72
libvisio::Colour::operator!=
bool operator!=(const Colour &col) const
Definition VSDTypes.h:79
libvisio::Colour::b
unsigned char b
Definition VSDTypes.h:89
libvisio::Colour::g
unsigned char g
Definition VSDTypes.h:88
libvisio::Colour::operator!
bool operator!() const
Definition VSDTypes.h:83
libvisio::Colour::Colour
Colour()
Definition VSDTypes.h:74
libvisio::ForeignData
Definition VSDTypes.h:127
libvisio::ForeignData::ForeignData
ForeignData()
Definition VSDTypes.h:137
libvisio::ForeignData::height
double height
Definition VSDTypes.h:135
libvisio::ForeignData::dataId
unsigned dataId
Definition VSDTypes.h:129
libvisio::ForeignData::data
librevenge::RVNGBinaryData data
Definition VSDTypes.h:136
libvisio::ForeignData::width
double width
Definition VSDTypes.h:134
libvisio::ForeignData::typeId
unsigned typeId
Definition VSDTypes.h:128
libvisio::ForeignData::format
unsigned format
Definition VSDTypes.h:131
libvisio::ForeignData::type
unsigned type
Definition VSDTypes.h:130
libvisio::ForeignData::offsetX
double offsetX
Definition VSDTypes.h:132
libvisio::ForeignData::offsetY
double offsetY
Definition VSDTypes.h:133
libvisio::NURBSData
Definition VSDTypes.h:94
libvisio::NURBSData::points
std::vector< std::pair< double, double > > points
Definition VSDTypes.h:101
libvisio::NURBSData::knots
std::vector< double > knots
Definition VSDTypes.h:99
libvisio::NURBSData::weights
std::vector< double > weights
Definition VSDTypes.h:100
libvisio::NURBSData::NURBSData
NURBSData()
Definition VSDTypes.h:102
libvisio::NURBSData::NURBSData
NURBSData(const NURBSData &data)=default
libvisio::NURBSData::lastKnot
double lastKnot
Definition VSDTypes.h:95
libvisio::NURBSData::degree
unsigned degree
Definition VSDTypes.h:96
libvisio::NURBSData::yType
unsigned char yType
Definition VSDTypes.h:98
libvisio::NURBSData::operator=
NURBSData & operator=(const NURBSData &data)=default
libvisio::NURBSData::xType
unsigned char xType
Definition VSDTypes.h:97
libvisio::PolylineData
Definition VSDTypes.h:115
libvisio::PolylineData::points
std::vector< std::pair< double, double > > points
Definition VSDTypes.h:118
libvisio::PolylineData::yType
unsigned char yType
Definition VSDTypes.h:117
libvisio::PolylineData::xType
unsigned char xType
Definition VSDTypes.h:116
libvisio::PolylineData::PolylineData
PolylineData()
Definition VSDTypes.h:119
libvisio::VSDBullet
Definition VSDTypes.h:232
libvisio::VSDBullet::VSDBullet
VSDBullet()
Definition VSDTypes.h:237
libvisio::VSDBullet::operator==
bool operator==(const VSDBullet &bullet) const
Definition VSDTypes.h:244
libvisio::VSDBullet::operator!
bool operator!() const
Definition VSDTypes.h:255
libvisio::VSDBullet::m_bulletFontSize
double m_bulletFontSize
Definition VSDTypes.h:235
libvisio::VSDBullet::VSDBullet
VSDBullet(const VSDBullet &bullet)=default
libvisio::VSDBullet::operator!=
bool operator!=(const VSDBullet &bullet) const
Definition VSDTypes.h:251
libvisio::VSDBullet::m_bulletFont
librevenge::RVNGString m_bulletFont
Definition VSDTypes.h:234
libvisio::VSDBullet::operator=
VSDBullet & operator=(const VSDBullet &bullet)=default
libvisio::VSDBullet::m_textPosAfterBullet
double m_textPosAfterBullet
Definition VSDTypes.h:236
libvisio::VSDBullet::m_bulletStr
librevenge::RVNGString m_bulletStr
Definition VSDTypes.h:233
libvisio::VSDFont
Definition VSDTypes.h:193
libvisio::VSDFont::VSDFont
VSDFont()
Definition VSDTypes.h:196
libvisio::VSDFont::VSDFont
VSDFont(const VSDFont &font)
Definition VSDTypes.h:199
libvisio::VSDFont::m_encoding
TextFormat m_encoding
Definition VSDTypes.h:195
libvisio::VSDFont::m_name
librevenge::RVNGString m_name
Definition VSDTypes.h:194
libvisio::VSDFont::VSDFont
VSDFont(const librevenge::RVNGString &name, const TextFormat &encoding)
Definition VSDTypes.h:197
libvisio::VSDMisc
Definition VSDTypes.h:204
libvisio::VSDMisc::VSDMisc
VSDMisc()
Definition VSDTypes.h:206
libvisio::VSDMisc::m_hideText
bool m_hideText
Definition VSDTypes.h:205
libvisio::VSDMisc::operator=
VSDMisc & operator=(const VSDMisc &misc)=default
libvisio::VSDMisc::VSDMisc
VSDMisc(const VSDMisc &misc)=default
libvisio::VSDTabSet
Definition VSDTypes.h:223
libvisio::VSDTabSet::m_tabStops
std::map< unsigned, VSDTabStop > m_tabStops
Definition VSDTypes.h:225
libvisio::VSDTabSet::VSDTabSet
VSDTabSet(const VSDTabSet &tabSet)
Definition VSDTypes.h:227
libvisio::VSDTabSet::m_numChars
unsigned m_numChars
Definition VSDTypes.h:224
libvisio::VSDTabSet::VSDTabSet
VSDTabSet()
Definition VSDTypes.h:226
libvisio::VSDTabStop
Definition VSDTypes.h:212
libvisio::VSDTabStop::VSDTabStop
VSDTabStop(const VSDTabStop &tabStop)
Definition VSDTypes.h:217
libvisio::VSDTabStop::m_leader
unsigned char m_leader
Definition VSDTypes.h:215
libvisio::VSDTabStop::m_alignment
unsigned char m_alignment
Definition VSDTypes.h:214
libvisio::VSDTabStop::VSDTabStop
VSDTabStop()
Definition VSDTypes.h:216
libvisio::VSDTabStop::m_position
double m_position
Definition VSDTypes.h:213
libvisio::XForm1D
Definition VSDTypes.h:43
libvisio::XForm1D::beginId
unsigned beginId
Definition VSDTypes.h:46
libvisio::XForm1D::beginY
double beginY
Definition VSDTypes.h:45
libvisio::XForm1D::XForm1D
XForm1D(const XForm1D &xform1d)
Definition VSDTypes.h:52
libvisio::XForm1D::endId
unsigned endId
Definition VSDTypes.h:49
libvisio::XForm1D::beginX
double beginX
Definition VSDTypes.h:44
libvisio::XForm1D::endY
double endY
Definition VSDTypes.h:48
libvisio::XForm1D::XForm1D
XForm1D()
Definition VSDTypes.h:50
libvisio::XForm1D::endX
double endX
Definition VSDTypes.h:47
libvisio::XForm
Definition VSDTypes.h:23
libvisio::XForm::pinX
double pinX
Definition VSDTypes.h:24
libvisio::XForm::pinLocY
double pinLocY
Definition VSDTypes.h:29
libvisio::XForm::width
double width
Definition VSDTypes.h:27
libvisio::XForm::pinY
double pinY
Definition VSDTypes.h:25
libvisio::XForm::XForm
XForm()
Definition VSDTypes.h:35
libvisio::XForm::height
double height
Definition VSDTypes.h:26
libvisio::XForm::x
double x
Definition VSDTypes.h:33
libvisio::XForm::angle
double angle
Definition VSDTypes.h:30
libvisio::XForm::XForm
XForm(const XForm &xform)=default
libvisio::XForm::flipY
bool flipY
Definition VSDTypes.h:32
libvisio::XForm::flipX
bool flipX
Definition VSDTypes.h:31
libvisio::XForm::pinLocX
double pinLocX
Definition VSDTypes.h:28
libvisio::XForm::y
double y
Definition VSDTypes.h:34
libvisio::XForm::operator=
XForm & operator=(const XForm &xform)=default