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
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;
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 
129 {
130  unsigned char xType;
131  unsigned char yType;
132  std::vector<std::pair<double, double> > points;
134  : xType(0x00),
135  yType(0x00),
136  points() {}
137 };
138 
139 
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;
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 
164 {
177 };
178 
179 class VSDName
180 {
181 public:
182  VSDName(const WPXBinaryData &data, TextFormat format)
183  : m_data(data),
184  m_format(format) {}
186  VSDName(const VSDName &name) : m_data(name.m_data), m_format(name.m_format) {}
187  WPXBinaryData m_data;
189 };
190 
191 struct VSDFont
192 {
193  WPXString m_name;
195  VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
196  VSDFont(const WPXString &name, const TextFormat &encoding) :
197  m_name(name), m_encoding(encoding) {}
198  VSDFont(const VSDFont &font) :
199  m_name(font.m_name), m_encoding(font.m_encoding) {}
200 };
201 
202 } // namespace libvisio
203 
204 #endif /* VSDTYPES_H */
205 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated for libvisio by doxygen 1.8.1.1