1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libmspub project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_MSPUBTYPES_H
11 #define INCLUDED_MSPUBTYPES_H
12 
13 #include <string>
14 #include <vector>
15 
16 #include <boost/optional.hpp>
17 
18 #include "ListInfo.h"
19 #include "MSPUBBlockID.h"
20 #include "MSPUBBlockType.h"
21 #include "MSPUBConstants.h"
22 #include "MSPUBContentChunkType.h"
23 
24 namespace libmspub
25 {
26 enum BorderPosition
27 {
28   INSIDE_SHAPE,
29   HALF_INSIDE_SHAPE,
30   OUTSIDE_SHAPE
31 };
32 
33 enum SuperSubType
34 {
35   NO_SUPER_SUB,
36   SUPERSCRIPT,
37   SUBSCRIPT
38 };
39 
40 enum class Underline
41 {
42   None,
43   Single,
44   WordsOnly,
45   Double,
46   Dotted,
47   Thick,
48   Dash,
49   DotDash,
50   DotDotDash,
51   Wave,
52   ThickWave,
53   ThickDot,
54   ThickDash,
55   ThickDotDash,
56   ThickDotDotDash,
57   LongDash,
58   ThickLongDash,
59   DoubleWave,
60 };
61 
62 enum Alignment
63 {
64   LEFT = 0,
65   CENTER = 2,
66   RIGHT = 1,
67   JUSTIFY = 6
68 };
69 
70 struct EscherContainerInfo
71 {
72   unsigned short initial;
73   unsigned short type;
74   unsigned long contentsLength;
75   unsigned long contentsOffset;
76 };
77 
78 struct MSPUBBlockInfo
79 {
MSPUBBlockInfoMSPUBBlockInfo80   MSPUBBlockInfo() : id(0), type(0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
81   unsigned id;
82   unsigned type;
83   unsigned long startPosition;
84   unsigned long dataOffset;
85   unsigned long dataLength;
86   unsigned data;
87   std::vector<unsigned char> stringData;
88 };
89 
90 struct ContentChunkReference
91 {
ContentChunkReferenceContentChunkReference92   ContentChunkReference() : type(0), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
ContentChunkReferenceContentChunkReference93   ContentChunkReference(unsigned t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
94     type(t), offset(o), end(e), seqNum(sn), parentSeqNum(psn) {}
95   unsigned type;
96   unsigned long offset;
97   unsigned long end; //offset of the last element plus one.
98   unsigned seqNum;
99   unsigned parentSeqNum;
100 };
101 
102 struct QuillChunkReference
103 {
QuillChunkReferenceQuillChunkReference104   QuillChunkReference() : length(0), offset(0), id(0), name(), name2() { }
105   unsigned long length;
106   unsigned long offset;
107   unsigned short id;
108   std::string name;
109   std::string name2;
110 };
111 
112 struct CharacterStyle
113 {
CharacterStyleCharacterStyle114   CharacterStyle() :
115     underline(), italic(), bold(),
116     textSizeInPt(), colorIndex(-1), fontIndex(), superSubType(NO_SUPER_SUB)
117     , outline(false)
118     , shadow(false)
119     , smallCaps(false)
120     , allCaps(false)
121     , emboss(false)
122     , engrave(false)
123     , textScale()
124     , lcid()
125   {
126   }
127   boost::optional<Underline> underline;
128   bool italic;
129   bool bold;
130   boost::optional<double> textSizeInPt;
131   int colorIndex;
132   boost::optional<unsigned> fontIndex;
133   SuperSubType superSubType;
134   bool outline;
135   bool shadow;
136   bool smallCaps;
137   bool allCaps;
138   bool emboss;
139   bool engrave;
140   boost::optional<double> textScale;
141   boost::optional<unsigned> lcid;
142 };
143 
144 enum LineSpacingType
145 {
146   LINE_SPACING_SP,
147   LINE_SPACING_PT
148 };
149 
150 struct LineSpacingInfo
151 {
152   LineSpacingType m_type;
153   double m_amount;
LineSpacingInfoLineSpacingInfo154   LineSpacingInfo() : m_type(LINE_SPACING_SP), m_amount(1)
155   {
156   }
LineSpacingInfoLineSpacingInfo157   LineSpacingInfo(LineSpacingType type, double amount) :
158     m_type(type), m_amount(amount)
159   {
160   }
161 };
162 
163 struct ParagraphStyle
164 {
165   boost::optional<Alignment> m_align;
166   boost::optional<unsigned> m_defaultCharStyleIndex;
167   boost::optional<LineSpacingInfo> m_lineSpacing;
168   boost::optional<unsigned> m_spaceBeforeEmu;
169   boost::optional<unsigned> m_spaceAfterEmu;
170   boost::optional<int> m_firstLineIndentEmu;
171   boost::optional<unsigned> m_leftIndentEmu;
172   boost::optional<unsigned> m_rightIndentEmu;
173   boost::optional<ListInfo> m_listInfo;
174   std::vector<unsigned> m_tabStopsInEmu;
175   boost::optional<unsigned> m_dropCapLines;
176   boost::optional<unsigned> m_dropCapLetters;
ParagraphStyleParagraphStyle177   ParagraphStyle() :
178     m_align(), m_defaultCharStyleIndex(), m_lineSpacing(), m_spaceBeforeEmu(),
179     m_spaceAfterEmu(), m_firstLineIndentEmu(), m_leftIndentEmu(),
180     m_rightIndentEmu(), m_listInfo(), m_tabStopsInEmu(), m_dropCapLines(), m_dropCapLetters()
181   {
182   }
183 };
184 
185 struct TextSpan
186 {
TextSpanTextSpan187   TextSpan(const std::vector<unsigned char> &c, const CharacterStyle &s) : chars(c), style(s) { }
188   std::vector<unsigned char> chars;
189   CharacterStyle style;
190 };
191 
192 struct TextParagraph
193 {
TextParagraphTextParagraph194   TextParagraph(const std::vector<TextSpan> &sp, const ParagraphStyle &st) : spans(sp), style(st) { }
195   std::vector<TextSpan> spans;
196   ParagraphStyle style;
197 };
198 
199 struct Color
200 {
ColorColor201   Color() : r(0), g(0), b(0) { }
ColorColor202   Color(unsigned char red, unsigned char green, unsigned char blue) : r(red), g(green), b(blue) { }
203   unsigned char r, g, b;
204 };
205 
206 enum PageType
207 {
208   MASTER,
209   NORMAL,
210   DUMMY_PAGE
211 };
212 
213 enum ImgType
214 {
215   UNKNOWN,
216   PNG,
217   JPEG,
218   WMF,
219   EMF,
220   TIFF,
221   DIB,
222   PICT,
223   JPEGCMYK
224 };
225 
226 } // namespace libmspub
227 
228 #endif /* INCLUDED_MSPUBTYPES_H */
229 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
230