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   unsigned chunkType;  // 4 bytes
00069   unsigned id;         // 4 bytes
00070   unsigned list;       // 4 bytes
00071   unsigned dataLength; // 4 bytes
00072   unsigned short level;      // 2 bytes
00073   unsigned char unknown;    // 1 byte
00074   unsigned trailer; // Derived
00075 };
00076 
00077 struct Colour
00078 {
00079   Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
00080     : r(red), g(green), b(blue), a(alpha) {}
00081   Colour() : r(0), g(0), b(0), a(0) {}
00082   unsigned char r;
00083   unsigned char g;
00084   unsigned char b;
00085   unsigned char a;
00086 };
00087 
00088 struct NURBSData
00089 {
00090   double lastKnot;
00091   unsigned degree;
00092   unsigned char xType;
00093   unsigned char yType;
00094   std::vector<double> knots;
00095   std::vector<double> weights;
00096   std::vector<std::pair<double, double> > points;
00097   NURBSData()
00098     : lastKnot(0.0),
00099       degree(0),
00100       xType(0x00),
00101       yType(0x00),
00102       knots(),
00103       weights(),
00104       points() {}
00105   NURBSData(const NURBSData &data)
00106     : lastKnot(data.lastKnot),
00107       degree(data.degree),
00108       xType(data.xType),
00109       yType(data.yType),
00110       knots(data.knots),
00111       weights(data.weights),
00112       points(data.points) {}
00113 };
00114 
00115 struct PolylineData
00116 {
00117   unsigned char xType;
00118   unsigned char yType;
00119   std::vector<std::pair<double, double> > points;
00120   PolylineData()
00121     : xType(0x00),
00122       yType(0x00),
00123       points() {}
00124 };
00125 
00126 
00127 struct ForeignData
00128 {
00129   unsigned typeId;
00130   unsigned dataId;
00131   unsigned type;
00132   unsigned format;
00133   double offsetX;
00134   double offsetY;
00135   double width;
00136   double height;
00137   WPXBinaryData data;
00138   ForeignData()
00139     : typeId(0),
00140       dataId(0),
00141       type(0),
00142       format(0),
00143       offsetX(0.0),
00144       offsetY(0.0),
00145       width(0.0),
00146       height(0.0),
00147       data() {}
00148 };
00149 
00150 enum TextFormat
00151 {
00152   VSD_TEXT_ANSI = 0,
00153   VSD_TEXT_GREEK,
00154   VSD_TEXT_TURKISH,
00155   VSD_TEXT_VIETNAMESE,
00156   VSD_TEXT_HEBREW,
00157   VSD_TEXT_ARABIC,
00158   VSD_TEXT_BALTIC,
00159   VSD_TEXT_RUSSIAN,
00160   VSD_TEXT_THAI,
00161   VSD_TEXT_CENTRAL_EUROPE,
00162   VSD_TEXT_UTF8,
00163   VSD_TEXT_UTF16
00164 };
00165 
00166 class VSDName
00167 {
00168 public:
00169   VSDName(const WPXBinaryData &data, TextFormat format)
00170     : m_data(data),
00171       m_format(format) {}
00172   VSDName() : m_data(), m_format(VSD_TEXT_ANSI) {}
00173   VSDName(const VSDName &name) : m_data(name.m_data), m_format(name.m_format) {}
00174   WPXBinaryData m_data;
00175   TextFormat m_format;
00176 };
00177 
00178 struct VSDFont
00179 {
00180   WPXString m_name;
00181   TextFormat m_encoding;
00182   VSDFont() : m_name("Arial"), m_encoding(libvisio::VSD_TEXT_ANSI) {}
00183   VSDFont(const WPXString &name, const TextFormat &encoding) :
00184     m_name(name), m_encoding(encoding) {}
00185   VSDFont(const VSDFont &font) :
00186     m_name(font.m_name), m_encoding(font.m_encoding) {}
00187 };
00188 
00189 } // namespace libvisio
00190 
00191 #endif /* VSDTYPES_H */
00192 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */