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