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 <stdio.h>
31 #include <string>
32 #include <algorithm>
33 #include <libwpd/libwpd.h>
34 #include <libwpd-stream/libwpd-stream.h>
35 #include "WPXEncryption.h"
36 #include "libwpd_types.h"
37 
38 /* Various functions/defines that need not/should not be exported externally */
39 
40 #ifdef _MSC_VER
41 #include <minmax.h>
42 #define LIBWPD_MIN min
43 #define LIBWPD_MAX max
44 #else
45 #define LIBWPD_MIN std::min
46 #define LIBWPD_MAX std::max
47 #endif
48 
49 #define WPD_CHECK_FILE_ERROR(v) if (v==EOF) { WPD_DEBUG_MSG(("X_CheckFileError: %d\n", __LINE__)); throw FileException(); }
50 #define WPD_CHECK_FILE_SEEK_ERROR(v) if (v) { WPD_DEBUG_MSG(("X_CheckFileSeekError: %d\n", __LINE__)); throw FileException(); }
51 #define WPD_CHECK_FILE_READ_ERROR(v,num_elements) if (v != num_elements) {\
52  WPD_DEBUG_MSG(("X_CheckFileReadElementError: %d\n", __LINE__)); throw FileException(); }
53 
54 #define DELETEP(m) if (m) { delete m; m = 0; }
55 
56 #ifdef DEBUG
57 #define WPD_DEBUG_MSG(M) printf M
58 #else
59 #define WPD_DEBUG_MSG(M)
60 #endif
61 
62 #define WPD_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
63 
64 // add more of these as needed for byteswapping
65 // (the 8-bit functions are just there to make things consistent)
66 uint8_t readU8(WPXInputStream *input, WPXEncryption *encryption);
67 uint16_t readU16(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
68 int16_t readS16(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
69 uint32_t readU32(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
70 
71 WPXString readPascalString(WPXInputStream *input, WPXEncryption *encryption);
72 WPXString readCString(WPXInputStream *input, WPXEncryption *encryption);
73 
74 void appendUCS4(WPXString &str, uint32_t ucs4);
75 
76 // Various helper structures for the libwpd parser..
77 
78 int extendedCharacterWP6ToUCS4(uint8_t character, uint8_t characterSet,
79  const uint32_t **chars);
80 
81 int extendedCharacterWP5ToUCS4(uint8_t character, uint8_t characterSet,
82  const uint32_t **chars);
83 
84 int appleWorldScriptToUCS4(uint16_t character, const uint32_t **chars);
85 
86 int extendedCharacterWP42ToUCS4(uint8_t character, const uint32_t **chars);
87 
88 uint16_t fixedPointToWPUs(const uint32_t fixedPointNumber);
89 double fixedPointToDouble(const uint32_t fixedPointNumber);
90 double wpuToFontPointSize(const uint16_t wpuNumber);
91 
104  };
105 
109 
111 
113 
114 // ATTRIBUTE bits
115 #define WPX_EXTRA_LARGE_BIT 1
116 #define WPX_VERY_LARGE_BIT 2
117 #define WPX_LARGE_BIT 4
118 #define WPX_SMALL_PRINT_BIT 8
119 #define WPX_FINE_PRINT_BIT 16
120 #define WPX_SUPERSCRIPT_BIT 32
121 #define WPX_SUBSCRIPT_BIT 64
122 #define WPX_OUTLINE_BIT 128
123 #define WPX_ITALICS_BIT 256
124 #define WPX_SHADOW_BIT 512
125 #define WPX_REDLINE_BIT 1024
126 #define WPX_DOUBLE_UNDERLINE_BIT 2048
127 #define WPX_BOLD_BIT 4096
128 #define WPX_STRIKEOUT_BIT 8192
129 #define WPX_UNDERLINE_BIT 16384
130 #define WPX_SMALL_CAPS_BIT 32768
131 #define WPX_BLINK_BIT 65536
132 #define WPX_REVERSEVIDEO_BIT 131072
133 
134 // JUSTIFICATION bits.
135 #define WPX_PARAGRAPH_JUSTIFICATION_LEFT 0x00
136 #define WPX_PARAGRAPH_JUSTIFICATION_FULL 0x01
137 #define WPX_PARAGRAPH_JUSTIFICATION_CENTER 0x02
138 #define WPX_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
139 #define WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
140 #define WPX_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
141 
142 // TABLE POSITION bits.
143 #define WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN 0x00
144 #define WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN 0x01
145 #define WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS 0x02
146 #define WPX_TABLE_POSITION_FULL 0x03
147 #define WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN 0x04
148 
149 // TABLE CELL BORDER bits
150 const uint8_t WPX_TABLE_CELL_LEFT_BORDER_OFF = 0x01;
151 const uint8_t WPX_TABLE_CELL_RIGHT_BORDER_OFF = 0x02;
152 const uint8_t WPX_TABLE_CELL_TOP_BORDER_OFF = 0x04;
153 const uint8_t WPX_TABLE_CELL_BOTTOM_BORDER_OFF = 0x08;
154 
155 // BREAK bits
156 #define WPX_PAGE_BREAK 0x00
157 #define WPX_SOFT_PAGE_BREAK 0x01
158 #define WPX_COLUMN_BREAK 0x02
159 
160 // Generic bits
161 #define WPX_LEFT 0x00
162 #define WPX_RIGHT 0x01
163 #define WPX_CENTER 0x02
164 #define WPX_TOP 0x03
165 #define WPX_BOTTOM 0x04
166 
167 typedef struct _RGBSColor RGBSColor;
169 {
170  _RGBSColor(uint8_t r, uint8_t g, uint8_t b, uint8_t s);
171  _RGBSColor(uint16_t red, uint16_t green, uint16_t blue); // Construct
172  // RBBSColor from double precision RGB color used by WP3.x for Mac
173  _RGBSColor(); // initializes all values to 0
174  uint8_t m_r;
175  uint8_t m_g;
176  uint8_t m_b;
177  uint8_t m_s;
178 };
179 
182 {
183  _WPXColumnDefinition(); // initializes all values to 0
184  double m_width;
185  double m_leftGutter;
187 };
188 
191 {
193  uint32_t m_attributes;
194  uint8_t m_alignment;
195 };
196 
197 typedef struct _WPXTabStop WPXTabStop;
199 {
200  _WPXTabStop();
201  double m_position;
205 };
206 
207 // Various exceptions: libwpd does not propagate exceptions externally..
208 
210 {
211 };
212 
214 {
215 };
216 
218 {
219 };
220 
222 {
223 };
224 
226 {
227 };
228 
230 {
231 };
232 
234 {
235 };
236 
237 // Various usefull, but cheesey functions
238 
239 int _extractNumericValueFromRoman(const char romanChar);
240 int _extractDisplayReferenceNumberFromBuf(const WPXString &buf, const WPXNumberingType listType);
241 WPXNumberingType _extractWPXNumberingTypeFromBuf(const WPXString &buf, const WPXNumberingType putativeWPXNumberingType);
243 extern const uint32_t macRomanCharacterMap[];
244 WPXString doubleToString(const double value);
245 
246 #endif /* LIBWPD_INTERNAL_H */
247 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */

Generated for libwpd by doxygen 1.8.1.2