00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef UTMISC_H
00021 #define UTMISC_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026
00027
00028
00029
00030
00031 #ifndef UT_TYPES_H
00032 #include "ut_types.h"
00033 #endif
00034
00035 #ifndef UTVECTOR_H
00036 #include "ut_vector.h"
00037 #endif
00038
00039 #include <string>
00040
00041 class UT_Rect;
00042 class UT_String;
00043 class UT_UTF8String;
00044 class PP_AttrProp;
00045
00046
00047
00048 class ABI_EXPORT UT_Rect
00049 {
00050 public:
00051 UT_Rect();
00052 UT_Rect(UT_sint32 iLeft, UT_sint32 iTop, UT_sint32 iWidth, UT_sint32 iHeight);
00053 UT_Rect(const UT_Rect &);
00054 UT_Rect(const UT_Rect * r);
00055
00056 bool containsPoint(UT_sint32 x, UT_sint32 y) const;
00057 void set(UT_sint32 iLeft, UT_sint32 iTop, UT_sint32 iWidth, UT_sint32 iHeight);
00058 bool intersectsRect(const UT_Rect * pRect) const;
00059 void unionRect( const UT_Rect *pRect);
00060 UT_sint32 left;
00061 UT_sint32 top;
00062 UT_sint32 width;
00063 UT_sint32 height;
00064 };
00065
00066
00067 struct ABI_EXPORT UT_Point
00068 {
00069 UT_sint32 x;
00070 UT_sint32 y;
00071 };
00072
00073 #define UT_MAX(A,B) (((A) > (B)) ? (A) : (B))
00074 #define UT_MIN(A,B) (((A) < (B)) ? (A) : (B))
00075 #define UT_ABS(A) ( ((A) < 0) ? (-(A)) : (A) )
00076
00077 std::string UT_pathSuffix(std::string path);
00078 bool UT_addOrReplacePathSuffix(std::string & sPath, const char* sSuffix);
00079
00080 bool UT_isWordDelimiter(UT_UCSChar currentChar, UT_UCSChar followChar, UT_UCSChar prevChar);
00081
00085 ABI_EXPORT const gchar* UT_getAttribute(const gchar* name,
00086 const gchar** atts);
00087
00092 ABI_EXPORT const gchar* UT_getAttribute( const gchar* name,
00093 const gchar** atts, const gchar* def );
00094
00095
00096
00101 ABI_EXPORT bool isTrue( const char* s );
00102
00103
00104
00105 ABI_EXPORT gchar ** UT_cloneAndDecodeAttributes (const gchar ** attrs);
00106
00107 UT_sint32 signedHiWord(UT_uint32 dw);
00108 UT_sint32 signedLoWord(UT_uint32 dw);
00109
00110 UT_GenericVector<UT_String*> * simpleSplit (const UT_String & str, char separator = ' ',
00111 size_t max = 0 );
00112
00113 void warpString(UT_String& str, size_t col_max = 75);
00114 UT_uint32 UT_HeadingDepth(const char * szHeadName);
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 #define UT_UID_INVALID 0xffffffff
00125 class ABI_EXPORT UT_UniqueId
00126 {
00127 public:
00128 UT_UniqueId();
00129 ~UT_UniqueId(){};
00130
00131 enum idType
00132 {
00133 List = 0,
00134 Footnote,
00135 Endnote,
00136 Annotation,
00137 HeaderFtr,
00138 Image,
00139 Math,
00140 Embed,
00141 ODTCTSplit,
00142
00143
00144 _Last
00145 };
00146
00147 UT_uint32 getUID(idType t);
00148 bool setMinId(idType t, UT_uint32 iMin);
00149 bool isIdUnique(idType t, UT_uint32 iId) const;
00150
00151 private:
00152 UT_uint32 m_iID[(UT_uint32)_Last];
00153 };
00154
00155 ABI_EXPORT bool UT_parseBool (const char * param, bool dfl);
00156
00157
00158 #if 0
00159
00160
00161
00162 #include <time.h>
00163
00164 typedef signed long suseconds_t;
00165
00166 struct timeval
00167 {
00168 time_t tv_sec;
00169 suseconds_t tv_usec;
00170 };
00171 #endif
00172
00178 void UT_gettimeofday(struct timeval *tv);
00179
00180 typedef unsigned char UT_EthernetAddress[6];
00184 bool UT_getEthernetAddress(UT_EthernetAddress &a);
00185
00186 class ABI_EXPORT UT_VersionInfo
00187 {
00188 public:
00189 UT_VersionInfo(UT_uint32 maj, UT_uint32 min, UT_uint32 mic, UT_uint32 nan)
00190 : m_iMajor(maj), m_iMinor(min), m_iMicro(mic), m_iNano(nan) {};
00191
00192 UT_VersionInfo()
00193 : m_iMajor(0), m_iMinor(0), m_iMicro(0), m_iNano(0) {};
00194
00195 UT_uint32 getMajor() const {return m_iMajor;}
00196 UT_uint32 getMinor() const {return m_iMinor;}
00197 UT_uint32 getMicro() const {return m_iMicro;}
00198 UT_uint32 getNano() const {return m_iNano;}
00199
00200 void set(UT_uint32 maj, UT_uint32 min, UT_uint32 mic, UT_uint32 nan)
00201 {m_iMajor = maj; m_iMinor = min; m_iMicro = mic; m_iNano = nan;}
00202
00203 bool operator > (const UT_VersionInfo &v) const
00204 {
00205 if(m_iMajor > v.m_iMajor)
00206 return true;
00207 if(m_iMajor < v.m_iMajor)
00208 return false;
00209
00210 if(m_iMinor > v.m_iMinor)
00211 return true;
00212 if(m_iMinor < v.m_iMinor)
00213 return false;
00214
00215 if(m_iMicro > v.m_iMicro)
00216 return true;
00217 if(m_iMicro < v.m_iMicro)
00218 return false;
00219
00220 if(m_iNano > v.m_iNano)
00221 return true;
00222 if(m_iNano < v.m_iNano)
00223 return false;
00224
00225 return false;
00226 }
00227
00228 const UT_UTF8String & getString() const;
00229
00230
00231 private:
00232 UT_uint32 m_iMajor;
00233 UT_uint32 m_iMinor;
00234 UT_uint32 m_iMicro;
00235 UT_uint32 m_iNano;
00236 };
00237
00238
00239
00240
00241
00242
00243
00244
00245 const gchar ** UT_setPropsToNothing(const gchar ** props);
00246
00247 const gchar ** UT_setPropsToValue(const gchar ** props, const gchar * value);
00248
00249 const gchar ** UT_splitPropsToArray(gchar * props);
00250
00251 UT_uint64 UT_hash64(const char * p, UT_uint32 bytelen = 0);
00252 UT_uint32 UT_hash32(const char * p, UT_uint32 bytelen = 0);
00253
00254
00255 #ifdef TOOLKIT_GTK_ALL
00256 #include <gtk/gtk.h>
00257 typedef GtkWidget AbiNativeWidget;
00258 #else
00259
00260 typedef void AbiNativeWidget;
00261 #endif
00262
00263 #endif