Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

libwpd_internal.h

Go to the documentation of this file.
00001 /* libwpd
00002  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
00003  * Copyright (C) 2002,2004 Marc Maurer (j.m.maurer@student.utwente.nl)
00004  *  
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018  *
00019  * For further information visit http://libwpd.sourceforge.net
00020  */
00021 
00022 /* "This product is not manufactured, approved, or supported by 
00023  * Corel Corporation or Corel Corporation Limited."
00024  */
00025 
00026 #ifndef LIBWPD_INTERNAL_H
00027 #define LIBWPD_INTERNAL_H
00028 #include "WPXStream.h"
00029 #include <stdio.h>
00030 #include "WPXString.h"
00031 
00032 /* Various functions/defines that need not/should not be exported externally */
00033 
00034 #define WPD_CHECK_FILE_ERROR(v) if (v==EOF) { WPD_DEBUG_MSG(("X_CheckFileError: %d\n", __LINE__)); throw FileException(); }
00035 #define WPD_CHECK_FILE_SEEK_ERROR(v) if (v) { WPD_DEBUG_MSG(("X_CheckFileSeekError: %d\n", __LINE__)); throw FileException(); }
00036 #define WPD_CHECK_FILE_READ_ERROR(v,num_elements) if (v != num_elements) {\
00037  WPD_DEBUG_MSG(("X_CheckFileReadElementError: %d\n", __LINE__)); throw FileException(); }
00038 
00039 #define DELETEP(m) if (m) { delete m; m = NULL; }
00040  
00041 #ifdef DEBUG
00042 #define WPD_DEBUG_MSG(M) printf M
00043 #else
00044 #define WPD_DEBUG_MSG(M)
00045 #endif
00046 
00047 #define WPD_LE_GET_GUINT8(p) (*(uint8_t const *)(p))
00048 #define WPD_LE_GET_GUINT16(p)                             \
00049         (uint16_t)((((uint8_t const *)(p))[0] << 0)  |    \
00050                   (((uint8_t const *)(p))[1] << 8))
00051 #define WPD_LE_GET_GUINT32(p) \
00052         (uint32_t)((((uint8_t const *)(p))[0] << 0)  |    \
00053                   (((uint8_t const *)(p))[1] << 8)  |    \
00054                   (((uint8_t const *)(p))[2] << 16) |    \
00055                   (((uint8_t const *)(p))[3] << 24))
00056 
00057 #define WPD_BE_GET_GUINT8(p) (*(uint8_t const *)(p))
00058 #define WPD_BE_GET_GUINT16(p)                           \
00059         (uint16_t)((((uint8_t const *)(p))[1] << 0)  |    \
00060                   (((uint8_t const *)(p))[0] << 8))
00061 #define WPD_BE_GET_GUINT32(p)                           \
00062         (uint32_t)((((uint8_t const *)(p))[3] << 0)  |    \
00063                   (((uint8_t const *)(p))[2] << 8)  |    \
00064                   (((uint8_t const *)(p))[1] << 16) |    \
00065                   (((uint8_t const *)(p))[0] << 24))
00066 
00067 // add more of these as needed for byteswapping
00068 // (the 8-bit functions are just there to make things consistent)
00069 int8_t read8(WPXInputStream *input); 
00070 uint8_t readU8(WPXInputStream *input); 
00071 uint16_t readU16(WPXInputStream *input, bool bigendian=false);
00072 uint32_t readU32(WPXInputStream *input, bool bigendian=false);
00073 
00074 void appendUCS4(WPXString &str, uint32_t ucs4);
00075 
00076 // Various helper structures for the libwpd parser..
00077 
00078 int extendedCharacterToUCS2(uint8_t character, uint8_t characterSet,
00079                             const uint16_t **chars);
00080 
00081 enum WPXFileType { WP6_DOCUMENT, WP5_DOCUMENT, WP42_DOCUMENT, OTHER };
00082 enum WPXNumberingType { ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
00083 enum WPXNoteType { FOOTNOTE, ENDNOTE };
00084 enum WPXHeaderFooterType { HEADER, FOOTER };
00085 enum WPXHeaderFooterOccurence { ODD, EVEN, ALL };
00086 enum WPXFormOrientation { PORTRAIT, LANDSCAPE };
00087 enum WPXTabAlignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
00088 enum WPXVerticalAlignment { TOP, MIDDLE, BOTTOM, FULL };
00089 
00090 enum WPXTextColumnType { NEWSPAPER, NEWSPAPER_VERTICAL_BALANCE, PARALLEL, PARALLEL_PROTECT };
00091 
00092 const float WPX_DEFAULT_LIST_INDENT = 0.2f; // default list indent per level
00093 
00094 // ATTRIBUTE bits
00095 #define WPX_EXTRA_LARGE_BIT 1
00096 #define WPX_VERY_LARGE_BIT 2
00097 #define WPX_LARGE_BIT 4
00098 #define WPX_SMALL_PRINT_BIT 8
00099 #define WPX_FINE_PRINT_BIT 16
00100 #define WPX_SUPERSCRIPT_BIT 32
00101 #define WPX_SUBSCRIPT_BIT 64
00102 #define WPX_OUTLINE_BIT 128
00103 #define WPX_ITALICS_BIT 256
00104 #define WPX_SHADOW_BIT 512
00105 #define WPX_REDLINE_BIT 1024
00106 #define WPX_DOUBLE_UNDERLINE_BIT 2048
00107 #define WPX_BOLD_BIT 4096
00108 #define WPX_STRIKEOUT_BIT 8192
00109 #define WPX_UNDERLINE_BIT 16384
00110 #define WPX_SMALL_CAPS_BIT 32768
00111 #define WPX_BLINK_BIT 65536
00112 #define WPX_REVERSEVIDEO_BIT 131072
00113 
00114 // JUSTIFICATION bits.
00115 #define WPX_PARAGRAPH_JUSTIFICATION_LEFT 0x00
00116 #define WPX_PARAGRAPH_JUSTIFICATION_FULL 0x01
00117 #define WPX_PARAGRAPH_JUSTIFICATION_CENTER 0x02
00118 #define WPX_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
00119 #define WPX_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
00120 #define WPX_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
00121 
00122 // TABLE POSITION bits.
00123 #define WPX_TABLE_POSITION_ALIGN_WITH_LEFT_MARGIN 0x00
00124 #define WPX_TABLE_POSITION_ALIGN_WITH_RIGHT_MARGIN 0x01
00125 #define WPX_TABLE_POSITION_CENTER_BETWEEN_MARGINS 0x02
00126 #define WPX_TABLE_POSITION_FULL 0x03
00127 #define WPX_TABLE_POSITION_ABSOLUTE_FROM_LEFT_MARGIN 0x04
00128 
00129 // TABLE CELL BORDER bits
00130 const uint8_t WPX_TABLE_CELL_LEFT_BORDER_OFF = 0x01;
00131 const uint8_t WPX_TABLE_CELL_RIGHT_BORDER_OFF = 0x02;
00132 const uint8_t WPX_TABLE_CELL_TOP_BORDER_OFF = 0x04;
00133 const uint8_t WPX_TABLE_CELL_BOTTOM_BORDER_OFF = 0x08;
00134 
00135 // BREAK bits
00136 #define WPX_PAGE_BREAK 0x00
00137 #define WPX_SOFT_PAGE_BREAK 0x01
00138 #define WPX_COLUMN_BREAK 0x02
00139 
00140 // Generic bits
00141 #define WPX_LEFT 0x00
00142 #define WPX_RIGHT 0x01
00143 #define WPX_CENTER 0x02
00144 #define WPX_TOP 0x03
00145 #define WPX_BOTTOM 0x04
00146 
00147 typedef struct _RGBSColor RGBSColor;
00148 struct _RGBSColor
00149 {
00150         _RGBSColor(uint8_t r, uint8_t g, uint8_t b, uint8_t s);
00151         _RGBSColor(); // initializes all values to 0
00152         uint8_t m_r;
00153         uint8_t m_g;
00154         uint8_t m_b;
00155         uint8_t m_s;
00156 };
00157 
00158 typedef struct _WPXColumnDefinition WPXColumnDefinition;
00159 struct _WPXColumnDefinition
00160 {
00161         _WPXColumnDefinition(); // initializes all values to 0
00162         float m_width;
00163         float m_leftGutter;
00164         float m_rightGutter;
00165 };
00166 
00167 typedef struct _WPXTabStop WPXTabStop;
00168 struct _WPXTabStop
00169 {
00170         _WPXTabStop(float position, WPXTabAlignment alignment, uint16_t leaderCharacter, uint8_t leaderNumSpaces);
00171         _WPXTabStop();
00172         float m_position;
00173         WPXTabAlignment m_alignment;
00174         uint16_t m_leaderCharacter;
00175         uint8_t m_leaderNumSpaces;
00176 };
00177 
00178 // Various exceptions: libwpd does not propagate exceptions externally..
00179 
00180 class VersionException
00181 {
00182         // needless to say, we could flesh this class out a bit
00183 };
00184 
00185 class FileException
00186 {
00187         // needless to say, we could flesh this class out a bit
00188 };
00189 
00190 class ParseException
00191 {
00192         // needless to say, we could flesh this class out a bit
00193 };
00194 
00195 class GenericException
00196 {
00197         // needless to say, we could flesh this class out a bit
00198 };
00199 
00200 class UnsupportedEncryptionException
00201 {
00202         // needless to say, we could flesh this class out a bit
00203 };
00204 
00205 #endif /* LIBWPD_INTERNAL_H */

Generated on Mon Mar 12 10:11:47 2007 for libwpd by doxygen 1.4.2