Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* libmspub
3 : * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
17 : * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
18 : *
19 : * All Rights Reserved.
20 : *
21 : * For minor contributions see the git repository.
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25 : * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26 : * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27 : * instead of those above.
28 : */
29 :
30 : #ifndef __MSPUBTYPES_H__
31 : #define __MSPUBTYPES_H__
32 :
33 : #include <vector>
34 : #include <string>
35 : #include <boost/optional.hpp>
36 : #include "MSPUBBlockType.h"
37 : #include "MSPUBBlockID.h"
38 : #include "MSPUBContentChunkType.h"
39 : #include "MSPUBConstants.h"
40 : #include "ListInfo.h"
41 :
42 : namespace libmspub
43 : {
44 : enum BorderPosition
45 : {
46 : INSIDE_SHAPE,
47 : HALF_INSIDE_SHAPE,
48 : OUTSIDE_SHAPE
49 : };
50 :
51 : enum SuperSubType
52 : {
53 : NO_SUPER_SUB,
54 : SUPERSCRIPT,
55 : SUBSCRIPT
56 : };
57 :
58 : enum Alignment
59 : {
60 : LEFT = 0,
61 : CENTER = 2,
62 : RIGHT = 1,
63 : JUSTIFY = 6
64 : };
65 :
66 : struct EscherContainerInfo
67 : {
68 : unsigned short initial;
69 : unsigned short type;
70 : unsigned long contentsLength;
71 : unsigned long contentsOffset;
72 : };
73 :
74 0 : struct MSPUBBlockInfo
75 : {
76 0 : MSPUBBlockInfo() : id((MSPUBBlockID)0), type((MSPUBBlockType)0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
77 : MSPUBBlockID id;
78 : MSPUBBlockType type;
79 : unsigned long startPosition;
80 : unsigned long dataOffset;
81 : unsigned long dataLength;
82 : unsigned data;
83 : std::vector<unsigned char> stringData;
84 : };
85 :
86 : struct ContentChunkReference
87 : {
88 : ContentChunkReference() : type((MSPUBContentChunkType)0), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
89 0 : ContentChunkReference(MSPUBContentChunkType t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
90 0 : type(t), offset(o), end(e), seqNum(sn), parentSeqNum(psn) {}
91 : MSPUBContentChunkType type;
92 : unsigned long offset;
93 : unsigned long end; //offset of the last element plus one.
94 : unsigned seqNum;
95 : unsigned parentSeqNum;
96 : };
97 :
98 0 : struct QuillChunkReference
99 : {
100 0 : QuillChunkReference() : length(0), offset(0), id(0), name(), name2() { }
101 : unsigned long length;
102 : unsigned long offset;
103 : unsigned short id;
104 : std::string name;
105 : std::string name2;
106 : };
107 :
108 0 : struct CharacterStyle
109 : {
110 0 : CharacterStyle() :
111 : underline(), italic(), bold(),
112 0 : textSizeInPt(), colorIndex(-1), fontIndex(), superSubType(NO_SUPER_SUB)
113 : {
114 0 : }
115 0 : CharacterStyle(bool u, bool i, bool b,
116 : boost::optional<double> tSIP = boost::optional<double>(),
117 : int cI = -1,
118 : boost::optional<unsigned> fI = boost::optional<unsigned>(),
119 : SuperSubType sst = NO_SUPER_SUB) :
120 0 : underline(u), italic(i), bold(b), textSizeInPt(tSIP), colorIndex(cI), fontIndex(fI), superSubType(sst) { }
121 : bool underline;
122 : bool italic;
123 : bool bold;
124 : boost::optional<double> textSizeInPt;
125 : int colorIndex;
126 : boost::optional<unsigned> fontIndex;
127 : SuperSubType superSubType;
128 : };
129 :
130 : enum LineSpacingType
131 : {
132 : LINE_SPACING_SP,
133 : LINE_SPACING_PT
134 : };
135 :
136 : struct LineSpacingInfo
137 : {
138 : LineSpacingType m_type;
139 : double m_amount;
140 0 : LineSpacingInfo() : m_type(LINE_SPACING_SP), m_amount(1)
141 : {
142 0 : }
143 0 : LineSpacingInfo(LineSpacingType type, double amount) :
144 0 : m_type(type), m_amount(amount)
145 : {
146 0 : }
147 : };
148 :
149 0 : struct ParagraphStyle
150 : {
151 : boost::optional<Alignment> m_align;
152 : boost::optional<unsigned> m_defaultCharStyleIndex;
153 : boost::optional<LineSpacingInfo> m_lineSpacing;
154 : boost::optional<unsigned> m_spaceBeforeEmu;
155 : boost::optional<unsigned> m_spaceAfterEmu;
156 : boost::optional<int> m_firstLineIndentEmu;
157 : boost::optional<unsigned> m_leftIndentEmu;
158 : boost::optional<unsigned> m_rightIndentEmu;
159 : boost::optional<ListInfo> m_listInfo;
160 : std::vector<unsigned> m_tabStopsInEmu;
161 0 : ParagraphStyle() :
162 : m_align(), m_defaultCharStyleIndex(), m_lineSpacing(), m_spaceBeforeEmu(),
163 : m_spaceAfterEmu(), m_firstLineIndentEmu(), m_leftIndentEmu(),
164 0 : m_rightIndentEmu(), m_listInfo(), m_tabStopsInEmu()
165 : {
166 0 : }
167 : };
168 :
169 0 : struct TextSpan
170 : {
171 0 : TextSpan(std::vector<unsigned char> c, CharacterStyle s) : chars(c), style(s) { }
172 : std::vector<unsigned char> chars;
173 : CharacterStyle style;
174 : };
175 :
176 0 : struct TextParagraph
177 : {
178 0 : TextParagraph(std::vector<TextSpan> sp, ParagraphStyle st) : spans(sp), style(st) { }
179 : std::vector<TextSpan> spans;
180 : ParagraphStyle style;
181 : };
182 :
183 : struct Color
184 : {
185 0 : Color() : r(0), g(0), b(0) { }
186 0 : Color(unsigned char red, unsigned char green, unsigned char blue) : r(red), g(green), b(blue) { }
187 : unsigned char r, g, b;
188 : };
189 :
190 : enum PageType
191 : {
192 : MASTER,
193 : NORMAL,
194 : DUMMY_PAGE
195 : };
196 :
197 : enum ImgType
198 : {
199 : UNKNOWN,
200 : PNG,
201 : JPEG,
202 : WMF,
203 : EMF,
204 : TIFF,
205 : DIB,
206 : PICT
207 : };
208 :
209 : } // namespace libmspub
210 :
211 : #endif /* __MSPUBTYPES_H__ */
212 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|