MSPUBTypes.h Source File documentation

MSPUBTypes.h
Go to the documentation of this file.
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 {
80 MSPUBBlockInfo() : id((MSPUBBlockID)0), type((MSPUBBlockType)0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
81 MSPUBBlockID id;
82 MSPUBBlockType 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 {
92 ContentChunkReference() : type(UNKNOWN_CHUNK), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
93 ContentChunkReference(MSPUBContentChunkType t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
94 type(t), offset(o), end(e), seqNum(sn), parentSeqNum(psn) {}
95 MSPUBContentChunkType 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 {
104 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 {
114 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;
154 LineSpacingInfo() : m_type(LINE_SPACING_SP), m_amount(1)
155 {
156 }
157 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;
177 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 {
187 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 {
194 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 {
201 Color() : r(0), g(0), b(0) { }
202 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: */
libmspub::MASTER
Definition: MSPUBTypes.h:208
libmspub::JUSTIFY
Definition: MSPUBTypes.h:67
libmspub::EscherContainerInfo::initial
unsigned short initial
Definition: MSPUBTypes.h:72
libmspub::HALF_INSIDE_SHAPE
Definition: MSPUBTypes.h:29
libmspub::ContentChunkReference::offset
unsigned long offset
Definition: MSPUBTypes.h:96
libmspub::TextParagraph
Definition: MSPUBTypes.h:192
libmspub::TextParagraph::TextParagraph
TextParagraph(const std::vector< TextSpan > &sp, const ParagraphStyle &st)
Definition: MSPUBTypes.h:194
libmspub::MSPUBContentChunkType
MSPUBContentChunkType
Definition: MSPUBContentChunkType.h:15
MSPUBContentChunkType.h
libmspub::EscherContainerInfo::contentsLength
unsigned long contentsLength
Definition: MSPUBTypes.h:74
libmspub::Underline::DotDotDash
MSPUBConstants.h
libmspub::Color
Definition: MSPUBTypes.h:199
libmspub::CharacterStyle::colorIndex
int colorIndex
Definition: MSPUBTypes.h:131
libmspub::CharacterStyle::emboss
bool emboss
Definition: MSPUBTypes.h:138
libmspub::SuperSubType
SuperSubType
Definition: MSPUBTypes.h:33
libmspub::Underline::ThickWave
libmspub::TextSpan
Definition: MSPUBTypes.h:185
libmspub::LineSpacingInfo::m_amount
double m_amount
Definition: MSPUBTypes.h:153
libmspub::ContentChunkReference::seqNum
unsigned seqNum
Definition: MSPUBTypes.h:98
libmspub::JPEG
Definition: MSPUBTypes.h:217
libmspub::CharacterStyle::textScale
boost::optional< double > textScale
Definition: MSPUBTypes.h:140
libmspub::OUTSIDE_SHAPE
Definition: MSPUBTypes.h:30
libmspub::TextParagraph::style
ParagraphStyle style
Definition: MSPUBTypes.h:196
libmspub::LEFT
Definition: MSPUBTypes.h:64
libmspub::CharacterStyle::outline
bool outline
Definition: MSPUBTypes.h:134
libmspub::QuillChunkReference::name2
std::string name2
Definition: MSPUBTypes.h:109
libmspub::WMF
Definition: MSPUBTypes.h:218
ListInfo.h
libmspub::LINE_SPACING_SP
Definition: MSPUBTypes.h:146
libmspub::CharacterStyle::bold
bool bold
Definition: MSPUBTypes.h:129
libmspub::Color::Color
Color(unsigned char red, unsigned char green, unsigned char blue)
Definition: MSPUBTypes.h:202
libmspub::TextSpan::style
CharacterStyle style
Definition: MSPUBTypes.h:189
libmspub::TextSpan::TextSpan
TextSpan(const std::vector< unsigned char > &c, const CharacterStyle &s)
Definition: MSPUBTypes.h:187
libmspub::ParagraphStyle::m_defaultCharStyleIndex
boost::optional< unsigned > m_defaultCharStyleIndex
Definition: MSPUBTypes.h:166
libmspub::MSPUBBlockInfo
Definition: MSPUBTypes.h:78
libmspub::LineSpacingType
LineSpacingType
Definition: MSPUBTypes.h:144
libmspub::Color::r
unsigned char r
Definition: MSPUBTypes.h:203
libmspub::DIB
Definition: MSPUBTypes.h:221
libmspub::MSPUBBlockInfo::type
MSPUBBlockType type
Definition: MSPUBTypes.h:82
libmspub::MSPUBBlockInfo::MSPUBBlockInfo
MSPUBBlockInfo()
Definition: MSPUBTypes.h:80
libmspub::MSPUBBlockInfo::dataOffset
unsigned long dataOffset
Definition: MSPUBTypes.h:84
libmspub::ParagraphStyle::m_dropCapLines
boost::optional< unsigned > m_dropCapLines
Definition: MSPUBTypes.h:175
libmspub::BorderPosition
BorderPosition
Definition: MSPUBTypes.h:26
libmspub::SUBSCRIPT
Definition: MSPUBTypes.h:37
libmspub::Underline::LongDash
libmspub::QuillChunkReference::name
std::string name
Definition: MSPUBTypes.h:108
libmspub::EMF
Definition: MSPUBTypes.h:219
libmspub::TextSpan::chars
std::vector< unsigned char > chars
Definition: MSPUBTypes.h:188
libmspub::CENTER
Definition: MSPUBTypes.h:65
libmspub::Underline::Double
libmspub::Underline::None
libmspub::INSIDE_SHAPE
Definition: MSPUBTypes.h:28
libmspub::ContentChunkReference::type
MSPUBContentChunkType type
Definition: MSPUBTypes.h:95
MSPUBBlockType.h
libmspub::TIFF
Definition: MSPUBTypes.h:220
libmspub::CharacterStyle::lcid
boost::optional< unsigned > lcid
Definition: MSPUBTypes.h:141
libmspub::ParagraphStyle::m_spaceAfterEmu
boost::optional< unsigned > m_spaceAfterEmu
Definition: MSPUBTypes.h:169
libmspub::ParagraphStyle::m_align
boost::optional< Alignment > m_align
Definition: MSPUBTypes.h:165
libmspub::LineSpacingInfo
Definition: MSPUBTypes.h:150
libmspub::EscherContainerInfo::type
unsigned short type
Definition: MSPUBTypes.h:73
libmspub::Underline::ThickDotDotDash
libmspub::ContentChunkReference
Definition: MSPUBTypes.h:90
libmspub::Underline::Dotted
libmspub::MSPUBBlockType
MSPUBBlockType
Definition: MSPUBBlockType.h:15
libmspub::ParagraphStyle::m_rightIndentEmu
boost::optional< unsigned > m_rightIndentEmu
Definition: MSPUBTypes.h:172
libmspub::ParagraphStyle::m_tabStopsInEmu
std::vector< unsigned > m_tabStopsInEmu
Definition: MSPUBTypes.h:174
libmspub::SUPERSCRIPT
Definition: MSPUBTypes.h:36
libmspub::Alignment
Alignment
Definition: MSPUBTypes.h:62
libmspub::ContentChunkReference::parentSeqNum
unsigned parentSeqNum
Definition: MSPUBTypes.h:99
libmspub::UNKNOWN
Definition: MSPUBTypes.h:215
libmspub::ParagraphStyle::m_listInfo
boost::optional< ListInfo > m_listInfo
Definition: MSPUBTypes.h:173
libmspub::NO_SUPER_SUB
Definition: MSPUBTypes.h:35
libmspub::ParagraphStyle::m_spaceBeforeEmu
boost::optional< unsigned > m_spaceBeforeEmu
Definition: MSPUBTypes.h:168
libmspub::PageType
PageType
Definition: MSPUBTypes.h:206
libmspub::ImgType
ImgType
Definition: MSPUBTypes.h:213
libmspub::MSPUBBlockInfo::stringData
std::vector< unsigned char > stringData
Definition: MSPUBTypes.h:87
libmspub::QuillChunkReference::QuillChunkReference
QuillChunkReference()
Definition: MSPUBTypes.h:104
libmspub::JPEGCMYK
Definition: MSPUBTypes.h:223
libmspub::ParagraphStyle::m_firstLineIndentEmu
boost::optional< int > m_firstLineIndentEmu
Definition: MSPUBTypes.h:170
MSPUBBlockID.h
libmspub::ContentChunkReference::ContentChunkReference
ContentChunkReference(MSPUBContentChunkType t, unsigned long o, unsigned long e, unsigned sn, unsigned psn)
Definition: MSPUBTypes.h:93
libmspub::CharacterStyle::allCaps
bool allCaps
Definition: MSPUBTypes.h:137
libmspub::MSPUBBlockInfo::dataLength
unsigned long dataLength
Definition: MSPUBTypes.h:85
libmspub::EscherContainerInfo
Definition: MSPUBTypes.h:70
libmspub::CharacterStyle::textSizeInPt
boost::optional< double > textSizeInPt
Definition: MSPUBTypes.h:130
libmspub::QuillChunkReference::id
unsigned short id
Definition: MSPUBTypes.h:107
libmspub::Underline::ThickDash
libmspub::CharacterStyle::engrave
bool engrave
Definition: MSPUBTypes.h:139
libmspub::CharacterStyle::shadow
bool shadow
Definition: MSPUBTypes.h:135
libmspub::Underline::ThickLongDash
libmspub::CharacterStyle::fontIndex
boost::optional< unsigned > fontIndex
Definition: MSPUBTypes.h:132
libmspub::Underline::DotDash
libmspub::PNG
Definition: MSPUBTypes.h:216
libmspub::ParagraphStyle
Definition: MSPUBTypes.h:163
libmspub::RIGHT
Definition: MSPUBTypes.h:66
libmspub
Definition: Arrow.h:13
libmspub::CharacterStyle::underline
boost::optional< Underline > underline
Definition: MSPUBTypes.h:127
libmspub::LINE_SPACING_PT
Definition: MSPUBTypes.h:147
libmspub::QuillChunkReference::length
unsigned long length
Definition: MSPUBTypes.h:105
libmspub::Underline
Underline
Definition: MSPUBTypes.h:40
libmspub::Underline::WordsOnly
libmspub::QuillChunkReference
Definition: MSPUBTypes.h:102
libmspub::Underline::ThickDot
libmspub::Underline::Wave
libmspub::ParagraphStyle::m_lineSpacing
boost::optional< LineSpacingInfo > m_lineSpacing
Definition: MSPUBTypes.h:167
libmspub::Underline::Single
libmspub::CharacterStyle
Definition: MSPUBTypes.h:112
libmspub::ParagraphStyle::m_leftIndentEmu
boost::optional< unsigned > m_leftIndentEmu
Definition: MSPUBTypes.h:171
libmspub::EscherContainerInfo::contentsOffset
unsigned long contentsOffset
Definition: MSPUBTypes.h:75
libmspub::MSPUBBlockInfo::id
MSPUBBlockID id
Definition: MSPUBTypes.h:81
libmspub::TextParagraph::spans
std::vector< TextSpan > spans
Definition: MSPUBTypes.h:195
libmspub::Underline::Thick
libmspub::CharacterStyle::smallCaps
bool smallCaps
Definition: MSPUBTypes.h:136
libmspub::Underline::DoubleWave
libmspub::CharacterStyle::italic
bool italic
Definition: MSPUBTypes.h:128
libmspub::Color::Color
Color()
Definition: MSPUBTypes.h:201
libmspub::DUMMY_PAGE
Definition: MSPUBTypes.h:210
libmspub::Underline::Dash
libmspub::ContentChunkReference::end
unsigned long end
Definition: MSPUBTypes.h:97
libmspub::LineSpacingInfo::LineSpacingInfo
LineSpacingInfo()
Definition: MSPUBTypes.h:154
libmspub::MSPUBBlockID
MSPUBBlockID
Definition: MSPUBBlockID.h:15
libmspub::ContentChunkReference::ContentChunkReference
ContentChunkReference()
Definition: MSPUBTypes.h:92
libmspub::MSPUBBlockInfo::data
unsigned data
Definition: MSPUBTypes.h:86
libmspub::LineSpacingInfo::m_type
LineSpacingType m_type
Definition: MSPUBTypes.h:152
libmspub::NORMAL
Definition: MSPUBTypes.h:209
libmspub::Underline::ThickDotDash
libmspub::PICT
Definition: MSPUBTypes.h:222
libmspub::ParagraphStyle::m_dropCapLetters
boost::optional< unsigned > m_dropCapLetters
Definition: MSPUBTypes.h:176
libmspub::MSPUBBlockInfo::startPosition
unsigned long startPosition
Definition: MSPUBTypes.h:83
libmspub::CharacterStyle::CharacterStyle
CharacterStyle()
Definition: MSPUBTypes.h:114
libmspub::UNKNOWN_CHUNK
Definition: MSPUBContentChunkType.h:17
libmspub::CharacterStyle::superSubType
SuperSubType superSubType
Definition: MSPUBTypes.h:133
libmspub::QuillChunkReference::offset
unsigned long offset
Definition: MSPUBTypes.h:106
libmspub::LineSpacingInfo::LineSpacingInfo
LineSpacingInfo(LineSpacingType type, double amount)
Definition: MSPUBTypes.h:157
libmspub::ParagraphStyle::ParagraphStyle
ParagraphStyle()
Definition: MSPUBTypes.h:177