libwps_internal.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
00004  * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00019  *
00020  * For further information visit http://libwps.sourceforge.net
00021  */
00022 
00023 #ifndef LIBWPS_INTERNAL_H
00024 #define LIBWPS_INTERNAL_H
00025 #include <libwpd-stream/libwpd-stream.h>
00026 #include <libwpd/libwpd.h>
00027 #include <string>
00028 
00029 #if defined(_MSC_VER) || defined(__DJGPP__)
00030 typedef signed char int8_t;
00031 typedef unsigned char uint8_t;
00032 typedef signed short int16_t;
00033 typedef unsigned short uint16_t;
00034 typedef signed int int32_t;
00035 typedef unsigned int uint32_t;
00036 #else /* !_MSC_VER && !__DJGPP__*/
00037 #include <inttypes.h>
00038 #endif /* _MSC_VER || __DJGPP__*/
00039 
00040 /* ---------- memory  --------------- */
00041 #ifdef HAVE_CONFIG_H
00042 #include "config.h"
00043 #endif
00044 
00045 #if defined(SHAREDPTR_TR1)
00046 #include <tr1/memory>
00047 using std::tr1::shared_ptr;
00048 #elif defined(SHAREDPTR_STD)
00049 #include <memory>
00050 using std::shared_ptr;
00051 #else
00052 #include <boost/shared_ptr.hpp>
00053 using boost::shared_ptr;
00054 #endif
00055 
00057 template <class T>
00058 struct WPS_shared_ptr_noop_deleter
00059 {
00060         void operator() (T *) {}
00061 };
00062 
00063 /* ---------- typedef ------------- */
00064 typedef shared_ptr<WPXInputStream> WPXInputStreamPtr;
00065 
00066 /* ---------- debug  --------------- */
00067 #ifdef DEBUG
00068 #define WPS_DEBUG_MSG(M) printf M
00069 #else
00070 #define WPS_DEBUG_MSG(M)
00071 #endif
00072 
00073 /* ---------- exception  ------------ */
00074 namespace libwps
00075 {
00076 // Various exceptions
00077 class VersionException
00078 {
00079         // needless to say, we could flesh this class out a bit
00080 };
00081 
00082 class FileException
00083 {
00084         // needless to say, we could flesh this class out a bit
00085 };
00086 
00087 class ParseException
00088 {
00089         // needless to say, we could flesh this class out a bit
00090 };
00091 
00092 class GenericException
00093 {
00094         // needless to say, we could flesh this class out a bit
00095 };
00096 }
00097 
00098 /* ---------- input ----------------- */
00099 namespace libwps
00100 {
00101 uint8_t readU8(WPXInputStream *input);
00102 uint16_t readU16(WPXInputStream *input);
00103 uint32_t readU32(WPXInputStream *input);
00104 
00105 int8_t read8(WPXInputStream *input);
00106 int16_t read16(WPXInputStream *input);
00107 int32_t read32(WPXInputStream *input);
00108 
00109 inline uint8_t readU8(WPXInputStreamPtr &input)
00110 {
00111         return readU8(input.get());
00112 }
00113 inline uint16_t readU16(WPXInputStreamPtr &input)
00114 {
00115         return readU16(input.get());
00116 }
00117 inline uint32_t readU32(WPXInputStreamPtr &input)
00118 {
00119         return readU32(input.get());
00120 }
00121 
00122 inline int8_t read8(WPXInputStreamPtr &input)
00123 {
00124         return read8(input.get());
00125 }
00126 inline int16_t read16(WPXInputStreamPtr &input)
00127 {
00128         return read16(input.get());
00129 }
00130 inline int32_t read32(WPXInputStreamPtr &input)
00131 {
00132         return read32(input.get());
00133 }
00134 }
00135 
00136 #define WPS_LE_GET_GUINT16(p)                             \
00137         (uint16_t)((((uint8_t const *)(p))[0] << 0)  |    \
00138                   (((uint8_t const *)(p))[1] << 8))
00139 #define WPS_LE_GET_GUINT32(p) \
00140         (uint32_t)((((uint8_t const *)(p))[0] << 0)  |    \
00141                   (((uint8_t const *)(p))[1] << 8)  |    \
00142                   (((uint8_t const *)(p))[2] << 16) |    \
00143                   (((uint8_t const *)(p))[3] << 24))
00144 
00145 // Various helper structures for the parser..
00146 namespace libwps
00147 {
00148 enum HeaderFooterType { HEADER, FOOTER };
00149 enum HeaderFooterOccurence { ODD, EVEN, ALL, NEVER };
00150 enum FormOrientation { PORTRAIT, LANDSCAPE };
00151 }
00152 
00153 // ATTRIBUTE bits
00154 #define WPS_EXTRA_LARGE_BIT 1
00155 #define WPS_VERY_LARGE_BIT 2
00156 #define WPS_LARGE_BIT 4
00157 #define WPS_SMALL_PRINT_BIT 8
00158 #define WPS_FINE_PRINT_BIT 0x10
00159 #define WPS_SUPERSCRIPT_BIT 0x20
00160 #define WPS_SUBSCRIPT_BIT 0x40
00161 #define WPS_OUTLINE_BIT 0x80
00162 #define WPS_ITALICS_BIT 0x100
00163 #define WPS_SHADOW_BIT 0x200
00164 #define WPS_REDLINE_BIT 0x400
00165 #define WPS_DOUBLE_UNDERLINE_BIT 0x800
00166 #define WPS_BOLD_BIT 0x1000
00167 #define WPS_STRIKEOUT_BIT 0x2000
00168 #define WPS_UNDERLINE_BIT 0x4000
00169 #define WPS_SMALL_CAPS_BIT 0x8000
00170 #define WPS_BLINK_BIT 0x10000L
00171 #define WPS_REVERSEVIDEO_BIT 0x20000L
00172 #define WPS_ALL_CAPS_BIT 0x40000L
00173 #define WPS_EMBOSS_BIT 0x80000L
00174 #define WPS_ENGRAVE_BIT 0x100000L
00175 #define WPS_SPECIAL_BIT 0x200000L
00176 
00177 // JUSTIFICATION bits
00178 #define WPS_PARAGRAPH_JUSTIFICATION_LEFT 0x00
00179 #define WPS_PARAGRAPH_JUSTIFICATION_FULL 0x01
00180 #define WPS_PARAGRAPH_JUSTIFICATION_CENTER 0x02
00181 #define WPS_PARAGRAPH_JUSTIFICATION_RIGHT 0x03
00182 #define WPS_PARAGRAPH_JUSTIFICATION_FULL_ALL_LINES 0x04
00183 #define WPS_PARAGRAPH_JUSTIFICATION_DECIMAL_ALIGNED 0x05
00184 
00185 #define WPS_PARAGRAPH_LAYOUT_NO_BREAK  0x01
00186 #define WPS_PARAGRAPH_LAYOUT_WITH_NEXT 0x02
00187 
00188 #define WPS_TAB_LEFT 0x00
00189 #define WPS_TAB_CENTER 0x01
00190 #define WPS_TAB_RIGHT 0x02
00191 #define WPS_TAB_DECIMAL 0x03
00192 #define WPS_TAB_BAR 0x04
00193 
00194 // BREAK bits
00195 #define WPS_PAGE_BREAK 0x00
00196 #define WPS_SOFT_PAGE_BREAK 0x01
00197 #define WPS_COLUMN_BREAK 0x02
00198 
00199 // Generic bits
00200 #define WPS_LEFT 0x00
00201 #define WPS_RIGHT 0x01
00202 #define WPS_CENTER 0x02
00203 #define WPS_TOP 0x03
00204 #define WPS_BOTTOM 0x04
00205 
00206 // Field codes
00207 #define WPS_FIELD_PAGE 1
00208 #define WPS_FIELD_DATE 2
00209 #define WPS_FIELD_TIME 3
00210 #define WPS_FIELD_FILE 4
00211 
00212 // Bullets and numbering
00213 
00214 #define WPS_NUMBERING_NONE   0
00215 #define WPS_NUMBERING_BULLET 1
00216 #define WPS_NUMBERING_NUMBER 2
00217 
00218 #define WPS_NUM_STYLE_NONE   0
00219 #define WPS_NUM_STYLE_ARABIC 2
00220 #define WPS_NUM_STYLE_LLATIN 3
00221 #define WPS_NUM_STYLE_ULATIN 4
00222 #define WPS_NUM_STYLE_LROMAN 5
00223 #define WPS_NUM_STYLE_UROMAN 6
00224 
00225 #endif /* LIBWPS_INTERNAL_H */
00226 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */