VSDTypes.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libvisio
00003  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
00017  * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
00018  *
00019  *
00020  * All Rights Reserved.
00021  *
00022  * For minor contributions see the git repository.
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00026  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00027  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00028  * instead of those above.
00029  */
00030 
00031 #ifndef VSDTYPES_H
00032 #define VSDTYPES_H
00033 
00034 #include <vector>
00035 #include <libwpd/libwpd.h>
00036 
00037 #define FROM_OPTIONAL(t, u) !!t ? t.get() : u
00038 #define ASSIGN_OPTIONAL(t, u) if(!!t) u = t.get()
00039 #define MINUS_ONE (unsigned)-1
00040 
00041 namespace libvisio
00042 {
00043 struct XForm
00044 {
00045   double pinX;
00046   double pinY;
00047   double height;
00048   double width;
00049   double pinLocX;
00050   double pinLocY;
00051   double angle;
00052   bool flipX;
00053   bool flipY;
00054   double x;
00055   double y;
00056   XForm() : pinX(0.0), pinY(0.0), height(0.0), width(0.0),
00057     pinLocX(0.0), pinLocY(0.0), angle(0.0),
00058     flipX(false), flipY(false), x(0.0), y(0.0) {}
00059   XForm(const XForm &xform) : pinX(xform.pinX), pinY(xform.pinY), height(xform.height),
00060     width(xform.width), pinLocX(xform.pinLocX), pinLocY(xform.pinLocY), angle(xform.angle),
00061     flipX(xform.flipX), flipY(xform.flipY), x(xform.x), y(xform.y) {}
00062 
00063 };
00064 
00065 // Utilities
00066 struct ChunkHeader
00067 {
00068   ChunkHeader() : chunkType(0), id(0), list(0), dataLength(0), level(0), unknown(0), trailer(0) {}
00069   unsigned chunkType;  // 4 bytes
00070   unsigned id;         // 4 bytes
00071   unsigned list;       // 4 bytes
00072   unsigned dataLength; // 4 bytes
00073   unsigned short level;      // 2 bytes
00074   unsigned char unknown;    // 1 byte
00075   unsigned trailer; // Derived
00076 };
00077 
00078 struct Colour
00079 {
00080   Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
00081     : r(red), g(green), b(blue), a(alpha) {}
00082   Colour() : r(0), g(0), b(0), a(0) {}
00083   inline bool operator==(const Colour &col)
00084   {
00085     return ((r == col.r) && (g == col.g) && (b == col.b) && (a == col.a));
00086   }
00087   inline bool operator!=(const Colour &col)
00088   {
00089     return !operator==(col);
00090   }
00091   inline bool operator!()
00092   {
00093     return (!r && !g && !b && !a);
00094   }
00095   unsigned char r;
00096   unsigned char g;
00097   unsigned char b;
00098   unsigned char a;
00099 };
00100 
00101 struct NURBSData
00102 {
00103   double lastKnot;
00104   unsigned degree;
00105   unsigned char xType;
00106   unsigned char yType;
00107   std::vector<double> knots;
00108   std::vector<double> weights;
00109   std::vector<std::pair<double, double> > points;
00110   NURBSData()
00111     : lastKnot(0.0),
00112       degree(0),
00113       xType(0x00),
00114       yType(0x00),
00115       knots(),
00116       weights(),
00117       points() {}
00118   NURBSData(const NURBSData &data)
00119     : lastKnot(data.lastKnot),
00120       degree(data.degree),
00121       xType(data.xType),
00122       yType(data.yType),
00123       knots(data.knots),
00124       weights(data.weights),
00125       points(data.points) {}
00126 };
00127 
00128 struct PolylineData
00129 {
00130   unsigned char xType;
00131   unsigned char yType;
00132   std::vector<std::pair<double, double> > points;
00133   PolylineData()
00134     : xType(0x00),
00135       yType(0x00),
00136       points() {}
00137 };
00138 
00139 
00140 struct ForeignData
00141 {
00142   unsigned typeId;
00143   unsigned dataId;
00144   unsigned type;
00145   unsigned format;
00146   double offsetX;
00147   double offsetY;
00148   double width;
00149   double height;
00150   WPXBinaryData data;
00151   ForeignData()
00152     : typeId(0),
00153       dataId(0),
00154       type(0),
00155       format(0),
00156       offsetX(0.0),
00157       offsetY(0.0),
00158       width(0.0),
00159       height(0.0),
00160       data() {}
00161 };
00162 
00163 enum TextFormat
00164 {
00165   VSD_TEXT_ANSI = 0,
00166   VSD_TEXT_SYMBOL,
00167   VSD_TEXT_GREEK,
00168   VSD_TEXT_TURKISH,
00169   VSD_TEXT_VIETNAMESE,
00170   VSD_TEXT_HEBREW,
00171   VSD_TEXT_ARABIC,
00172   VSD_TEXT_BALTIC,
00173   VSD_TEXT_RUSSIAN,
00174   VSD_TEXT_THAI,
00175   VSD_TEXT_CENTRAL_EUROPE,
00176   VSD_TEXT_JAPANESE,
00177   VSD_TEXT_KOREAN,
00178   VSD_TEXT_CHINESE_SIMPLIFIED,
00179   VSD_TEXT_CHINESE_TRADITIONAL,
00180   VSD_TEXT_UTF8,
00181   VSD_TEXT_UTF16
00182 };
00183 
00184 class VSDName
00185 {
00186 public:
00187   VSDName(const WPXBinaryData &data, TextFormat format)
00188     : m_data(data),
00189       m_format(format) {}
00190   VSDName() : m_data(), m_format(VSD_TEXT_ANSI) {}
00191   VSDName(const VSDName &name) : m_data(name.m_data), m_format(name.m_format) {}
00192   bool empty() const
00193   {
00194     return !m_data.size();
00195   }
00196   WPXBinaryData m_data;
00197   TextFormat m_format;
00198 };
00199 
00200 struct VSDFont
00201 {
00202   WPXString m_name;
00203   TextFormat m_encoding;
00204   VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
00205   VSDFont(const WPXString &name, const TextFormat &encoding) :
00206     m_name(name), m_encoding(encoding) {}
00207   VSDFont(const VSDFont &font) :
00208     m_name(font.m_name), m_encoding(font.m_encoding) {}
00209 };
00210 
00211 struct VSDMisc
00212 {
00213   bool m_hideText;
00214   VSDMisc() : m_hideText(false) {}
00215   VSDMisc(const VSDMisc &misc) : m_hideText(misc.m_hideText) {}
00216 };
00217 
00218 } // namespace libvisio
00219 
00220 #endif /* VSDTYPES_H */
00221 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */