Go to the documentation of this file.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
00028
00029
00030 #ifndef __LIBMSPUB_UTILS_H__
00031 #define __LIBMSPUB_UTILS_H__
00032
00033 #include <stdio.h>
00034 #include <vector>
00035 #include <map>
00036 #include <libwpd/libwpd.h>
00037 #include <libwpd-stream/libwpd-stream.h>
00038
00039 #include "MSPUBTypes.h"
00040
00041 #ifdef _MSC_VER
00042
00043 typedef unsigned char uint8_t;
00044 typedef unsigned short uint16_t;
00045 typedef unsigned uint32_t;
00046 typedef signed char int8_t;
00047 typedef short int16_t;
00048 typedef int int32_t;
00049 typedef unsigned __int64 uint64_t;
00050
00051 #else
00052
00053 #ifdef HAVE_CONFIG_H
00054
00055 #include <config.h>
00056
00057 #ifdef HAVE_STDINT_H
00058 #include <stdint.h>
00059 #endif
00060
00061 #ifdef HAVE_INTTYPES_H
00062 #include <inttypes.h>
00063 #endif
00064
00065 #else
00066
00067
00068 #include <stdint.h>
00069 #include <inttypes.h>
00070
00071 #endif
00072
00073 #endif
00074
00075
00076
00077
00078
00079 #ifdef DEBUG
00080 #ifdef VERBOSE_DEBUG
00081 #define MSPUB_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
00082 #define MSPUB_DEBUG(M) M
00083 #else
00084 #define MSPUB_DEBUG_MSG(M) printf M
00085 #define MSPUB_DEBUG(M) M
00086 #endif
00087 #else
00088 #define MSPUB_DEBUG_MSG(M)
00089 #define MSPUB_DEBUG(M)
00090 #endif
00091
00092 namespace libmspub
00093 {
00094 const char *mimeByImgType(ImgType type);
00095 const char *windowsCharsetNameByOriginalCharset(const char *name);
00096
00097 uint8_t readU8(WPXInputStream *input);
00098 uint16_t readU16(WPXInputStream *input);
00099 uint32_t readU32(WPXInputStream *input);
00100 uint64_t readU64(WPXInputStream *input);
00101 int8_t readS8(WPXInputStream *input);
00102 int16_t readS16(WPXInputStream *input);
00103 int32_t readS32(WPXInputStream *input);
00104 double readFixedPoint(WPXInputStream *input);
00105 double toFixedPoint(int fp);
00106 void readNBytes(WPXInputStream *input, unsigned long length, std::vector<unsigned char> &out);
00107
00108 void appendCharacters(WPXString &text, std::vector<unsigned char> characters, const char *encoding);
00109
00110 bool stillReading(WPXInputStream *input, unsigned long until);
00111
00112 void rotateCounter(double &x, double &y, double centerX, double centerY, short rotation);
00113 void flipIfNecessary(double &x, double &y, double centerX, double centerY, bool flipVertical, bool flipHorizontal);
00114
00115 unsigned correctModulo(int x, unsigned n);
00116 double doubleModulo(double x, double y);
00117
00118 template <class MapT> typename MapT::mapped_type *getIfExists(MapT &map, const typename MapT::key_type &key)
00119 {
00120 typename MapT::iterator i = map.find(key);
00121 return i == map.end() ? NULL : &(i->second);
00122 }
00123
00124 template <class MapT> const typename MapT::mapped_type *getIfExists_const(MapT &map, const typename MapT::key_type &key)
00125 {
00126 typename MapT::const_iterator i = map.find(key);
00127 return i == map.end() ? NULL : &(i->second);
00128 }
00129
00130 template <class MapT> typename MapT::mapped_type ptr_getIfExists(MapT &map, const typename MapT::key_type &key)
00131 {
00132 typename MapT::iterator i = map.find(key);
00133 return i == map.end() ? NULL : i->second;
00134 }
00135
00136 class EndOfStreamException
00137 {
00138 };
00139
00140 class GenericException
00141 {
00142 };
00143
00144 WPXBinaryData inflateData(WPXBinaryData);
00145
00146 }
00147
00148 #endif // __LIBMSPUB_UTILS_H__
00149