VSDXTypes.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 VSDXTYPES_H
00032 #define VSDXTYPES_H
00033 
00034 #include <libwpd/libwpd.h>
00035 
00036 namespace libvisio
00037 {
00038 struct XForm
00039 {
00040   double pinX;
00041   double pinY;
00042   double height;
00043   double width;
00044   double pinLocX;
00045   double pinLocY;
00046   double angle;
00047   bool flipX;
00048   bool flipY;
00049   double x;
00050   double y;
00051   XForm() : pinX(0.0), pinY(0.0), height(0.0), width(0.0),
00052     pinLocX(0.0), pinLocY(0.0), angle(0.0),
00053     flipX(false), flipY(false), x(0.0), y(0.0) {}
00054 };
00055 
00056 // Utilities
00057 struct ChunkHeader
00058 {
00059   unsigned chunkType;  // 4 bytes
00060   unsigned id;         // 4 bytes
00061   unsigned list;       // 4 bytes
00062   unsigned dataLength; // 4 bytes
00063   unsigned short level;      // 2 bytes
00064   unsigned char unknown;    // 1 byte
00065   unsigned trailer; // Derived
00066 };
00067 
00068 struct Colour
00069 {
00070   Colour(unsigned red, unsigned char green, unsigned char blue, unsigned char alpha)
00071     : r(red), g(green), b(blue), a(alpha) {}
00072   Colour() : r(0), g(0), b(0), a(0) {}
00073   unsigned char r;
00074   unsigned char g;
00075   unsigned char b;
00076   unsigned char a;
00077 };
00078 
00079 struct NURBSData
00080 {
00081   double lastKnot;
00082   unsigned degree;
00083   unsigned char xType;
00084   unsigned char yType;
00085   std::vector<double> knots;
00086   std::vector<double> weights;
00087   std::vector<std::pair<double, double> > points;
00088   NURBSData()
00089     : lastKnot(0.0),
00090       degree(0),
00091       xType(0x00),
00092       yType(0x00),
00093       knots(),
00094       weights(),
00095       points() {}
00096   NURBSData(const NURBSData &data)
00097     : lastKnot(data.lastKnot),
00098       degree(data.degree),
00099       xType(data.xType),
00100       yType(data.yType),
00101       knots(data.knots),
00102       weights(data.weights),
00103       points(data.points) {}
00104   NURBSData &operator=(const NURBSData &data)
00105   {
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     return *this;
00114   }
00115 };
00116 
00117 struct PolylineData
00118 {
00119   unsigned char xType;
00120   unsigned char yType;
00121   std::vector<std::pair<double, double> > points;
00122   PolylineData()
00123     : xType(0x00),
00124       yType(0x00),
00125       points() {}
00126   PolylineData(const PolylineData &data)
00127     : xType(data.xType),
00128       yType(data.yType),
00129       points(data.points) {}
00130   PolylineData &operator=(const PolylineData &data)
00131   {
00132     xType = data.xType;
00133     yType = data.yType;
00134     points = data.points;
00135     return *this;
00136   }
00137 };
00138 
00139 
00140 struct ForeignData
00141 {
00142   unsigned typeId;
00143   unsigned dataId;
00144   unsigned typeLevel;
00145   unsigned dataLevel;
00146   unsigned type;
00147   unsigned format;
00148   double offsetX;
00149   double offsetY;
00150   double width;
00151   double height;
00152   WPXBinaryData data;
00153   ForeignData()
00154     : typeId(0),
00155       dataId(0),
00156       typeLevel(0),
00157       dataLevel(0),
00158       type(0),
00159       format(0),
00160       offsetX(0.0),
00161       offsetY(0.0),
00162       width(0.0),
00163       height(0.0),
00164       data() {}
00165   ForeignData(const ForeignData &fd)
00166     : typeId(fd.typeId),
00167       dataId(fd.dataId),
00168       typeLevel(fd.typeLevel),
00169       dataLevel(fd.dataLevel),
00170       type(fd.type),
00171       format(fd.format),
00172       offsetX(fd.offsetX),
00173       offsetY(fd.offsetY),
00174       width(fd.width),
00175       height(fd.height),
00176       data(fd.data) {}
00177 };
00178 
00179 enum TextFormat { VSD_TEXT_ANSI, VSD_TEXT_UTF16 };
00180 
00181 class VSDXName
00182 {
00183 public:
00184   VSDXName(const WPXBinaryData &data, TextFormat format)
00185     : m_data(data),
00186       m_format(format) {}
00187   VSDXName() : m_data(), m_format(VSD_TEXT_ANSI) {}
00188   VSDXName(const VSDXName &element)
00189     : m_data(element.m_data),
00190       m_format(element.m_format) {}
00191   VSDXName &operator=(const VSDXName &element)
00192   {
00193     m_data = element.m_data;
00194     m_format = element.m_format;
00195     return *this;
00196   }
00197   WPXBinaryData m_data;
00198   TextFormat m_format;
00199 };
00200 
00201 } // namespace libvisio
00202 
00203 #endif /* VSDXTYPES_H */
00204 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */