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