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  * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
4  * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
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 #include "WPXStream.h"
30 #include <stdio.h>
31 #include <string>
32 #include <algorithm>
33 #include "WPXString.h"
34 #include "WPXEncryption.h"
35 #include "libwpd_types.h"
36 
37 /* Various functions/defines that need not/should not be exported externally */
38 
39 #ifdef _MSC_VER
40 #include <minmax.h>
41 #define LIBWPD_MIN min
42 #define LIBWPD_MAX max
43 #else
44 #define LIBWPD_MIN std::min
45 #define LIBWPD_MAX std::max
46 #endif
47 
48 #define WPD_CHECK_FILE_ERROR(v) if (v==EOF) { WPD_DEBUG_MSG(("X_CheckFileError: %d\n", __LINE__)); throw FileException(); }
49 #define WPD_CHECK_FILE_SEEK_ERROR(v) if (v) { WPD_DEBUG_MSG(("X_CheckFileSeekError: %d\n", __LINE__)); throw FileException(); }
50 #define WPD_CHECK_FILE_READ_ERROR(v,num_elements) if (v != num_elements) {\
51  WPD_DEBUG_MSG(("X_CheckFileReadElementError: %d\n", __LINE__)); throw FileException(); }
52 
53 #define DELETEP(m) if (m) { delete m; m = 0; }
54 
55 #ifdef DEBUG
56 #define WPD_DEBUG_MSG(M) printf M
57 #else
58 #define WPD_DEBUG_MSG(M)
59 #endif
60 
61 #define WPD_LE_GET_GUINT8(p) (*(uint8_t const *)(p))
62 #define WPD_LE_GET_GUINT16(p) \
63  (uint16_t)((((uint8_t const *)(p))[0] << 0) | \
64  (((uint8_t const *)(p))[1] << 8))
65 #define WPD_LE_GET_GUINT32(p) \
66  (uint32_t)((((uint8_t const *)(p))[0] << 0) | \
67  (((uint8_t const *)(p))[1] << 8) | \
68  (((uint8_t const *)(p))[2] << 16) | \
69  (((uint8_t const *)(p))[3] << 24))
70 
71 #define WPD_BE_GET_GUINT8(p) (*(uint8_t const *)(p))
72 #define WPD_BE_GET_GUINT16(p) \
73  (uint16_t)((((uint8_t const *)(p))[1] << 0) | \
74  (((uint8_t const *)(p))[0] << 8))
75 #define WPD_BE_GET_GUINT32(p) \
76  (uint32_t)((((uint8_t const *)(p))[3] << 0) | \
77  (((uint8_t const *)(p))[2] << 8) | \
78  (((uint8_t const *)(p))[1] << 16) | \
79  (((uint8_t const *)(p))[0] << 24))
80 
81 #define WPD_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
82 
83 // add more of these as needed for byteswapping
84 // (the 8-bit functions are just there to make things consistent)
85 uint8_t readU8(WPXInputStream *input, WPXEncryption *encryption);
86 uint16_t readU16(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
87 uint32_t readU32(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
88 
91 
92 void appendUCS4(WPXString &str, uint32_t ucs4);
93 
94 // Various helper structures for the libwpd parser..
95 
96 int extendedCharacterWP6ToUCS4(uint8_t character, uint8_t characterSet,
97  const uint32_t **chars);
98 
99 int extendedCharacterWP5ToUCS4(uint8_t character, uint8_t characterSet,
100  const uint32_t **chars);
101 
102 int appleWorldScriptToUCS4(uint16_t character, const uint32_t **chars);
103 
104 int extendedCharacterWP42ToUCS4(uint8_t character, const uint32_t **chars);
105 
106 uint16_t fixedPointToWPUs(const uint32_t fixedPointNumber);
107 double fixedPointToDouble(const uint32_t fixedPointNumber);
108 double wpuToFontPointSize(const uint16_t wpuNumber);
109 
122  };
123 
127 
129 
131 
132 // ATTRIBUTE bits
133 #define WPX_EXTRA_LARGE_BIT 1
134 #define WPX_VERY_LARGE_BIT 2
135 #define WPX_LARGE_BIT 4
136 #define WPX_SMALL_PRINT_BIT 8
137 #define WPX_FINE_PRINT_BIT 16
138 #define WPX_SUPERSCRIPT_BIT 32
139 #define WPX_SUBSCRIPT_BIT 64
140 #define WPX_OUTLINE_BIT 128
141 #define WPX_ITALICS_BIT 256
142 #define WPX_SHADOW_BIT 512
143 #define WPX_REDLINE_BIT 1024
144 #define WPX_DOUBLE_UNDERLINE_BIT 2048
145 #define WPX_BOLD_BIT 4096
146 #define WPX_STRIKEOUT_BIT 8192
147 #define WPX_UNDERLINE_BIT 16384
148 #define WPX_SMALL_CAPS_BIT 32768
149 #define WPX_BLINK_BIT 65536
150 #define WPX_REVERSEVIDEO_BIT 131072
151 
152 // JUSTIFICATION bits.
153 #define WPX_PARAGRAPH_JUSTIFICATION_LEFT 0x00
154 #define WPX_PARAGRAPH_JUSTIFICATION_FULL 0x01
155 #define WPX_PARAGRAPH_JUSTIFICATION_CENTER 0x02
156 #define WPX_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
157 #define WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
158 #define WPX_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
159 
160 // TABLE POSITION bits.
161 #define WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN 0x00
162 #define WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN 0x01
163 #define WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS 0x02
164 #define WPX_TABLE_POSITION_FULL 0x03
165 #define WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN 0x04
166 
167 // TABLE CELL BORDER bits
168 const uint8_t WPX_TABLE_CELL_LEFT_BORDER_OFF = 0x01;
169 const uint8_t WPX_TABLE_CELL_RIGHT_BORDER_OFF = 0x02;
170 const uint8_t WPX_TABLE_CELL_TOP_BORDER_OFF = 0x04;
171 const uint8_t WPX_TABLE_CELL_BOTTOM_BORDER_OFF = 0x08;
172 
173 // BREAK bits
174 #define WPX_PAGE_BREAK 0x00
175 #define WPX_SOFT_PAGE_BREAK 0x01
176 #define WPX_COLUMN_BREAK 0x02
177 
178 // Generic bits
179 #define WPX_LEFT 0x00
180 #define WPX_RIGHT 0x01
181 #define WPX_CENTER 0x02
182 #define WPX_TOP 0x03
183 #define WPX_BOTTOM 0x04
184 
185 typedef struct _RGBSColor RGBSColor;
187 {
188  _RGBSColor(uint8_t r, uint8_t g, uint8_t b, uint8_t s);
189  _RGBSColor(uint16_t red, uint16_t green, uint16_t blue); // Construct
190  // RBBSColor from double precision RGB color used by WP3.x for Mac
191  _RGBSColor(); // initializes all values to 0
192  uint8_t m_r;
193  uint8_t m_g;
194  uint8_t m_b;
195  uint8_t m_s;
196 };
197 
200 {
201  _WPXColumnDefinition(); // initializes all values to 0
202  double m_width;
203  double m_leftGutter;
205 };
206 
209 {
211  uint32_t m_attributes;
212  uint8_t m_alignment;
213 };
214 
215 typedef struct _WPXTabStop WPXTabStop;
217 {
218  _WPXTabStop();
219  double m_position;
223 };
224 
225 // Various exceptions: libwpd does not propagate exceptions externally..
226 
228 {
229 };
230 
232 {
233 };
234 
236 {
237 };
238 
240 {
241 };
242 
244 {
245 };
246 
248 {
249 };
250 
252 {
253 };
254 
255 // Various usefull, but cheesey functions
256 
257 int _extractNumericValueFromRoman(const char romanChar);
259 WPXNumberingType _extractWPXNumberingTypeFromBuf(const WPXString &buf, const WPXNumberingType putativeWPXNumberingType);
261 extern const uint32_t macRomanCharacterMap[];
262 WPXString doubleToString(const double value);
263 
264 #endif /* LIBWPD_INTERNAL_H */
265 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */

Generated for libwpd by doxygen 1.8.3