- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

libwpd_internal.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwpd
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Major Contributor(s):
10 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
11 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
19 *
20 * For further information visit http://libwpd.sourceforge.net
21 */
22
23 /* "This product is not manufactured, approved, or supported by
24 * Corel Corporation or Corel Corporation Limited."
25 */
26
27 #ifndef LIBWPD_INTERNAL_H
28 #define LIBWPD_INTERNAL_H
29
30 #include <librevenge/librevenge.h>
31 #include <librevenge-stream/librevenge-stream.h>
32 #include "WPXEncryption.h"
33
34 /* Various functions/defines that need not/should not be exported externally */
35
36 #define DELETEP(m) if (m) { delete m; m = 0; }
37
38 #if defined(__clang__) || defined(__GNUC__)
39 #define WPD_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
40 #else
41 #define WPD_ATTRIBUTE_PRINTF(fmt, arg)
42 #endif
43
44 #ifdef DEBUG
45 namespace libwpd
46 {
47 void debugPrint(const char *format, ...) WPD_ATTRIBUTE_PRINTF(1, 2);
48 }
49
50 #define WPD_DEBUG_MSG(M) libwpd::debugPrint M
51 #else
52 #define WPD_DEBUG_MSG(M)
53 #endif
54
55 #define WPD_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
56
57 // add more of these as needed for byteswapping
58 // (the 8-bit functions are just there to make things consistent)
59 unsigned char readU8(librevenge::RVNGInputStream *input, WPXEncryption *encryption);
60 unsigned short readU16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false);
61 signed short readS16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false);
62 unsigned readU32(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false);
63
64 librevenge::RVNGString readPascalString(librevenge::RVNGInputStream *input, WPXEncryption *encryption);
65 librevenge::RVNGString readCString(librevenge::RVNGInputStream *input, WPXEncryption *encryption);
66
67 void appendUCS4(librevenge::RVNGString &str, unsigned ucs4);
68
69 // Various helper structures for the libwpd parser..
70
71 int extendedCharacterWP6ToUCS4(unsigned char character, unsigned char characterSet,
72 const unsigned **chars);
73
74 int extendedCharacterWP5ToUCS4(unsigned char character, unsigned char characterSet,
75 const unsigned **chars);
76
77 int appleWorldScriptToUCS4(unsigned short character, const unsigned **chars);
78
79 int extendedCharacterWP42ToUCS4(unsigned char character, const unsigned **chars);
80
81 unsigned short fixedPointToWPUs(const unsigned fixedPointNumber);
82 double fixedPointToDouble(const unsigned fixedPointNumber);
83 double wpuToFontPointSize(const unsigned short wpuNumber);
84
85 enum WPXFileType { WP6_DOCUMENT, WP5_DOCUMENT, WP42_DOCUMENT, OTHER };
86 enum WPXNumberingType { ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
87 enum WPXNoteType { FOOTNOTE, ENDNOTE };
88 enum WPXHeaderFooterType { HEADER, FOOTER };
89 enum WPXHeaderFooterInternalType { HEADER_A, HEADER_B, FOOTER_A, FOOTER_B, DUMMY };
90 enum WPXHeaderFooterOccurrence { ODD, EVEN, ALL, NEVER };
91 enum WPXPageNumberPosition { PAGENUMBER_POSITION_NONE = 0, PAGENUMBER_POSITION_TOP_LEFT, PAGENUMBER_POSITION_TOP_CENTER,
92 PAGENUMBER_POSITION_TOP_RIGHT, PAGENUMBER_POSITION_TOP_LEFT_AND_RIGHT,
93 PAGENUMBER_POSITION_BOTTOM_LEFT, PAGENUMBER_POSITION_BOTTOM_CENTER,
94 PAGENUMBER_POSITION_BOTTOM_RIGHT, PAGENUMBER_POSITION_BOTTOM_LEFT_AND_RIGHT,
95 PAGENUMBER_POSITION_TOP_INSIDE_LEFT_AND_RIGHT,
96 PAGENUMBER_POSITION_BOTTOM_INSIDE_LEFT_AND_RIGHT
97 };
98
99 enum WPXFormOrientation { PORTRAIT, LANDSCAPE };
100 enum WPXTabAlignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
101 enum WPXVerticalAlignment { TOP, MIDDLE, BOTTOM, FULL };
102
103 enum WPXTextColumnType { NEWSPAPER, NEWSPAPER_VERTICAL_BALANCE, PARALLEL, PARALLEL_PROTECT };
104
105 enum WPXSubDocumentType { WPX_SUBDOCUMENT_NONE, WPX_SUBDOCUMENT_HEADER_FOOTER, WPX_SUBDOCUMENT_NOTE, WPX_SUBDOCUMENT_TEXT_BOX, WPX_SUBDOCUMENT_COMMENT_ANNOTATION };
106
107 // ATTRIBUTE bits
108 #define WPX_EXTRA_LARGE_BIT 1
109 #define WPX_VERY_LARGE_BIT 2
110 #define WPX_LARGE_BIT 4
111 #define WPX_SMALL_PRINT_BIT 8
112 #define WPX_FINE_PRINT_BIT 16
113 #define WPX_SUPERSCRIPT_BIT 32
114 #define WPX_SUBSCRIPT_BIT 64
115 #define WPX_OUTLINE_BIT 128
116 #define WPX_ITALICS_BIT 256
117 #define WPX_SHADOW_BIT 512
118 #define WPX_REDLINE_BIT 1024
119 #define WPX_DOUBLE_UNDERLINE_BIT 2048
120 #define WPX_BOLD_BIT 4096
121 #define WPX_STRIKEOUT_BIT 8192
122 #define WPX_UNDERLINE_BIT 16384
123 #define WPX_SMALL_CAPS_BIT 32768
124 #define WPX_BLINK_BIT 65536
125 #define WPX_REVERSEVIDEO_BIT 131072
126
127 // JUSTIFICATION bits.
128 #define WPX_PARAGRAPH_JUSTIFICATION_LEFT 0x00
129 #define WPX_PARAGRAPH_JUSTIFICATION_FULL 0x01
130 #define WPX_PARAGRAPH_JUSTIFICATION_CENTER 0x02
131 #define WPX_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
132 #define WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
133 #define WPX_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
134
135 // TABLE POSITION bits.
136 #define WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN 0x00
137 #define WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN 0x01
138 #define WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS 0x02
139 #define WPX_TABLE_POSITION_FULL 0x03
140 #define WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN 0x04
141
142 // TABLE CELL BORDER bits
143 const unsigned char WPX_TABLE_CELL_LEFT_BORDER_OFF = 0x01;
144 const unsigned char WPX_TABLE_CELL_RIGHT_BORDER_OFF = 0x02;
145 const unsigned char WPX_TABLE_CELL_TOP_BORDER_OFF = 0x04;
146 const unsigned char WPX_TABLE_CELL_BOTTOM_BORDER_OFF = 0x08;
147
148 // BREAK bits
149 #define WPX_PAGE_BREAK 0x00
150 #define WPX_SOFT_PAGE_BREAK 0x01
151 #define WPX_COLUMN_BREAK 0x02
152
153 // Generic bits
154 #define WPX_LEFT 0x00
155 #define WPX_RIGHT 0x01
156 #define WPX_CENTER 0x02
157 #define WPX_TOP 0x03
158 #define WPX_BOTTOM 0x04
159
160 struct RGBSColor
161 {
162 RGBSColor(unsigned char r, unsigned char g, unsigned char b, unsigned char s);
163 RGBSColor(unsigned short red, unsigned short green, unsigned short blue); // Construct
164 // RBBSColor from double precision RGB color used by WP3.x for Mac
165 RGBSColor(); // initializes all values to 0
166 unsigned char m_r;
167 unsigned char m_g;
168 unsigned char m_b;
169 unsigned char m_s;
170 };
171
172 struct WPXColumnDefinition
173 {
174 WPXColumnDefinition(); // initializes all values to 0
175 double m_width;
176 double m_leftGutter;
177 double m_rightGutter;
178 };
179
180 struct WPXColumnProperties
181 {
182 WPXColumnProperties();
183 unsigned m_attributes;
184 unsigned char m_alignment;
185 };
186
187 struct WPXTabStop
188 {
189 WPXTabStop();
190 double m_position;
191 WPXTabAlignment m_alignment;
192 unsigned m_leaderCharacter;
193 unsigned char m_leaderNumSpaces;
194 };
195
196 // Various exceptions: libwpd does not propagate exceptions externally..
197
198 class VersionException
199 {
200 };
201
202 class FileException
203 {
204 };
205
206 class ParseException
207 {
208 };
209
210 class GenericException
211 {
212 };
213
214 class UnsupportedEncryptionException
215 {
216 };
217
218 class SupportedEncryptionException
219 {
220 };
221
222 class WrongPasswordException
223 {
224 };
225
226 // Various usefull, but cheesey functions
227
228 int _extractNumericValueFromRoman(const char romanChar);
229 int _extractDisplayReferenceNumberFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType listType);
230 WPXNumberingType _extractWPXNumberingTypeFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType putativeWPXNumberingType);
231 librevenge::RVNGString _numberingTypeToString(WPXNumberingType t);
232 extern const unsigned macRomanCharacterMap[];
233 librevenge::RVNGString doubleToString(const double value);
234
235 #endif /* LIBWPD_INTERNAL_H */
236 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPXNumberingType
WPXNumberingType
Definition: libwpd_internal.h:86
DUMMY
Definition: libwpd_internal.h:89
RGBSColor::m_g
unsigned char m_g
Definition: libwpd_internal.h:167
WPXTabStop::m_alignment
WPXTabAlignment m_alignment
Definition: libwpd_internal.h:191
PARALLEL_PROTECT
Definition: libwpd_internal.h:103
readU8
unsigned char readU8(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
Definition: libwpd_internal.cpp:103
OTHER
Definition: libwpd_internal.h:85
PAGENUMBER_POSITION_TOP_RIGHT
Definition: libwpd_internal.h:92
WPXTabStop
Definition: libwpd_internal.h:187
PAGENUMBER_POSITION_NONE
Definition: libwpd_internal.h:91
PAGENUMBER_POSITION_BOTTOM_RIGHT
Definition: libwpd_internal.h:94
WPXColumnDefinition::m_width
double m_width
Definition: libwpd_internal.h:175
WPXEncryption.h
WPXHeaderFooterInternalType
WPXHeaderFooterInternalType
Definition: libwpd_internal.h:89
RGBSColor::m_r
unsigned char m_r
Definition: libwpd_internal.h:166
readU16
unsigned short readU16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false)
Definition: libwpd_internal.cpp:116
extendedCharacterWP5ToUCS4
int extendedCharacterWP5ToUCS4(unsigned char character, unsigned char characterSet, const unsigned **chars)
Definition: libwpd_internal.cpp:1017
NEVER
Definition: libwpd_internal.h:90
FOOTER_A
Definition: libwpd_internal.h:89
readCString
librevenge::RVNGString readCString(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
Definition: libwpd_internal.cpp:183
WPXTextColumnType
WPXTextColumnType
Definition: libwpd_internal.h:103
WPX_TABLE_CELL_BOTTOM_BORDER_OFF
const unsigned char WPX_TABLE_CELL_BOTTOM_BORDER_OFF
Definition: libwpd_internal.h:146
NEWSPAPER_VERTICAL_BALANCE
Definition: libwpd_internal.h:103
WPD_ATTRIBUTE_PRINTF
#define WPD_ATTRIBUTE_PRINTF(fmt, arg)
Definition: libwpd_internal.h:41
ENDNOTE
Definition: libwpd_internal.h:87
WPXHeaderFooterOccurrence
WPXHeaderFooterOccurrence
Definition: libwpd_internal.h:90
_numberingTypeToString
librevenge::RVNGString _numberingTypeToString(WPXNumberingType t)
Definition: libwpd_internal.cpp:1322
HEADER
Definition: libwpd_internal.h:88
SupportedEncryptionException
Definition: libwpd_internal.h:218
PAGENUMBER_POSITION_BOTTOM_INSIDE_LEFT_AND_RIGHT
Definition: libwpd_internal.h:96
RIGHT
Definition: libwpd_internal.h:100
WPXFileType
WPXFileType
Definition: libwpd_internal.h:85
appleWorldScriptToUCS4
int appleWorldScriptToUCS4(unsigned short character, const unsigned **chars)
Definition: libwpd_internal.cpp:1408
WPXSubDocumentType
WPXSubDocumentType
Definition: libwpd_internal.h:105
wpuToFontPointSize
double wpuToFontPointSize(const unsigned short wpuNumber)
Definition: libwpd_internal.cpp:1178
PAGENUMBER_POSITION_TOP_INSIDE_LEFT_AND_RIGHT
Definition: libwpd_internal.h:95
WP6_DOCUMENT
Definition: libwpd_internal.h:85
WPXTabAlignment
WPXTabAlignment
Definition: libwpd_internal.h:100
HEADER_B
Definition: libwpd_internal.h:89
WPX_SUBDOCUMENT_NOTE
Definition: libwpd_internal.h:105
fixedPointToWPUs
unsigned short fixedPointToWPUs(const unsigned fixedPointNumber)
Definition: libwpd_internal.cpp:1163
_extractNumericValueFromRoman
int _extractNumericValueFromRoman(const char romanChar)
Definition: libwpd_internal.cpp:1229
RGBSColor::m_s
unsigned char m_s
Definition: libwpd_internal.h:169
WrongPasswordException
Definition: libwpd_internal.h:222
ALL
Definition: libwpd_internal.h:90
LOWERCASE_ROMAN
Definition: libwpd_internal.h:86
PAGENUMBER_POSITION_BOTTOM_CENTER
Definition: libwpd_internal.h:93
LOWERCASE
Definition: libwpd_internal.h:86
PORTRAIT
Definition: libwpd_internal.h:99
readS16
signed short readS16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false)
Definition: libwpd_internal.cpp:131
FileException
Definition: libwpd_internal.h:202
LEFT
Definition: libwpd_internal.h:100
WPXColumnProperties::m_attributes
unsigned m_attributes
Definition: libwpd_internal.h:183
extendedCharacterWP6ToUCS4
int extendedCharacterWP6ToUCS4(unsigned char character, unsigned char characterSet, const unsigned **chars)
Definition: libwpd_internal.cpp:659
WPX_SUBDOCUMENT_HEADER_FOOTER
Definition: libwpd_internal.h:105
EVEN
Definition: libwpd_internal.h:90
ARABIC
Definition: libwpd_internal.h:86
ParseException
Definition: libwpd_internal.h:206
UPPERCASE
Definition: libwpd_internal.h:86
UnsupportedEncryptionException
Definition: libwpd_internal.h:214
WPXTabStop::m_leaderCharacter
unsigned m_leaderCharacter
Definition: libwpd_internal.h:192
LANDSCAPE
Definition: libwpd_internal.h:99
BOTTOM
Definition: libwpd_internal.h:101
_extractDisplayReferenceNumberFromBuf
int _extractDisplayReferenceNumberFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType listType)
Definition: libwpd_internal.cpp:1256
doubleToString
librevenge::RVNGString doubleToString(const double value)
Definition: libwpd_internal.cpp:1384
WPXColumnProperties
Definition: libwpd_internal.h:180
WPXFormOrientation
WPXFormOrientation
Definition: libwpd_internal.h:99
PAGENUMBER_POSITION_TOP_LEFT_AND_RIGHT
Definition: libwpd_internal.h:92
PAGENUMBER_POSITION_TOP_CENTER
Definition: libwpd_internal.h:91
MIDDLE
Definition: libwpd_internal.h:101
macRomanCharacterMap
const unsigned macRomanCharacterMap[]
Definition: libwpd_internal.cpp:1352
UPPERCASE_ROMAN
Definition: libwpd_internal.h:86
NEWSPAPER
Definition: libwpd_internal.h:103
WPX_TABLE_CELL_TOP_BORDER_OFF
const unsigned char WPX_TABLE_CELL_TOP_BORDER_OFF
Definition: libwpd_internal.h:145
fixedPointToDouble
double fixedPointToDouble(const unsigned fixedPointNumber)
Definition: libwpd_internal.cpp:1171
WPXVerticalAlignment
WPXVerticalAlignment
Definition: libwpd_internal.h:101
BAR
Definition: libwpd_internal.h:100
WPXColumnDefinition
Definition: libwpd_internal.h:172
WPXColumnDefinition::m_leftGutter
double m_leftGutter
Definition: libwpd_internal.h:176
PAGENUMBER_POSITION_BOTTOM_LEFT_AND_RIGHT
Definition: libwpd_internal.h:94
RGBSColor::m_b
unsigned char m_b
Definition: libwpd_internal.h:168
WPXColumnDefinition::m_rightGutter
double m_rightGutter
Definition: libwpd_internal.h:177
DECIMAL
Definition: libwpd_internal.h:100
WPX_SUBDOCUMENT_TEXT_BOX
Definition: libwpd_internal.h:105
WPXTabStop::m_leaderNumSpaces
unsigned char m_leaderNumSpaces
Definition: libwpd_internal.h:193
CENTER
Definition: libwpd_internal.h:100
WPXEncryption
Definition: WPXEncryption.h:33
PAGENUMBER_POSITION_BOTTOM_LEFT
Definition: libwpd_internal.h:93
WPXColumnProperties::m_alignment
unsigned char m_alignment
Definition: libwpd_internal.h:184
RGBSColor
Definition: libwpd_internal.h:160
ODD
Definition: libwpd_internal.h:90
GenericException
Definition: libwpd_internal.h:210
WP42_DOCUMENT
Definition: libwpd_internal.h:85
WPXPageNumberPosition
WPXPageNumberPosition
Definition: libwpd_internal.h:91
WP5_DOCUMENT
Definition: libwpd_internal.h:85
PAGENUMBER_POSITION_TOP_LEFT
Definition: libwpd_internal.h:91
appendUCS4
void appendUCS4(librevenge::RVNGString &str, unsigned ucs4)
Definition: libwpd_internal.cpp:151
WPXTabStop::m_position
double m_position
Definition: libwpd_internal.h:190
libwpd
Definition: WPDocument.h:46
readU32
unsigned readU32(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false)
Definition: libwpd_internal.cpp:136
TOP
Definition: libwpd_internal.h:101
WPX_TABLE_CELL_RIGHT_BORDER_OFF
const unsigned char WPX_TABLE_CELL_RIGHT_BORDER_OFF
Definition: libwpd_internal.h:144
FOOTNOTE
Definition: libwpd_internal.h:87
VersionException
Definition: libwpd_internal.h:198
HEADER_A
Definition: libwpd_internal.h:89
WPX_TABLE_CELL_LEFT_BORDER_OFF
const unsigned char WPX_TABLE_CELL_LEFT_BORDER_OFF
Definition: libwpd_internal.h:143
WPXHeaderFooterType
WPXHeaderFooterType
Definition: libwpd_internal.h:88
readPascalString
librevenge::RVNGString readPascalString(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
Definition: libwpd_internal.cpp:162
PARALLEL
Definition: libwpd_internal.h:103
extendedCharacterWP42ToUCS4
int extendedCharacterWP42ToUCS4(unsigned char character, const unsigned **chars)
Definition: libwpd_internal.cpp:1150
FOOTER_B
Definition: libwpd_internal.h:89
_extractWPXNumberingTypeFromBuf
WPXNumberingType _extractWPXNumberingTypeFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType putativeWPXNumberingType)
Definition: libwpd_internal.cpp:1302
FULL
Definition: libwpd_internal.h:101
WPX_SUBDOCUMENT_COMMENT_ANNOTATION
Definition: libwpd_internal.h:105
WPXNoteType
WPXNoteType
Definition: libwpd_internal.h:87
FOOTER
Definition: libwpd_internal.h:88
WPX_SUBDOCUMENT_NONE
Definition: libwpd_internal.h:105