libwps_internal.h

Go to the documentation of this file.
00001 /* libwps
00002  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
00003  * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00018  *
00019  * For further information visit http://libwps.sourceforge.net
00020  */
00021 
00022 #ifndef LIBWPS_INTERNAL_H
00023 #define LIBWPS_INTERNAL_H
00024 #ifdef DEBUG
00025 #include <bitset>
00026 #endif
00027 #include "WPSStream.h"
00028 #include <libwpd/WPXString.h>
00029 #include <libwpd/libwpd_types.h>
00030 #include <string>
00031 #include <cstring>
00032 
00033 /* Various functions/defines that need not/should not be exported externally */
00034 
00035 #define DELETEP(m) if (m) { delete m; m = NULL; }
00036  
00037 #ifdef DEBUG
00038 #define WPS_DEBUG_MSG(M) printf M
00039 #else
00040 #define WPS_DEBUG_MSG(M)
00041 #endif
00042 
00043 #define WPS_LE_GET_GUINT16(p)                             \
00044         (uint16_t)((((uint8_t const *)(p))[0] << 0)  |    \
00045                   (((uint8_t const *)(p))[1] << 8))
00046 #define WPS_LE_GET_GUINT32(p) \
00047         (uint32_t)((((uint8_t const *)(p))[0] << 0)  |    \
00048                   (((uint8_t const *)(p))[1] << 8)  |    \
00049                   (((uint8_t const *)(p))[2] << 16) |    \
00050                   (((uint8_t const *)(p))[3] << 24))
00051 
00052 // add more of these as needed for byteswapping
00053 // (the 8-bit functions are just there to make things consistent)
00054 uint8_t readU8(WPSInputStream *input); 
00055 uint16_t readU16(WPSInputStream *input, bool bigendian=false);
00056 uint32_t readU32(WPSInputStream *input, bool bigendian=false);
00057 
00058 // Various helper structures for the parser..
00059 
00060 uint16_t fixedPointToWPUs(const uint32_t fixedPointNumber);
00061 
00062 enum WPSNumberingType { ARABIC, LOWERCASE, UPPERCASE, LOWERCASE_ROMAN, UPPERCASE_ROMAN };
00063 enum WPSNoteType { FOOTNOTE, ENDNOTE };
00064 enum WPSHeaderFooterType { HEADER, FOOTER };
00065 enum WPSHeaderFooterInternalType { HEADER_A, HEADER_B, FOOTER_A, FOOTER_B, DUMMY };
00066 enum WPSHeaderFooterOccurence { ODD, EVEN, ALL, NEVER };
00067 enum WPSFormOrientation { PORTRAIT, LANDSCAPE };
00068 enum WPSTabAlignment { LEFT, RIGHT, CENTER, DECIMAL, BAR };
00069 enum WPSVerticalAlignment { TOP, MIDDLE, BOTTOM, FULL };
00070 
00071 enum WPSTextColumnType { NEWSPAPER, NEWSPAPER_VERTICAL_BALANCE, PARALLEL, PARALLEL_PROTECT };
00072 
00073 // ATTRIBUTE bits
00074 #define WPS_EXTRA_LARGE_BIT 1
00075 #define WPS_VERY_LARGE_BIT 2
00076 #define WPS_LARGE_BIT 4
00077 #define WPS_SMALL_PRINT_BIT 8
00078 #define WPS_FINE_PRINT_BIT 16
00079 #define WPS_SUPERSCRIPT_BIT 32
00080 #define WPS_SUBSCRIPT_BIT 64
00081 #define WPS_OUTLINE_BIT 128
00082 #define WPS_ITALICS_BIT 256
00083 #define WPS_SHADOW_BIT 512
00084 #define WPS_REDLINE_BIT 1024
00085 #define WPS_DOUBLE_UNDERLINE_BIT 2048
00086 #define WPS_BOLD_BIT 4096
00087 #define WPS_STRIKEOUT_BIT 8192
00088 #define WPS_UNDERLINE_BIT 16384
00089 #define WPS_SMALL_CAPS_BIT 32768
00090 #define WPS_BLINK_BIT 65536
00091 #define WPS_REVERSEVIDEO_BIT 131072
00092 
00093 // JUSTIFICATION bits
00094 #define WPS_PARAGRAPH_JUSTIFICATION_LEFT 0x00
00095 #define WPS_PARAGRAPH_JUSTIFICATION_FULL 0x01
00096 #define WPS_PARAGRAPH_JUSTIFICATION_CENTER 0x02
00097 #define WPS_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
00098 #define WPS_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
00099 #define WPS_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
00100 
00101 // BREAK bits
00102 #define WPS_PAGE_BREAK 0x00
00103 #define WPS_SOFT_PAGE_BREAK 0x01
00104 #define WPS_COLUMN_BREAK 0x02
00105 
00106 // Generic bits
00107 #define WPS_LEFT 0x00
00108 #define WPS_RIGHT 0x01
00109 #define WPS_CENTER 0x02
00110 #define WPS_TOP 0x03
00111 #define WPS_BOTTOM 0x04
00112 
00113 typedef struct _RGBSColor RGBSColor;
00114 struct _RGBSColor
00115 {
00116         _RGBSColor(uint8_t r, uint8_t g, uint8_t b, uint8_t s);
00117         _RGBSColor(uint16_t red, uint16_t green, uint16_t blue); // Construct
00118         // RBBSColor from double precision RGB color used by WP3.x for Mac
00119         _RGBSColor(); // initializes all values to 0
00120         uint8_t m_r;
00121         uint8_t m_g;
00122         uint8_t m_b;
00123         uint8_t m_s;
00124 };
00125 
00126 typedef struct _WPSColumnDefinition WPSColumnDefinition;
00127 struct _WPSColumnDefinition
00128 {
00129         _WPSColumnDefinition(); // initializes all values to 0
00130         float m_width;
00131         float m_leftGutter;
00132         float m_rightGutter;
00133 };
00134 
00135 typedef struct _WPSColumnProperties WPSColumnProperties;
00136 struct _WPSColumnProperties
00137 {
00138         _WPSColumnProperties();
00139         uint32_t m_attributes;
00140         uint8_t m_alignment;
00141 };
00142 
00143 typedef struct _WPSTabStop WPSTabStop;
00144 struct _WPSTabStop
00145 {
00146         _WPSTabStop(float position, WPSTabAlignment alignment, uint16_t leaderCharacter, uint8_t leaderNumSpaces);
00147         _WPSTabStop();
00148         float m_position;
00149         WPSTabAlignment m_alignment;
00150         uint16_t m_leaderCharacter;
00151         uint8_t m_leaderNumSpaces;
00152 };
00153 
00154 // Various exceptions
00155 
00156 class VersionException
00157 {
00158         // needless to say, we could flesh this class out a bit
00159 };
00160 
00161 class FileException
00162 {
00163         // needless to say, we could flesh this class out a bit
00164 };
00165 
00166 class ParseException
00167 {
00168         // needless to say, we could flesh this class out a bit
00169 };
00170 
00171 class GenericException
00172 {
00173         // needless to say, we could flesh this class out a bit
00174 };
00175 
00176 // Various functions
00177 
00178 std::string to_bits(std::string s);
00179 
00180 #endif /* LIBWPS_INTERNAL_H */

Generated on Mon Sep 10 13:52:18 2007 for libwps by doxygen 1.5.3