MSPUBTypes.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libmspub
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) 2012 Brennan Vincent <brennanv@email.arizona.edu>
00017  * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
00018  *
00019  * All Rights Reserved.
00020  *
00021  * For minor contributions see the git repository.
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00025  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00026  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00027  * instead of those above.
00028  */
00029 
00030 #ifndef __MSPUBTYPES_H__
00031 #define __MSPUBTYPES_H__
00032 
00033 #include <vector>
00034 #include <string>
00035 #include <boost/optional.hpp>
00036 #include "MSPUBBlockType.h"
00037 #include "MSPUBBlockID.h"
00038 #include "MSPUBContentChunkType.h"
00039 #include "MSPUBConstants.h"
00040 #include "ListInfo.h"
00041 
00042 namespace libmspub
00043 {
00044 enum BorderPosition
00045 {
00046   INSIDE_SHAPE,
00047   HALF_INSIDE_SHAPE,
00048   OUTSIDE_SHAPE
00049 };
00050 
00051 enum SuperSubType
00052 {
00053   NO_SUPER_SUB,
00054   SUPERSCRIPT,
00055   SUBSCRIPT
00056 };
00057 
00058 enum Alignment
00059 {
00060   LEFT = 0,
00061   CENTER = 2,
00062   RIGHT = 1,
00063   JUSTIFY = 6
00064 };
00065 
00066 struct EscherContainerInfo
00067 {
00068   unsigned short initial;
00069   unsigned short type;
00070   unsigned long contentsLength;
00071   unsigned long contentsOffset;
00072 };
00073 
00074 struct MSPUBBlockInfo
00075 {
00076   MSPUBBlockInfo() : id((MSPUBBlockID)0), type((MSPUBBlockType)0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
00077   MSPUBBlockID id;
00078   MSPUBBlockType type;
00079   unsigned long startPosition;
00080   unsigned long dataOffset;
00081   unsigned long dataLength;
00082   unsigned data;
00083   std::vector<unsigned char> stringData;
00084 };
00085 
00086 struct ContentChunkReference
00087 {
00088   ContentChunkReference() : type((MSPUBContentChunkType)0), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
00089   ContentChunkReference(MSPUBContentChunkType t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
00090     type(t), offset(o), end(e), seqNum(sn), parentSeqNum(psn) {}
00091   MSPUBContentChunkType type;
00092   unsigned long offset;
00093   unsigned long end; //offset of the last element plus one.
00094   unsigned seqNum;
00095   unsigned parentSeqNum;
00096 };
00097 
00098 struct QuillChunkReference
00099 {
00100   QuillChunkReference() : length(0), offset(0), id(0), name(), name2() { }
00101   unsigned long length;
00102   unsigned long offset;
00103   unsigned short id;
00104   std::string name;
00105   std::string name2;
00106 };
00107 
00108 struct CharacterStyle
00109 {
00110   CharacterStyle() :
00111     underline(), italic(), bold(),
00112     textSizeInPt(), colorIndex(-1), fontIndex(), superSubType(NO_SUPER_SUB)
00113   {
00114   }
00115   CharacterStyle(bool u, bool i, bool b,
00116                  boost::optional<double> tSIP = boost::optional<double>(),
00117                  int cI = -1,
00118                  boost::optional<unsigned> fI = boost::optional<unsigned>(),
00119                  SuperSubType sst = NO_SUPER_SUB) :
00120     underline(u), italic(i), bold(b), textSizeInPt(tSIP), colorIndex(cI), fontIndex(fI), superSubType(sst) { }
00121   bool underline;
00122   bool italic;
00123   bool bold;
00124   boost::optional<double> textSizeInPt;
00125   int colorIndex;
00126   boost::optional<unsigned> fontIndex;
00127   SuperSubType superSubType;
00128 };
00129 
00130 enum LineSpacingType
00131 {
00132   LINE_SPACING_SP,
00133   LINE_SPACING_PT
00134 };
00135 
00136 struct LineSpacingInfo
00137 {
00138   LineSpacingType m_type;
00139   double m_amount;
00140   LineSpacingInfo() : m_type(LINE_SPACING_SP), m_amount(1)
00141   {
00142   }
00143   LineSpacingInfo(LineSpacingType type, double amount) :
00144     m_type(type), m_amount(amount)
00145   {
00146   }
00147 };
00148 
00149 struct ParagraphStyle
00150 {
00151   boost::optional<Alignment> m_align;
00152   boost::optional<unsigned> m_defaultCharStyleIndex;
00153   boost::optional<LineSpacingInfo> m_lineSpacing;
00154   boost::optional<unsigned> m_spaceBeforeEmu;
00155   boost::optional<unsigned> m_spaceAfterEmu;
00156   boost::optional<int> m_firstLineIndentEmu;
00157   boost::optional<unsigned> m_leftIndentEmu;
00158   boost::optional<unsigned> m_rightIndentEmu;
00159   boost::optional<ListInfo> m_listInfo;
00160   std::vector<unsigned> m_tabStopsInEmu;
00161   boost::optional<unsigned> m_dropCapLines;
00162   boost::optional<unsigned> m_dropCapLetters;
00163   ParagraphStyle() :
00164     m_align(), m_defaultCharStyleIndex(), m_lineSpacing(), m_spaceBeforeEmu(),
00165     m_spaceAfterEmu(), m_firstLineIndentEmu(), m_leftIndentEmu(),
00166     m_rightIndentEmu(), m_listInfo(), m_tabStopsInEmu(), m_dropCapLines(), m_dropCapLetters()
00167   {
00168   }
00169 };
00170 
00171 struct TextSpan
00172 {
00173   TextSpan(const std::vector<unsigned char> &c, const CharacterStyle &s) : chars(c), style(s) { }
00174   std::vector<unsigned char> chars;
00175   CharacterStyle style;
00176 };
00177 
00178 struct TextParagraph
00179 {
00180   TextParagraph(const std::vector<TextSpan> &sp, const ParagraphStyle &st) : spans(sp), style(st) { }
00181   std::vector<TextSpan> spans;
00182   ParagraphStyle style;
00183 };
00184 
00185 struct Color
00186 {
00187   Color() : r(0), g(0), b(0) { }
00188   Color(unsigned char red, unsigned char green, unsigned char blue) : r(red), g(green), b(blue) { }
00189   unsigned char r, g, b;
00190 };
00191 
00192 enum PageType
00193 {
00194   MASTER,
00195   NORMAL,
00196   DUMMY_PAGE
00197 };
00198 
00199 enum ImgType
00200 {
00201   UNKNOWN,
00202   PNG,
00203   JPEG,
00204   WMF,
00205   EMF,
00206   TIFF,
00207   DIB,
00208   PICT,
00209   JPEGCMYK
00210 };
00211 
00212 } // namespace libmspub
00213 
00214 #endif /* __MSPUBTYPES_H__ */
00215 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */