MSPUBTypes.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 libmspub 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 __MSPUBTYPES_H__
00011 #define __MSPUBTYPES_H__
00012 
00013 #include <vector>
00014 #include <string>
00015 #include <boost/optional.hpp>
00016 #include "MSPUBBlockType.h"
00017 #include "MSPUBBlockID.h"
00018 #include "MSPUBContentChunkType.h"
00019 #include "MSPUBConstants.h"
00020 #include "ListInfo.h"
00021 
00022 namespace libmspub
00023 {
00024 enum BorderPosition
00025 {
00026   INSIDE_SHAPE,
00027   HALF_INSIDE_SHAPE,
00028   OUTSIDE_SHAPE
00029 };
00030 
00031 enum SuperSubType
00032 {
00033   NO_SUPER_SUB,
00034   SUPERSCRIPT,
00035   SUBSCRIPT
00036 };
00037 
00038 enum Alignment
00039 {
00040   LEFT = 0,
00041   CENTER = 2,
00042   RIGHT = 1,
00043   JUSTIFY = 6
00044 };
00045 
00046 struct EscherContainerInfo
00047 {
00048   unsigned short initial;
00049   unsigned short type;
00050   unsigned long contentsLength;
00051   unsigned long contentsOffset;
00052 };
00053 
00054 struct MSPUBBlockInfo
00055 {
00056   MSPUBBlockInfo() : id((MSPUBBlockID)0), type((MSPUBBlockType)0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
00057   MSPUBBlockID id;
00058   MSPUBBlockType type;
00059   unsigned long startPosition;
00060   unsigned long dataOffset;
00061   unsigned long dataLength;
00062   unsigned data;
00063   std::vector<unsigned char> stringData;
00064 };
00065 
00066 struct ContentChunkReference
00067 {
00068   ContentChunkReference() : type((MSPUBContentChunkType)0), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
00069   ContentChunkReference(MSPUBContentChunkType t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
00070     type(t), offset(o), end(e), seqNum(sn), parentSeqNum(psn) {}
00071   MSPUBContentChunkType type;
00072   unsigned long offset;
00073   unsigned long end; //offset of the last element plus one.
00074   unsigned seqNum;
00075   unsigned parentSeqNum;
00076 };
00077 
00078 struct QuillChunkReference
00079 {
00080   QuillChunkReference() : length(0), offset(0), id(0), name(), name2() { }
00081   unsigned long length;
00082   unsigned long offset;
00083   unsigned short id;
00084   std::string name;
00085   std::string name2;
00086 };
00087 
00088 struct CharacterStyle
00089 {
00090   CharacterStyle() :
00091     underline(), italic(), bold(),
00092     textSizeInPt(), colorIndex(-1), fontIndex(), superSubType(NO_SUPER_SUB)
00093   {
00094   }
00095   CharacterStyle(bool u, bool i, bool b,
00096                  boost::optional<double> tSIP = boost::optional<double>(),
00097                  int cI = -1,
00098                  boost::optional<unsigned> fI = boost::optional<unsigned>(),
00099                  SuperSubType sst = NO_SUPER_SUB) :
00100     underline(u), italic(i), bold(b), textSizeInPt(tSIP), colorIndex(cI), fontIndex(fI), superSubType(sst) { }
00101   bool underline;
00102   bool italic;
00103   bool bold;
00104   boost::optional<double> textSizeInPt;
00105   int colorIndex;
00106   boost::optional<unsigned> fontIndex;
00107   SuperSubType superSubType;
00108 };
00109 
00110 enum LineSpacingType
00111 {
00112   LINE_SPACING_SP,
00113   LINE_SPACING_PT
00114 };
00115 
00116 struct LineSpacingInfo
00117 {
00118   LineSpacingType m_type;
00119   double m_amount;
00120   LineSpacingInfo() : m_type(LINE_SPACING_SP), m_amount(1)
00121   {
00122   }
00123   LineSpacingInfo(LineSpacingType type, double amount) :
00124     m_type(type), m_amount(amount)
00125   {
00126   }
00127 };
00128 
00129 struct ParagraphStyle
00130 {
00131   boost::optional<Alignment> m_align;
00132   boost::optional<unsigned> m_defaultCharStyleIndex;
00133   boost::optional<LineSpacingInfo> m_lineSpacing;
00134   boost::optional<unsigned> m_spaceBeforeEmu;
00135   boost::optional<unsigned> m_spaceAfterEmu;
00136   boost::optional<int> m_firstLineIndentEmu;
00137   boost::optional<unsigned> m_leftIndentEmu;
00138   boost::optional<unsigned> m_rightIndentEmu;
00139   boost::optional<ListInfo> m_listInfo;
00140   std::vector<unsigned> m_tabStopsInEmu;
00141   boost::optional<unsigned> m_dropCapLines;
00142   boost::optional<unsigned> m_dropCapLetters;
00143   ParagraphStyle() :
00144     m_align(), m_defaultCharStyleIndex(), m_lineSpacing(), m_spaceBeforeEmu(),
00145     m_spaceAfterEmu(), m_firstLineIndentEmu(), m_leftIndentEmu(),
00146     m_rightIndentEmu(), m_listInfo(), m_tabStopsInEmu(), m_dropCapLines(), m_dropCapLetters()
00147   {
00148   }
00149 };
00150 
00151 struct TextSpan
00152 {
00153   TextSpan(const std::vector<unsigned char> &c, const CharacterStyle &s) : chars(c), style(s) { }
00154   std::vector<unsigned char> chars;
00155   CharacterStyle style;
00156 };
00157 
00158 struct TextParagraph
00159 {
00160   TextParagraph(const std::vector<TextSpan> &sp, const ParagraphStyle &st) : spans(sp), style(st) { }
00161   std::vector<TextSpan> spans;
00162   ParagraphStyle style;
00163 };
00164 
00165 struct Color
00166 {
00167   Color() : r(0), g(0), b(0) { }
00168   Color(unsigned char red, unsigned char green, unsigned char blue) : r(red), g(green), b(blue) { }
00169   unsigned char r, g, b;
00170 };
00171 
00172 enum PageType
00173 {
00174   MASTER,
00175   NORMAL,
00176   DUMMY_PAGE
00177 };
00178 
00179 enum ImgType
00180 {
00181   UNKNOWN,
00182   PNG,
00183   JPEG,
00184   WMF,
00185   EMF,
00186   TIFF,
00187   DIB,
00188   PICT,
00189   JPEGCMYK
00190 };
00191 
00192 } // namespace libmspub
00193 
00194 #endif /* __MSPUBTYPES_H__ */
00195 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */