- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

VSDTypes.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libvisio
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) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
17 * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
18 *
19 *
20 * All Rights Reserved.
21 *
22 * For minor contributions see the git repository.
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
26 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
27 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
28 * instead of those above.
29 */
30
31 #ifndef VSDTYPES_H
32 #define VSDTYPES_H
33
34 #include <vector>
35 #include <libwpd/libwpd.h>
36
37 #define FROM_OPTIONAL(t, u) !!t ? t.get() : u
38 #define ASSIGN_OPTIONAL(t, u) if(!!t) u = t.get()
39 #define MINUS_ONE (unsigned)-1
40
41 namespace libvisio
42 {
43 struct XForm
44 {
45 double pinX;
46 double pinY;
47 double height;
48 double width;
49 double pinLocX;
50 double pinLocY;
51 double angle;
52 bool flipX;
53 bool flipY;
54 double x;
55 double y;
56 XForm() : pinX(0.0), pinY(0.0), height(0.0), width(0.0),
57 pinLocX(0.0), pinLocY(0.0), angle(0.0),
58 flipX(false), flipY(false), x(0.0), y(0.0) {}
59 XForm(const XForm &xform) : pinX(xform.pinX), pinY(xform.pinY), height(xform.height),
60 width(xform.width), pinLocX(xform.pinLocX), pinLocY(xform.pinLocY), angle(xform.angle),
61 flipX(xform.flipX), flipY(xform.flipY), x(xform.x), y(xform.y) {}
62
63 };
64
65 // Utilities
66 struct ChunkHeader
67 {
68 ChunkHeader() : chunkType(0), id(0), list(0), dataLength(0), level(0), unknown(0), trailer(0) {}
69 unsigned chunkType; // 4 bytes
70 unsigned id; // 4 bytes
71 unsigned list; // 4 bytes
72 unsigned dataLength; // 4 bytes
73 unsigned short level; // 2 bytes
74 unsigned char unknown; // 1 byte
75 unsigned trailer; // Derived
76 };
77
78 struct Colour
79 {
80 Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
81 : r(red), g(green), b(blue), a(alpha) {}
82 Colour() : r(0), g(0), b(0), a(0) {}
83 inline bool operator==(const Colour &col)
84 {
85 return ((r == col.r) && (g == col.g) && (b == col.b) && (a == col.a));
86 }
87 inline bool operator!=(const Colour &col)
88 {
89 return !operator==(col);
90 }
91 inline bool operator!()
92 {
93 return (!r && !g && !b && !a);
94 }
95 unsigned char r;
96 unsigned char g;
97 unsigned char b;
98 unsigned char a;
99 };
100
101 struct NURBSData
102 {
103 double lastKnot;
104 unsigned degree;
105 unsigned char xType;
106 unsigned char yType;
107 std::vector<double> knots;
108 std::vector<double> weights;
109 std::vector<std::pair<double, double> > points;
110 NURBSData()
111 : lastKnot(0.0),
112 degree(0),
113 xType(0x00),
114 yType(0x00),
115 knots(),
116 weights(),
117 points() {}
118 NURBSData(const NURBSData &data)
119 : lastKnot(data.lastKnot),
120 degree(data.degree),
121 xType(data.xType),
122 yType(data.yType),
123 knots(data.knots),
124 weights(data.weights),
125 points(data.points) {}
126 };
127
128 struct PolylineData
129 {
130 unsigned char xType;
131 unsigned char yType;
132 std::vector<std::pair<double, double> > points;
133 PolylineData()
134 : xType(0x00),
135 yType(0x00),
136 points() {}
137 };
138
139
140 struct ForeignData
141 {
142 unsigned typeId;
143 unsigned dataId;
144 unsigned type;
145 unsigned format;
146 double offsetX;
147 double offsetY;
148 double width;
149 double height;
150 WPXBinaryData data;
151 ForeignData()
152 : typeId(0),
153 dataId(0),
154 type(0),
155 format(0),
156 offsetX(0.0),
157 offsetY(0.0),
158 width(0.0),
159 height(0.0),
160 data() {}
161 };
162
163 enum TextFormat
164 {
165 VSD_TEXT_ANSI = 0,
166 VSD_TEXT_SYMBOL,
167 VSD_TEXT_GREEK,
168 VSD_TEXT_TURKISH,
169 VSD_TEXT_VIETNAMESE,
170 VSD_TEXT_HEBREW,
171 VSD_TEXT_ARABIC,
172 VSD_TEXT_BALTIC,
173 VSD_TEXT_RUSSIAN,
174 VSD_TEXT_THAI,
175 VSD_TEXT_CENTRAL_EUROPE,
176 VSD_TEXT_JAPANESE,
177 VSD_TEXT_KOREAN,
178 VSD_TEXT_CHINESE_SIMPLIFIED,
179 VSD_TEXT_CHINESE_TRADITIONAL,
180 VSD_TEXT_UTF8,
181 VSD_TEXT_UTF16
182 };
183
184 class VSDName
185 {
186 public:
187 VSDName(const WPXBinaryData &data, TextFormat format)
188 : m_data(data),
189 m_format(format) {}
190 VSDName() : m_data(), m_format(VSD_TEXT_ANSI) {}
191 VSDName(const VSDName &name) : m_data(name.m_data), m_format(name.m_format) {}
192 bool empty() const
193 {
194 return !m_data.size();
195 }
196 WPXBinaryData m_data;
197 TextFormat m_format;
198 };
199
200 struct VSDFont
201 {
202 WPXString m_name;
203 TextFormat m_encoding;
204 VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
205 VSDFont(const WPXString &name, const TextFormat &encoding) :
206 m_name(name), m_encoding(encoding) {}
207 VSDFont(const VSDFont &font) :
208 m_name(font.m_name), m_encoding(font.m_encoding) {}
209 };
210
211 struct VSDMisc
212 {
213 bool m_hideText;
214 VSDMisc() : m_hideText(false) {}
215 VSDMisc(const VSDMisc &misc) : m_hideText(misc.m_hideText) {}
216 };
217
218 } // namespace libvisio
219
220 #endif /* VSDTYPES_H */
221 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSD_TEXT_THAI
Definition: VSDTypes.h:174
libvisio::ChunkHeader::id
unsigned id
Definition: VSDTypes.h:70
libvisio::VSDFont::VSDFont
VSDFont()
Definition: VSDTypes.h:204
libvisio::VSDName::m_data
WPXBinaryData m_data
Definition: VSDTypes.h:196
libvisio::Colour::Colour
Colour()
Definition: VSDTypes.h:82
libvisio::VSD_TEXT_CHINESE_SIMPLIFIED
Definition: VSDTypes.h:178
libvisio::XForm::x
double x
Definition: VSDTypes.h:54
libvisio::NURBSData::weights
std::vector< double > weights
Definition: VSDTypes.h:108
libvisio::VSDName::m_format
TextFormat m_format
Definition: VSDTypes.h:197
libvisio::XForm::width
double width
Definition: VSDTypes.h:48
libvisio::VSDMisc::m_hideText
bool m_hideText
Definition: VSDTypes.h:213
libvisio::PolylineData::xType
unsigned char xType
Definition: VSDTypes.h:130
libvisio::VSD_TEXT_SYMBOL
Definition: VSDTypes.h:166
libvisio::NURBSData
Definition: VSDTypes.h:101
libvisio::Colour
Definition: VSDTypes.h:78
libvisio::VSD_TEXT_BALTIC
Definition: VSDTypes.h:172
libvisio::PolylineData::PolylineData
PolylineData()
Definition: VSDTypes.h:133
libvisio::ForeignData::offsetY
double offsetY
Definition: VSDTypes.h:147
libvisio::Colour::b
unsigned char b
Definition: VSDTypes.h:97
libvisio::ChunkHeader::chunkType
unsigned chunkType
Definition: VSDTypes.h:69
libvisio::XForm::XForm
XForm()
Definition: VSDTypes.h:56
libvisio::Colour::operator!=
bool operator!=(const Colour &col)
Definition: VSDTypes.h:87
libvisio::VSDFont::m_encoding
TextFormat m_encoding
Definition: VSDTypes.h:203
libvisio::VSD_TEXT_UTF8
Definition: VSDTypes.h:180
libvisio::VSDMisc::VSDMisc
VSDMisc(const VSDMisc &misc)
Definition: VSDTypes.h:215
libvisio::XForm::flipX
bool flipX
Definition: VSDTypes.h:52
libvisio::VSDMisc
Definition: VSDTypes.h:211
libvisio::XForm::pinLocX
double pinLocX
Definition: VSDTypes.h:49
libvisio::XForm::angle
double angle
Definition: VSDTypes.h:51
libvisio::VSDName::empty
bool empty() const
Definition: VSDTypes.h:192
libvisio::VSD_TEXT_HEBREW
Definition: VSDTypes.h:170
libvisio::ForeignData::ForeignData
ForeignData()
Definition: VSDTypes.h:151
libvisio::XForm::pinLocY
double pinLocY
Definition: VSDTypes.h:50
libvisio::VSD_TEXT_TURKISH
Definition: VSDTypes.h:168
libvisio::NURBSData::xType
unsigned char xType
Definition: VSDTypes.h:105
libvisio::ForeignData::offsetX
double offsetX
Definition: VSDTypes.h:146
libvisio::NURBSData::NURBSData
NURBSData()
Definition: VSDTypes.h:110
libvisio::XForm::pinX
double pinX
Definition: VSDTypes.h:45
libvisio::VSDName::VSDName
VSDName(const VSDName &name)
Definition: VSDTypes.h:191
libvisio::VSD_TEXT_JAPANESE
Definition: VSDTypes.h:176
libvisio::ForeignData::dataId
unsigned dataId
Definition: VSDTypes.h:143
libvisio::XForm::XForm
XForm(const XForm &xform)
Definition: VSDTypes.h:59
libvisio::VSD_TEXT_ARABIC
Definition: VSDTypes.h:171
libvisio::NURBSData::knots
std::vector< double > knots
Definition: VSDTypes.h:107
libvisio::ForeignData::format
unsigned format
Definition: VSDTypes.h:145
libvisio::VSD_TEXT_UTF16
Definition: VSDTypes.h:181
libvisio::VSDFont::VSDFont
VSDFont(const WPXString &name, const TextFormat &encoding)
Definition: VSDTypes.h:205
libvisio::Colour::operator!
bool operator!()
Definition: VSDTypes.h:91
libvisio::NURBSData::yType
unsigned char yType
Definition: VSDTypes.h:106
libvisio::XForm::y
double y
Definition: VSDTypes.h:55
libvisio::NURBSData::degree
unsigned degree
Definition: VSDTypes.h:104
libvisio::Colour::g
unsigned char g
Definition: VSDTypes.h:96
libvisio::XForm::height
double height
Definition: VSDTypes.h:47
libvisio::TextFormat
TextFormat
Definition: VSDTypes.h:163
libvisio::NURBSData::lastKnot
double lastKnot
Definition: VSDTypes.h:103
libvisio::VSDName::VSDName
VSDName()
Definition: VSDTypes.h:190
libvisio::ForeignData::type
unsigned type
Definition: VSDTypes.h:144
libvisio::Colour::operator==
bool operator==(const Colour &col)
Definition: VSDTypes.h:83
libvisio::ForeignData
Definition: VSDTypes.h:140
libvisio::VSD_TEXT_VIETNAMESE
Definition: VSDTypes.h:169
libvisio::VSDFont::VSDFont
VSDFont(const VSDFont &font)
Definition: VSDTypes.h:207
libvisio::Colour::a
unsigned char a
Definition: VSDTypes.h:98
libvisio::PolylineData::points
std::vector< std::pair< double, double > > points
Definition: VSDTypes.h:132
libvisio::ChunkHeader
Definition: VSDTypes.h:66
libvisio::NURBSData::points
std::vector< std::pair< double, double > > points
Definition: VSDTypes.h:109
libvisio::ChunkHeader::unknown
unsigned char unknown
Definition: VSDTypes.h:74
libvisio::VSD_TEXT_CHINESE_TRADITIONAL
Definition: VSDTypes.h:179
libvisio::Colour::Colour
Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
Definition: VSDTypes.h:80
libvisio::ForeignData::data
WPXBinaryData data
Definition: VSDTypes.h:150
libvisio::VSD_TEXT_GREEK
Definition: VSDTypes.h:167
libvisio::VSD_TEXT_KOREAN
Definition: VSDTypes.h:177
libvisio::NURBSData::NURBSData
NURBSData(const NURBSData &data)
Definition: VSDTypes.h:118
libvisio::ChunkHeader::list
unsigned list
Definition: VSDTypes.h:71
libvisio::ForeignData::height
double height
Definition: VSDTypes.h:149
libvisio::ChunkHeader::ChunkHeader
ChunkHeader()
Definition: VSDTypes.h:68
libvisio::PolylineData
Definition: VSDTypes.h:128
libvisio::XForm::flipY
bool flipY
Definition: VSDTypes.h:53
libvisio::ChunkHeader::level
unsigned short level
Definition: VSDTypes.h:73
libvisio::XForm
Definition: VSDTypes.h:43
libvisio::ChunkHeader::dataLength
unsigned dataLength
Definition: VSDTypes.h:72
libvisio::PolylineData::yType
unsigned char yType
Definition: VSDTypes.h:131
libvisio::Colour::r
unsigned char r
Definition: VSDTypes.h:95
libvisio::XForm::pinY
double pinY
Definition: VSDTypes.h:46
libvisio::VSDName
Definition: VSDTypes.h:184
libvisio::VSDMisc::VSDMisc
VSDMisc()
Definition: VSDTypes.h:214
libvisio::VSDFont
Definition: VSDTypes.h:200
libvisio::ForeignData::width
double width
Definition: VSDTypes.h:148
libvisio::VSD_TEXT_ANSI
Definition: VSDTypes.h:165
libvisio::VSDFont::m_name
WPXString m_name
Definition: VSDTypes.h:202
libvisio::VSDName::VSDName
VSDName(const WPXBinaryData &data, TextFormat format)
Definition: VSDTypes.h:187
libvisio::VSD_TEXT_CENTRAL_EUROPE
Definition: VSDTypes.h:175
libvisio::ChunkHeader::trailer
unsigned trailer
Definition: VSDTypes.h:75
libvisio::ForeignData::typeId
unsigned typeId
Definition: VSDTypes.h:142
libvisio::VSD_TEXT_RUSSIAN
Definition: VSDTypes.h:173