VSDTypes.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libvisio project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef VSDTYPES_H
00011 #define VSDTYPES_H
00012 
00013 #include <vector>
00014 #include <librevenge/librevenge.h>
00015 
00016 #define FROM_OPTIONAL(t, u) !!t ? t.get() : u
00017 #define ASSIGN_OPTIONAL(t, u) if(!!t) u = t.get()
00018 #define MINUS_ONE (unsigned)-1
00019 
00020 namespace libvisio
00021 {
00022 struct XForm
00023 {
00024   double pinX;
00025   double pinY;
00026   double height;
00027   double width;
00028   double pinLocX;
00029   double pinLocY;
00030   double angle;
00031   bool flipX;
00032   bool flipY;
00033   double x;
00034   double y;
00035   XForm() : pinX(0.0), pinY(0.0), height(0.0), width(0.0),
00036     pinLocX(0.0), pinLocY(0.0), angle(0.0),
00037     flipX(false), flipY(false), x(0.0), y(0.0) {}
00038   XForm(const XForm &xform) : pinX(xform.pinX), pinY(xform.pinY), height(xform.height),
00039     width(xform.width), pinLocX(xform.pinLocX), pinLocY(xform.pinLocY), angle(xform.angle),
00040     flipX(xform.flipX), flipY(xform.flipY), x(xform.x), y(xform.y) {}
00041 
00042 };
00043 
00044 struct XForm1D
00045 {
00046   double beginX;
00047   double beginY;
00048   unsigned beginId;
00049   double endX;
00050   double endY;
00051   unsigned endId;
00052   XForm1D() : beginX(0.0), beginY(0.0), beginId(MINUS_ONE),
00053     endX(0.0), endY(0.0), endId(MINUS_ONE) {}
00054   XForm1D(const XForm1D &xform1d) : beginX(xform1d.beginX),
00055     beginY(xform1d.beginY), beginId(xform1d.beginId),
00056     endX(xform1d.endX), endY(xform1d.endY), endId(xform1d.endId) {}
00057 };
00058 
00059 // Utilities
00060 struct ChunkHeader
00061 {
00062   ChunkHeader() : chunkType(0), id(0), list(0), dataLength(0), level(0), unknown(0), trailer(0) {}
00063   unsigned chunkType;  // 4 bytes
00064   unsigned id;         // 4 bytes
00065   unsigned list;       // 4 bytes
00066   unsigned dataLength; // 4 bytes
00067   unsigned short level;      // 2 bytes
00068   unsigned char unknown;    // 1 byte
00069   unsigned trailer; // Derived
00070 };
00071 
00072 struct Colour
00073 {
00074   Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
00075     : r(red), g(green), b(blue), a(alpha) {}
00076   Colour() : r(0), g(0), b(0), a(0) {}
00077   inline bool operator==(const Colour &col)
00078   {
00079     return ((r == col.r) && (g == col.g) && (b == col.b) && (a == col.a));
00080   }
00081   inline bool operator!=(const Colour &col)
00082   {
00083     return !operator==(col);
00084   }
00085   inline bool operator!()
00086   {
00087     return (!r && !g && !b && !a);
00088   }
00089   unsigned char r;
00090   unsigned char g;
00091   unsigned char b;
00092   unsigned char a;
00093 };
00094 
00095 struct NURBSData
00096 {
00097   double lastKnot;
00098   unsigned degree;
00099   unsigned char xType;
00100   unsigned char yType;
00101   std::vector<double> knots;
00102   std::vector<double> weights;
00103   std::vector<std::pair<double, double> > points;
00104   NURBSData()
00105     : lastKnot(0.0),
00106       degree(0),
00107       xType(0x00),
00108       yType(0x00),
00109       knots(),
00110       weights(),
00111       points() {}
00112   NURBSData(const NURBSData &data)
00113     : lastKnot(data.lastKnot),
00114       degree(data.degree),
00115       xType(data.xType),
00116       yType(data.yType),
00117       knots(data.knots),
00118       weights(data.weights),
00119       points(data.points) {}
00120 };
00121 
00122 struct PolylineData
00123 {
00124   unsigned char xType;
00125   unsigned char yType;
00126   std::vector<std::pair<double, double> > points;
00127   PolylineData()
00128     : xType(0x00),
00129       yType(0x00),
00130       points() {}
00131 };
00132 
00133 
00134 struct ForeignData
00135 {
00136   unsigned typeId;
00137   unsigned dataId;
00138   unsigned type;
00139   unsigned format;
00140   double offsetX;
00141   double offsetY;
00142   double width;
00143   double height;
00144   librevenge::RVNGBinaryData data;
00145   ForeignData()
00146     : typeId(0),
00147       dataId(0),
00148       type(0),
00149       format(0),
00150       offsetX(0.0),
00151       offsetY(0.0),
00152       width(0.0),
00153       height(0.0),
00154       data() {}
00155 };
00156 
00157 enum TextFormat
00158 {
00159   VSD_TEXT_ANSI = 0,
00160   VSD_TEXT_SYMBOL,
00161   VSD_TEXT_GREEK,
00162   VSD_TEXT_TURKISH,
00163   VSD_TEXT_VIETNAMESE,
00164   VSD_TEXT_HEBREW,
00165   VSD_TEXT_ARABIC,
00166   VSD_TEXT_BALTIC,
00167   VSD_TEXT_RUSSIAN,
00168   VSD_TEXT_THAI,
00169   VSD_TEXT_CENTRAL_EUROPE,
00170   VSD_TEXT_JAPANESE,
00171   VSD_TEXT_KOREAN,
00172   VSD_TEXT_CHINESE_SIMPLIFIED,
00173   VSD_TEXT_CHINESE_TRADITIONAL,
00174   VSD_TEXT_UTF8,
00175   VSD_TEXT_UTF16
00176 };
00177 
00178 class VSDName
00179 {
00180 public:
00181   VSDName(const librevenge::RVNGBinaryData &data, TextFormat format)
00182     : m_data(data),
00183       m_format(format) {}
00184   VSDName() : m_data(), m_format(VSD_TEXT_ANSI) {}
00185   VSDName(const VSDName &name) : m_data(name.m_data), m_format(name.m_format) {}
00186   bool empty() const
00187   {
00188     return !m_data.size();
00189   }
00190   librevenge::RVNGBinaryData m_data;
00191   TextFormat m_format;
00192 };
00193 
00194 struct VSDFont
00195 {
00196   librevenge::RVNGString m_name;
00197   TextFormat m_encoding;
00198   VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
00199   VSDFont(const librevenge::RVNGString &name, const TextFormat &encoding) :
00200     m_name(name), m_encoding(encoding) {}
00201   VSDFont(const VSDFont &font) :
00202     m_name(font.m_name), m_encoding(font.m_encoding) {}
00203 };
00204 
00205 struct VSDMisc
00206 {
00207   bool m_hideText;
00208   VSDMisc() : m_hideText(false) {}
00209   VSDMisc(const VSDMisc &misc) : m_hideText(misc.m_hideText) {}
00210 };
00211 
00212 } // namespace libvisio
00213 
00214 #endif /* VSDTYPES_H */
00215 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */