libwpd_internal.h Source File documentation

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#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
37#define WPD_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
38#else
39#define WPD_ATTRIBUTE_PRINTF(fmt, arg)
40#endif
41
42#ifdef DEBUG
43namespace libwpd
44{
45void debugPrint(const char *format, ...) WPD_ATTRIBUTE_PRINTF(1, 2);
46}
47
48#define WPD_DEBUG_MSG(M) libwpd::debugPrint M
49#else
50#define WPD_DEBUG_MSG(M)
51#endif
52
53#define WPD_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
54
55 namespace libwpd
56{
57 struct WPXDummyDeleter
58{
59 void operator()(void *) {}
60};
61}
62
63// add more of these as needed for byteswapping
64// (the 8-bit functions are just there to make things consistent)
65unsigned char readU8(librevenge::RVNGInputStream *input, WPXEncryption *encryption);
66unsigned short readU16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false);
67signed short readS16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false);
68unsigned readU32(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false);
69
70librevenge::RVNGString readPascalString(librevenge::RVNGInputStream *input, WPXEncryption *encryption);
71librevenge::RVNGString readCString(librevenge::RVNGInputStream *input, WPXEncryption *encryption);
72
73void appendUCS4(librevenge::RVNGString &str, unsigned ucs4);
74
75// Various helper structures for the libwpd parser..
76
77int extendedCharacterWP6ToUCS4(unsigned char character, unsigned char characterSet,
78 const unsigned **chars);
79
80int extendedCharacterWP5ToUCS4(unsigned char character, unsigned char characterSet,
81 const unsigned **chars);
82
83int appleWorldScriptToUCS4(unsigned short character, const unsigned **chars);
84
85int extendedCharacterWP42ToUCS4(unsigned char character, const unsigned **chars);
86
87unsigned short fixedPointToWPUs(const unsigned fixedPointNumber);
88double fixedPointToDouble(const unsigned fixedPointNumber);
89double wpuToFontPointSize(const unsigned short wpuNumber);
90
91 enum WPXFileType { WP6_DOCUMENT, WP5_DOCUMENT, WP42_DOCUMENT, OTHER };
92 enum WPXNumberingType { ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
93 enum WPXNoteType { FOOTNOTE, ENDNOTE };
94 enum WPXHeaderFooterType { HEADER, FOOTER };
95 enum WPXHeaderFooterInternalType { HEADER_A, HEADER_B, FOOTER_A, FOOTER_B, DUMMY };
96 enum WPXHeaderFooterOccurrence { ODD, EVEN, ALL, NEVER };
97 enum WPXPageNumberPosition { PAGENUMBER_POSITION_NONE = 0, PAGENUMBER_POSITION_TOP_LEFT, PAGENUMBER_POSITION_TOP_CENTER,
98 PAGENUMBER_POSITION_TOP_RIGHT, PAGENUMBER_POSITION_TOP_LEFT_AND_RIGHT,
99 PAGENUMBER_POSITION_BOTTOM_LEFT, PAGENUMBER_POSITION_BOTTOM_CENTER,
100 PAGENUMBER_POSITION_BOTTOM_RIGHT, PAGENUMBER_POSITION_BOTTOM_LEFT_AND_RIGHT,
101 PAGENUMBER_POSITION_TOP_INSIDE_LEFT_AND_RIGHT,
102 PAGENUMBER_POSITION_BOTTOM_INSIDE_LEFT_AND_RIGHT
103 };
104
105 enum WPXFormOrientation { PORTRAIT, LANDSCAPE };
106 enum WPXTabAlignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
107 enum WPXVerticalAlignment { TOP, MIDDLE, BOTTOM, FULL };
108
109 enum WPXTextColumnType { NEWSPAPER, NEWSPAPER_VERTICAL_BALANCE, PARALLEL, PARALLEL_PROTECT };
110
111 enum WPXSubDocumentType { WPX_SUBDOCUMENT_NONE, WPX_SUBDOCUMENT_HEADER_FOOTER, WPX_SUBDOCUMENT_NOTE, WPX_SUBDOCUMENT_TEXT_BOX, WPX_SUBDOCUMENT_COMMENT_ANNOTATION };
112
113// ATTRIBUTE bits
114#define WPX_EXTRA_LARGE_BIT 1
115#define WPX_VERY_LARGE_BIT 2
116#define WPX_LARGE_BIT 4
117#define WPX_SMALL_PRINT_BIT 8
118#define WPX_FINE_PRINT_BIT 16
119#define WPX_SUPERSCRIPT_BIT 32
120#define WPX_SUBSCRIPT_BIT 64
121#define WPX_OUTLINE_BIT 128
122#define WPX_ITALICS_BIT 256
123#define WPX_SHADOW_BIT 512
124#define WPX_REDLINE_BIT 1024
125#define WPX_DOUBLE_UNDERLINE_BIT 2048
126#define WPX_BOLD_BIT 4096
127#define WPX_STRIKEOUT_BIT 8192
128#define WPX_UNDERLINE_BIT 16384
129#define WPX_SMALL_CAPS_BIT 32768
130#define WPX_BLINK_BIT 65536
131#define WPX_REVERSEVIDEO_BIT 131072
132
133// JUSTIFICATION bits.
134#define WPX_PARAGRAPH_JUSTIFICATION_LEFT 0x00
135#define WPX_PARAGRAPH_JUSTIFICATION_FULL 0x01
136#define WPX_PARAGRAPH_JUSTIFICATION_CENTER 0x02
137#define WPX_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
138#define WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
139#define WPX_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
140
141// TABLE POSITION bits.
142#define WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN 0x00
143#define WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN 0x01
144#define WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS 0x02
145#define WPX_TABLE_POSITION_FULL 0x03
146#define WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN 0x04
147
148// TABLE CELL BORDER bits
149 const unsigned char WPX_TABLE_CELL_LEFT_BORDER_OFF = 0x01;
150 const unsigned char WPX_TABLE_CELL_RIGHT_BORDER_OFF = 0x02;
151 const unsigned char WPX_TABLE_CELL_TOP_BORDER_OFF = 0x04;
152 const unsigned char WPX_TABLE_CELL_BOTTOM_BORDER_OFF = 0x08;
153
154// BREAK bits
155#define WPX_PAGE_BREAK 0x00
156#define WPX_SOFT_PAGE_BREAK 0x01
157#define WPX_COLUMN_BREAK 0x02
158
159// Generic bits
160#define WPX_LEFT 0x00
161#define WPX_RIGHT 0x01
162#define WPX_CENTER 0x02
163#define WPX_TOP 0x03
164#define WPX_BOTTOM 0x04
165
166 struct RGBSColor
167{
168 RGBSColor(unsigned char r, unsigned char g, unsigned char b, unsigned char s);
169 RGBSColor(unsigned short red, unsigned short green, unsigned short blue); // Construct
170 // RBBSColor from double precision RGB color used by WP3.x for Mac
171 RGBSColor(); // initializes all values to 0
172 unsigned char m_r;
173 unsigned char m_g;
174 unsigned char m_b;
175 unsigned char m_s;
176};
177
178 struct WPXColumnDefinition
179{
180 WPXColumnDefinition(); // initializes all values to 0
181 double m_width;
182 double m_leftGutter;
183 double m_rightGutter;
184};
185
186 struct WPXColumnProperties
187{
188 WPXColumnProperties();
189 unsigned m_attributes;
190 unsigned char m_alignment;
191};
192
193 struct WPXTabStop
194{
195 WPXTabStop();
196 double m_position;
197 WPXTabAlignment m_alignment;
198 unsigned m_leaderCharacter;
199 unsigned char m_leaderNumSpaces;
200};
201
202// Various exceptions: libwpd does not propagate exceptions externally..
203
204 class VersionException
205{
206};
207
208 class FileException
209{
210};
211
212 class ParseException
213{
214};
215
216 class GenericException
217{
218};
219
220 class UnsupportedEncryptionException
221{
222};
223
224 class SupportedEncryptionException
225{
226};
227
228 class WrongPasswordException
229{
230};
231
232// Various usefull, but cheesey functions
233
234int _extractNumericValueFromRoman(const char romanChar);
235int _extractDisplayReferenceNumberFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType listType);
236 WPXNumberingType _extractWPXNumberingTypeFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType putativeWPXNumberingType);
237librevenge::RVNGString _numberingTypeToString(WPXNumberingType t);
238extern const unsigned macRomanCharacterMap[];
239librevenge::RVNGString doubleToString(const double value);
240
241#endif /* LIBWPD_INTERNAL_H */
242/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPXEncryption.h
FileException
Definition libwpd_internal.h:209
GenericException
Definition libwpd_internal.h:217
ParseException
Definition libwpd_internal.h:213
SupportedEncryptionException
Definition libwpd_internal.h:225
UnsupportedEncryptionException
Definition libwpd_internal.h:221
VersionException
Definition libwpd_internal.h:205
WPXEncryption
Definition WPXEncryption.h:36
WrongPasswordException
Definition libwpd_internal.h:229
macRomanCharacterMap
const unsigned macRomanCharacterMap[]
Definition libwpd_internal.cpp:1353
WPXHeaderFooterOccurrence
WPXHeaderFooterOccurrence
Definition libwpd_internal.h:96
NEVER
@ NEVER
Definition libwpd_internal.h:96
EVEN
@ EVEN
Definition libwpd_internal.h:96
ODD
@ ODD
Definition libwpd_internal.h:96
ALL
@ ALL
Definition libwpd_internal.h:96
WPX_TABLE_CELL_BOTTOM_BORDER_OFF
const unsigned char WPX_TABLE_CELL_BOTTOM_BORDER_OFF
Definition libwpd_internal.h:152
WPXHeaderFooterType
WPXHeaderFooterType
Definition libwpd_internal.h:94
HEADER
@ HEADER
Definition libwpd_internal.h:94
FOOTER
@ FOOTER
Definition libwpd_internal.h:94
WPXFormOrientation
WPXFormOrientation
Definition libwpd_internal.h:105
LANDSCAPE
@ LANDSCAPE
Definition libwpd_internal.h:105
PORTRAIT
@ PORTRAIT
Definition libwpd_internal.h:105
WPXPageNumberPosition
WPXPageNumberPosition
Definition libwpd_internal.h:97
PAGENUMBER_POSITION_BOTTOM_INSIDE_LEFT_AND_RIGHT
@ PAGENUMBER_POSITION_BOTTOM_INSIDE_LEFT_AND_RIGHT
Definition libwpd_internal.h:102
PAGENUMBER_POSITION_BOTTOM_LEFT_AND_RIGHT
@ PAGENUMBER_POSITION_BOTTOM_LEFT_AND_RIGHT
Definition libwpd_internal.h:100
PAGENUMBER_POSITION_BOTTOM_LEFT
@ PAGENUMBER_POSITION_BOTTOM_LEFT
Definition libwpd_internal.h:99
PAGENUMBER_POSITION_TOP_CENTER
@ PAGENUMBER_POSITION_TOP_CENTER
Definition libwpd_internal.h:97
PAGENUMBER_POSITION_TOP_RIGHT
@ PAGENUMBER_POSITION_TOP_RIGHT
Definition libwpd_internal.h:98
PAGENUMBER_POSITION_TOP_LEFT_AND_RIGHT
@ PAGENUMBER_POSITION_TOP_LEFT_AND_RIGHT
Definition libwpd_internal.h:98
PAGENUMBER_POSITION_TOP_LEFT
@ PAGENUMBER_POSITION_TOP_LEFT
Definition libwpd_internal.h:97
PAGENUMBER_POSITION_BOTTOM_RIGHT
@ PAGENUMBER_POSITION_BOTTOM_RIGHT
Definition libwpd_internal.h:100
PAGENUMBER_POSITION_TOP_INSIDE_LEFT_AND_RIGHT
@ PAGENUMBER_POSITION_TOP_INSIDE_LEFT_AND_RIGHT
Definition libwpd_internal.h:101
PAGENUMBER_POSITION_NONE
@ PAGENUMBER_POSITION_NONE
Definition libwpd_internal.h:97
PAGENUMBER_POSITION_BOTTOM_CENTER
@ PAGENUMBER_POSITION_BOTTOM_CENTER
Definition libwpd_internal.h:99
wpuToFontPointSize
double wpuToFontPointSize(const unsigned short wpuNumber)
Definition libwpd_internal.cpp:1179
WPXTabAlignment
WPXTabAlignment
Definition libwpd_internal.h:106
CENTER
@ CENTER
Definition libwpd_internal.h:106
BAR
@ BAR
Definition libwpd_internal.h:106
LEFT
@ LEFT
Definition libwpd_internal.h:106
RIGHT
@ RIGHT
Definition libwpd_internal.h:106
DECIMAL
@ DECIMAL
Definition libwpd_internal.h:106
WPX_TABLE_CELL_RIGHT_BORDER_OFF
const unsigned char WPX_TABLE_CELL_RIGHT_BORDER_OFF
Definition libwpd_internal.h:150
_extractNumericValueFromRoman
int _extractNumericValueFromRoman(const char romanChar)
Definition libwpd_internal.cpp:1230
WPXFileType
WPXFileType
Definition libwpd_internal.h:91
WP6_DOCUMENT
@ WP6_DOCUMENT
Definition libwpd_internal.h:91
OTHER
@ OTHER
Definition libwpd_internal.h:91
WP5_DOCUMENT
@ WP5_DOCUMENT
Definition libwpd_internal.h:91
WP42_DOCUMENT
@ WP42_DOCUMENT
Definition libwpd_internal.h:91
fixedPointToWPUs
unsigned short fixedPointToWPUs(const unsigned fixedPointNumber)
Definition libwpd_internal.cpp:1164
readS16
signed short readS16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false)
Definition libwpd_internal.cpp:134
WPD_ATTRIBUTE_PRINTF
#define WPD_ATTRIBUTE_PRINTF(fmt, arg)
Definition libwpd_internal.h:39
_extractWPXNumberingTypeFromBuf
WPXNumberingType _extractWPXNumberingTypeFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType putativeWPXNumberingType)
Definition libwpd_internal.cpp:1303
_numberingTypeToString
librevenge::RVNGString _numberingTypeToString(WPXNumberingType t)
Definition libwpd_internal.cpp:1323
_extractDisplayReferenceNumberFromBuf
int _extractDisplayReferenceNumberFromBuf(const librevenge::RVNGString &buf, const WPXNumberingType listType)
Definition libwpd_internal.cpp:1257
WPXTextColumnType
WPXTextColumnType
Definition libwpd_internal.h:109
NEWSPAPER_VERTICAL_BALANCE
@ NEWSPAPER_VERTICAL_BALANCE
Definition libwpd_internal.h:109
NEWSPAPER
@ NEWSPAPER
Definition libwpd_internal.h:109
PARALLEL_PROTECT
@ PARALLEL_PROTECT
Definition libwpd_internal.h:109
PARALLEL
@ PARALLEL
Definition libwpd_internal.h:109
appendUCS4
void appendUCS4(librevenge::RVNGString &str, unsigned ucs4)
Definition libwpd_internal.cpp:154
readCString
librevenge::RVNGString readCString(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
Definition libwpd_internal.cpp:184
readU8
unsigned char readU8(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
Definition libwpd_internal.cpp:106
doubleToString
librevenge::RVNGString doubleToString(const double value)
Definition libwpd_internal.cpp:1385
WPXNumberingType
WPXNumberingType
Definition libwpd_internal.h:92
UPPERCASE
@ UPPERCASE
Definition libwpd_internal.h:92
UPPERCASE_ROMAN
@ UPPERCASE_ROMAN
Definition libwpd_internal.h:92
ARABIC
@ ARABIC
Definition libwpd_internal.h:92
LOWERCASE_ROMAN
@ LOWERCASE_ROMAN
Definition libwpd_internal.h:92
LOWERCASE
@ LOWERCASE
Definition libwpd_internal.h:92
extendedCharacterWP5ToUCS4
int extendedCharacterWP5ToUCS4(unsigned char character, unsigned char characterSet, const unsigned **chars)
Definition libwpd_internal.cpp:1018
WPXHeaderFooterInternalType
WPXHeaderFooterInternalType
Definition libwpd_internal.h:95
FOOTER_B
@ FOOTER_B
Definition libwpd_internal.h:95
HEADER_B
@ HEADER_B
Definition libwpd_internal.h:95
FOOTER_A
@ FOOTER_A
Definition libwpd_internal.h:95
HEADER_A
@ HEADER_A
Definition libwpd_internal.h:95
DUMMY
@ DUMMY
Definition libwpd_internal.h:95
WPXSubDocumentType
WPXSubDocumentType
Definition libwpd_internal.h:111
WPX_SUBDOCUMENT_TEXT_BOX
@ WPX_SUBDOCUMENT_TEXT_BOX
Definition libwpd_internal.h:111
WPX_SUBDOCUMENT_NOTE
@ WPX_SUBDOCUMENT_NOTE
Definition libwpd_internal.h:111
WPX_SUBDOCUMENT_NONE
@ WPX_SUBDOCUMENT_NONE
Definition libwpd_internal.h:111
WPX_SUBDOCUMENT_COMMENT_ANNOTATION
@ WPX_SUBDOCUMENT_COMMENT_ANNOTATION
Definition libwpd_internal.h:111
WPX_SUBDOCUMENT_HEADER_FOOTER
@ WPX_SUBDOCUMENT_HEADER_FOOTER
Definition libwpd_internal.h:111
WPXVerticalAlignment
WPXVerticalAlignment
Definition libwpd_internal.h:107
TOP
@ TOP
Definition libwpd_internal.h:107
MIDDLE
@ MIDDLE
Definition libwpd_internal.h:107
BOTTOM
@ BOTTOM
Definition libwpd_internal.h:107
FULL
@ FULL
Definition libwpd_internal.h:107
extendedCharacterWP6ToUCS4
int extendedCharacterWP6ToUCS4(unsigned char character, unsigned char characterSet, const unsigned **chars)
Definition libwpd_internal.cpp:660
WPX_TABLE_CELL_TOP_BORDER_OFF
const unsigned char WPX_TABLE_CELL_TOP_BORDER_OFF
Definition libwpd_internal.h:151
fixedPointToDouble
double fixedPointToDouble(const unsigned fixedPointNumber)
Definition libwpd_internal.cpp:1172
readU16
unsigned short readU16(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false)
Definition libwpd_internal.cpp:119
WPX_TABLE_CELL_LEFT_BORDER_OFF
const unsigned char WPX_TABLE_CELL_LEFT_BORDER_OFF
Definition libwpd_internal.h:149
WPXNoteType
WPXNoteType
Definition libwpd_internal.h:93
FOOTNOTE
@ FOOTNOTE
Definition libwpd_internal.h:93
ENDNOTE
@ ENDNOTE
Definition libwpd_internal.h:93
readPascalString
librevenge::RVNGString readPascalString(librevenge::RVNGInputStream *input, WPXEncryption *encryption)
Definition libwpd_internal.cpp:163
readU32
unsigned readU32(librevenge::RVNGInputStream *input, WPXEncryption *encryption, bool bigendian=false)
Definition libwpd_internal.cpp:139
extendedCharacterWP42ToUCS4
int extendedCharacterWP42ToUCS4(unsigned char character, const unsigned **chars)
Definition libwpd_internal.cpp:1151
appleWorldScriptToUCS4
int appleWorldScriptToUCS4(unsigned short character, const unsigned **chars)
Definition libwpd_internal.cpp:1409
libwpd
Definition libwpd_internal.h:56
RGBSColor::m_b
unsigned char m_b
Definition libwpd_internal.h:174
RGBSColor::RGBSColor
RGBSColor()
Definition libwpd_internal.cpp:1192
RGBSColor::RGBSColor
RGBSColor(unsigned char r, unsigned char g, unsigned char b, unsigned char s)
Definition libwpd_internal.cpp:1184
RGBSColor::m_r
unsigned char m_r
Definition libwpd_internal.h:172
RGBSColor::m_s
unsigned char m_s
Definition libwpd_internal.h:175
RGBSColor::m_g
unsigned char m_g
Definition libwpd_internal.h:173
WPXColumnDefinition::m_leftGutter
double m_leftGutter
Definition libwpd_internal.h:182
WPXColumnDefinition::WPXColumnDefinition
WPXColumnDefinition()
Definition libwpd_internal.cpp:1216
WPXColumnDefinition::m_width
double m_width
Definition libwpd_internal.h:181
WPXColumnDefinition::m_rightGutter
double m_rightGutter
Definition libwpd_internal.h:183
WPXColumnProperties::WPXColumnProperties
WPXColumnProperties()
Definition libwpd_internal.cpp:1223
WPXColumnProperties::m_alignment
unsigned char m_alignment
Definition libwpd_internal.h:190
WPXColumnProperties::m_attributes
unsigned m_attributes
Definition libwpd_internal.h:189
WPXTabStop::WPXTabStop
WPXTabStop()
Definition libwpd_internal.cpp:1208
WPXTabStop::m_alignment
WPXTabAlignment m_alignment
Definition libwpd_internal.h:197
WPXTabStop::m_position
double m_position
Definition libwpd_internal.h:196
WPXTabStop::m_leaderNumSpaces
unsigned char m_leaderNumSpaces
Definition libwpd_internal.h:199
WPXTabStop::m_leaderCharacter
unsigned m_leaderCharacter
Definition libwpd_internal.h:198
libwpd::WPXDummyDeleter
Definition libwpd_internal.h:58
libwpd::WPXDummyDeleter::operator()
void operator()(void *)
Definition libwpd_internal.h:59