00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef LIBWPD_INTERNAL_H
00028 #define LIBWPD_INTERNAL_H
00029
00030 #include <stdio.h>
00031 #include <string>
00032 #include <algorithm>
00033 #include <libwpd/libwpd.h>
00034 #include <libwpd-stream/libwpd-stream.h>
00035 #include "WPXEncryption.h"
00036 #include "libwpd_types.h"
00037
00038
00039
00040 #ifdef _MSC_VER
00041 #include <minmax.h>
00042 #define LIBWPD_MIN min
00043 #define LIBWPD_MAX max
00044 #else
00045 #define LIBWPD_MIN std::min
00046 #define LIBWPD_MAX std::max
00047 #endif
00048
00049 #define WPD_CHECK_FILE_ERROR(v) if (v==EOF) { WPD_DEBUG_MSG(("X_CheckFileError: %d\n", __LINE__)); throw FileException(); }
00050 #define WPD_CHECK_FILE_SEEK_ERROR(v) if (v) { WPD_DEBUG_MSG(("X_CheckFileSeekError: %d\n", __LINE__)); throw FileException(); }
00051 #define WPD_CHECK_FILE_READ_ERROR(v,num_elements) if (v != num_elements) {\
00052 WPD_DEBUG_MSG(("X_CheckFileReadElementError: %d\n", __LINE__)); throw FileException(); }
00053
00054 #define DELETEP(m) if (m) { delete m; m = 0; }
00055
00056 #ifdef DEBUG
00057 #define WPD_DEBUG_MSG(M) printf M
00058 #else
00059 #define WPD_DEBUG_MSG(M)
00060 #endif
00061
00062 #define WPD_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
00063
00064
00065
00066 uint8_t readU8(WPXInputStream *input, WPXEncryption *encryption);
00067 uint16_t readU16(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
00068 int16_t readS16(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
00069 uint32_t readU32(WPXInputStream *input, WPXEncryption *encryption, bool bigendian=false);
00070
00071 WPXString readPascalString(WPXInputStream *input, WPXEncryption *encryption);
00072 WPXString readCString(WPXInputStream *input, WPXEncryption *encryption);
00073
00074 void appendUCS4(WPXString &str, uint32_t ucs4);
00075
00076
00077
00078 int extendedCharacterWP6ToUCS4(uint8_t character, uint8_t characterSet,
00079 const uint32_t **chars);
00080
00081 int extendedCharacterWP5ToUCS4(uint8_t character, uint8_t characterSet,
00082 const uint32_t **chars);
00083
00084 int appleWorldScriptToUCS4(uint16_t character, const uint32_t **chars);
00085
00086 int extendedCharacterWP42ToUCS4(uint8_t character, const uint32_t **chars);
00087
00088 uint16_t fixedPointToWPUs(const uint32_t fixedPointNumber);
00089 double fixedPointToDouble(const uint32_t fixedPointNumber);
00090 double wpuToFontPointSize(const uint16_t wpuNumber);
00091
00092 enum WPXFileType { WP6_DOCUMENT, WP5_DOCUMENT, WP42_DOCUMENT, OTHER };
00093 enum WPXNumberingType { ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
00094 enum WPXNoteType { FOOTNOTE, ENDNOTE };
00095 enum WPXHeaderFooterType { HEADER, FOOTER };
00096 enum WPXHeaderFooterInternalType { HEADER_A, HEADER_B, FOOTER_A, FOOTER_B, DUMMY };
00097 enum WPXHeaderFooterOccurence { ODD, EVEN, ALL, NEVER };
00098 enum WPXPageNumberPosition { PAGENUMBER_POSITION_NONE = 0, PAGENUMBER_POSITION_TOP_LEFT, PAGENUMBER_POSITION_TOP_CENTER,
00099 PAGENUMBER_POSITION_TOP_RIGHT, PAGENUMBER_POSITION_TOP_LEFT_AND_RIGHT,
00100 PAGENUMBER_POSITION_BOTTOM_LEFT, PAGENUMBER_POSITION_BOTTOM_CENTER,
00101 PAGENUMBER_POSITION_BOTTOM_RIGHT, PAGENUMBER_POSITION_BOTTOM_LEFT_AND_RIGHT,
00102 PAGENUMBER_POSITION_TOP_INSIDE_LEFT_AND_RIGHT,
00103 PAGENUMBER_POSITION_BOTTOM_INSIDE_LEFT_AND_RIGHT
00104 };
00105
00106 enum WPXFormOrientation { PORTRAIT, LANDSCAPE };
00107 enum WPXTabAlignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
00108 enum WPXVerticalAlignment { TOP, MIDDLE, BOTTOM, FULL };
00109
00110 enum WPXTextColumnType { NEWSPAPER, NEWSPAPER_VERTICAL_BALANCE, PARALLEL, PARALLEL_PROTECT };
00111
00112 enum WPXSubDocumentType { WPX_SUBDOCUMENT_NONE, WPX_SUBDOCUMENT_HEADER_FOOTER, WPX_SUBDOCUMENT_NOTE, WPX_SUBDOCUMENT_TEXT_BOX, WPX_SUBDOCUMENT_COMMENT_ANNOTATION };
00113
00114
00115 #define WPX_EXTRA_LARGE_BIT 1
00116 #define WPX_VERY_LARGE_BIT 2
00117 #define WPX_LARGE_BIT 4
00118 #define WPX_SMALL_PRINT_BIT 8
00119 #define WPX_FINE_PRINT_BIT 16
00120 #define WPX_SUPERSCRIPT_BIT 32
00121 #define WPX_SUBSCRIPT_BIT 64
00122 #define WPX_OUTLINE_BIT 128
00123 #define WPX_ITALICS_BIT 256
00124 #define WPX_SHADOW_BIT 512
00125 #define WPX_REDLINE_BIT 1024
00126 #define WPX_DOUBLE_UNDERLINE_BIT 2048
00127 #define WPX_BOLD_BIT 4096
00128 #define WPX_STRIKEOUT_BIT 8192
00129 #define WPX_UNDERLINE_BIT 16384
00130 #define WPX_SMALL_CAPS_BIT 32768
00131 #define WPX_BLINK_BIT 65536
00132 #define WPX_REVERSEVIDEO_BIT 131072
00133
00134
00135 #define WPX_PARAGRAPH_JUSTIFICATION_LEFT 0x00
00136 #define WPX_PARAGRAPH_JUSTIFICATION_FULL 0x01
00137 #define WPX_PARAGRAPH_JUSTIFICATION_CENTER 0x02
00138 #define WPX_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
00139 #define WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
00140 #define WPX_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
00141
00142
00143 #define WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN 0x00
00144 #define WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN 0x01
00145 #define WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS 0x02
00146 #define WPX_TABLE_POSITION_FULL 0x03
00147 #define WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN 0x04
00148
00149
00150 const uint8_t WPX_TABLE_CELL_LEFT_BORDER_OFF = 0x01;
00151 const uint8_t WPX_TABLE_CELL_RIGHT_BORDER_OFF = 0x02;
00152 const uint8_t WPX_TABLE_CELL_TOP_BORDER_OFF = 0x04;
00153 const uint8_t WPX_TABLE_CELL_BOTTOM_BORDER_OFF = 0x08;
00154
00155
00156 #define WPX_PAGE_BREAK 0x00
00157 #define WPX_SOFT_PAGE_BREAK 0x01
00158 #define WPX_COLUMN_BREAK 0x02
00159
00160
00161 #define WPX_LEFT 0x00
00162 #define WPX_RIGHT 0x01
00163 #define WPX_CENTER 0x02
00164 #define WPX_TOP 0x03
00165 #define WPX_BOTTOM 0x04
00166
00167 typedef struct _RGBSColor RGBSColor;
00168 struct _RGBSColor
00169 {
00170 _RGBSColor(uint8_t r, uint8_t g, uint8_t b, uint8_t s);
00171 _RGBSColor(uint16_t red, uint16_t green, uint16_t blue);
00172
00173 _RGBSColor();
00174 uint8_t m_r;
00175 uint8_t m_g;
00176 uint8_t m_b;
00177 uint8_t m_s;
00178 };
00179
00180 typedef struct _WPXColumnDefinition WPXColumnDefinition;
00181 struct _WPXColumnDefinition
00182 {
00183 _WPXColumnDefinition();
00184 double m_width;
00185 double m_leftGutter;
00186 double m_rightGutter;
00187 };
00188
00189 typedef struct _WPXColumnProperties WPXColumnProperties;
00190 struct _WPXColumnProperties
00191 {
00192 _WPXColumnProperties();
00193 uint32_t m_attributes;
00194 uint8_t m_alignment;
00195 };
00196
00197 typedef struct _WPXTabStop WPXTabStop;
00198 struct _WPXTabStop
00199 {
00200 _WPXTabStop();
00201 double m_position;
00202 WPXTabAlignment m_alignment;
00203 uint32_t m_leaderCharacter;
00204 uint8_t m_leaderNumSpaces;
00205 };
00206
00207
00208
00209 class VersionException
00210 {
00211 };
00212
00213 class FileException
00214 {
00215 };
00216
00217 class ParseException
00218 {
00219 };
00220
00221 class GenericException
00222 {
00223 };
00224
00225 class UnsupportedEncryptionException
00226 {
00227 };
00228
00229 class SupportedEncryptionException
00230 {
00231 };
00232
00233 class WrongPasswordException
00234 {
00235 };
00236
00237
00238
00239 int _extractNumericValueFromRoman(const char romanChar);
00240 int _extractDisplayReferenceNumberFromBuf(const WPXString &buf, const WPXNumberingType listType);
00241 WPXNumberingType _extractWPXNumberingTypeFromBuf(const WPXString &buf, const WPXNumberingType putativeWPXNumberingType);
00242 WPXString _numberingTypeToString(WPXNumberingType t);
00243 extern const uint32_t macRomanCharacterMap[];
00244 WPXString doubleToString(const double value);
00245
00246 #endif
00247