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 <librevenge/librevenge.h>
15 
16 #define FROM_OPTIONAL(t, u) !!t ? t.get() : u
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 // Utilities
46 {
47  ChunkHeader() : chunkType(0), id(0), list(0), dataLength(0), level(0), unknown(0), trailer(0) {}
48  unsigned chunkType; // 4 bytes
49  unsigned id; // 4 bytes
50  unsigned list; // 4 bytes
51  unsigned dataLength; // 4 bytes
52  unsigned short level; // 2 bytes
53  unsigned char unknown; // 1 byte
54  unsigned trailer; // Derived
55 };
56 
57 struct Colour
58 {
59  Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
60  : r(red), g(green), b(blue), a(alpha) {}
61  Colour() : r(0), g(0), b(0), a(0) {}
62  inline bool operator==(const Colour &col)
63  {
64  return ((r == col.r) && (g == col.g) && (b == col.b) && (a == col.a));
65  }
66  inline bool operator!=(const Colour &col)
67  {
68  return !operator==(col);
69  }
70  inline bool operator!()
71  {
72  return (!r && !g && !b && !a);
73  }
74  unsigned char r;
75  unsigned char g;
76  unsigned char b;
77  unsigned char a;
78 };
79 
80 struct NURBSData
81 {
82  double lastKnot;
83  unsigned degree;
84  unsigned char xType;
85  unsigned char yType;
86  std::vector<double> knots;
87  std::vector<double> weights;
88  std::vector<std::pair<double, double> > points;
90  : lastKnot(0.0),
91  degree(0),
92  xType(0x00),
93  yType(0x00),
94  knots(),
95  weights(),
96  points() {}
97  NURBSData(const NURBSData &data)
98  : lastKnot(data.lastKnot),
99  degree(data.degree),
100  xType(data.xType),
101  yType(data.yType),
102  knots(data.knots),
103  weights(data.weights),
104  points(data.points) {}
105 };
106 
108 {
109  unsigned char xType;
110  unsigned char yType;
111  std::vector<std::pair<double, double> > points;
113  : xType(0x00),
114  yType(0x00),
115  points() {}
116 };
117 
118 
120 {
121  unsigned typeId;
122  unsigned dataId;
123  unsigned type;
124  unsigned format;
125  double offsetX;
126  double offsetY;
127  double width;
128  double height;
129  librevenge::RVNGBinaryData data;
131  : typeId(0),
132  dataId(0),
133  type(0),
134  format(0),
135  offsetX(0.0),
136  offsetY(0.0),
137  width(0.0),
138  height(0.0),
139  data() {}
140 };
141 
143 {
161 };
162 
163 class VSDName
164 {
165 public:
166  VSDName(const librevenge::RVNGBinaryData &data, TextFormat format)
167  : m_data(data),
168  m_format(format) {}
170  VSDName(const VSDName &name) : m_data(name.m_data), m_format(name.m_format) {}
171  bool empty() const
172  {
173  return !m_data.size();
174  }
175  librevenge::RVNGBinaryData m_data;
177 };
178 
179 struct VSDFont
180 {
181  librevenge::RVNGString m_name;
183  VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
184  VSDFont(const librevenge::RVNGString &name, const TextFormat &encoding) :
185  m_name(name), m_encoding(encoding) {}
186  VSDFont(const VSDFont &font) :
187  m_name(font.m_name), m_encoding(font.m_encoding) {}
188 };
189 
190 struct VSDMisc
191 {
193  VSDMisc() : m_hideText(false) {}
194  VSDMisc(const VSDMisc &misc) : m_hideText(misc.m_hideText) {}
195 };
196 
197 } // namespace libvisio
198 
199 #endif /* VSDTYPES_H */
200 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition: VSDTypes.h:153
unsigned id
Definition: VSDTypes.h:49
VSDFont()
Definition: VSDTypes.h:183
VSDName(const librevenge::RVNGBinaryData &data, TextFormat format)
Definition: VSDTypes.h:166
librevenge::RVNGString m_name
Definition: VSDTypes.h:181
librevenge::RVNGBinaryData m_data
Definition: VSDTypes.h:175
Colour()
Definition: VSDTypes.h:61
Definition: VSDTypes.h:157
double x
Definition: VSDTypes.h:33
std::vector< double > weights
Definition: VSDTypes.h:87
TextFormat m_format
Definition: VSDTypes.h:176
double width
Definition: VSDTypes.h:27
bool m_hideText
Definition: VSDTypes.h:192
unsigned char xType
Definition: VSDTypes.h:109
Definition: VSDTypes.h:145
Definition: VSDTypes.h:80
Definition: VSDTypes.h:57
Definition: VSDTypes.h:151
PolylineData()
Definition: VSDTypes.h:112
double offsetY
Definition: VSDTypes.h:126
unsigned char b
Definition: VSDTypes.h:76
unsigned chunkType
Definition: VSDTypes.h:48
XForm()
Definition: VSDTypes.h:35
librevenge::RVNGBinaryData data
Definition: VSDTypes.h:129
bool operator!=(const Colour &col)
Definition: VSDTypes.h:66
TextFormat m_encoding
Definition: VSDTypes.h:182
Definition: VSDTypes.h:159
VSDMisc(const VSDMisc &misc)
Definition: VSDTypes.h:194
bool flipX
Definition: VSDTypes.h:31
Definition: VSDTypes.h:190
double pinLocX
Definition: VSDTypes.h:28
double angle
Definition: VSDTypes.h:30
bool empty() const
Definition: VSDTypes.h:171
Definition: VSDTypes.h:149
ForeignData()
Definition: VSDTypes.h:130
double pinLocY
Definition: VSDTypes.h:29
Definition: VSDTypes.h:147
unsigned char xType
Definition: VSDTypes.h:84
double offsetX
Definition: VSDTypes.h:125
NURBSData()
Definition: VSDTypes.h:89
double pinX
Definition: VSDTypes.h:24
VSDName(const VSDName &name)
Definition: VSDTypes.h:170
Definition: VSDTypes.h:155
unsigned dataId
Definition: VSDTypes.h:122
XForm(const XForm &xform)
Definition: VSDTypes.h:38
VSDFont(const librevenge::RVNGString &name, const TextFormat &encoding)
Definition: VSDTypes.h:184
Definition: VSDTypes.h:150
std::vector< double > knots
Definition: VSDTypes.h:86
unsigned format
Definition: VSDTypes.h:124
Definition: VSDTypes.h:160
bool operator!()
Definition: VSDTypes.h:70
unsigned char yType
Definition: VSDTypes.h:85
double y
Definition: VSDTypes.h:34
unsigned degree
Definition: VSDTypes.h:83
unsigned char g
Definition: VSDTypes.h:75
double height
Definition: VSDTypes.h:26
TextFormat
Definition: VSDTypes.h:142
double lastKnot
Definition: VSDTypes.h:82
VSDName()
Definition: VSDTypes.h:169
unsigned type
Definition: VSDTypes.h:123
bool operator==(const Colour &col)
Definition: VSDTypes.h:62
Definition: VSDTypes.h:119
Definition: VSDTypes.h:148
VSDFont(const VSDFont &font)
Definition: VSDTypes.h:186
unsigned char a
Definition: VSDTypes.h:77
std::vector< std::pair< double, double > > points
Definition: VSDTypes.h:111
Definition: VSDTypes.h:45
std::vector< std::pair< double, double > > points
Definition: VSDTypes.h:88
unsigned char unknown
Definition: VSDTypes.h:53
Definition: VSDTypes.h:158
Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
Definition: VSDTypes.h:59
Definition: VSDTypes.h:146
Definition: VSDTypes.h:156
NURBSData(const NURBSData &data)
Definition: VSDTypes.h:97
unsigned list
Definition: VSDTypes.h:50
double height
Definition: VSDTypes.h:128
ChunkHeader()
Definition: VSDTypes.h:47
Definition: VSDTypes.h:107
bool flipY
Definition: VSDTypes.h:32
unsigned short level
Definition: VSDTypes.h:52
Definition: VSDTypes.h:22
unsigned dataLength
Definition: VSDTypes.h:51
unsigned char yType
Definition: VSDTypes.h:110
unsigned char r
Definition: VSDTypes.h:74
double pinY
Definition: VSDTypes.h:25
Definition: VSDTypes.h:163
VSDMisc()
Definition: VSDTypes.h:193
Definition: VSDTypes.h:179
double width
Definition: VSDTypes.h:127
Definition: VSDTypes.h:144
Definition: VSDTypes.h:154
unsigned trailer
Definition: VSDTypes.h:54
unsigned typeId
Definition: VSDTypes.h:121
Definition: VSDTypes.h:152

Generated for libvisio by doxygen 1.8.6