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
00045
00046
00047 class ABI_EXPORT UT_Rect
00048 {
00049 public:
00050 UT_Rect();
00051 UT_Rect(UT_sint32 iLeft, UT_sint32 iTop, UT_sint32 iWidth, UT_sint32 iHeight);
00052 UT_Rect(const UT_Rect &);
00053 UT_Rect(const UT_Rect * r);
00054
00055 bool containsPoint(UT_sint32 x, UT_sint32 y) const;
00056 void set(UT_sint32 iLeft, UT_sint32 iTop, UT_sint32 iWidth, UT_sint32 iHeight);
00057 bool intersectsRect(const UT_Rect * pRect) const;
00058 void unionRect( const UT_Rect *pRect);
00059 UT_sint32 left;
00060 UT_sint32 top;
00061 UT_sint32 width;
00062 UT_sint32 height;
00063 };
00064
00065
00066 struct ABI_EXPORT UT_Point
00067 {
00068 UT_sint32 x;
00069 UT_sint32 y;
00070 };
00071
00072 #define UT_MAX(A,B) (((A) > (B)) ? (A) : (B))
00073 #define UT_MIN(A,B) (((A) < (B)) ? (A) : (B))
00074 #define UT_ABS(A) ( ((A) < 0) ? (-(A)) : (A) )
00075
00076 std::string UT_pathSuffix(std::string path);
00077 bool UT_addOrReplacePathSuffix(std::string & sPath, const char* sSuffix);
00078
00079 bool UT_isWordDelimiter(UT_UCSChar currentChar, UT_UCSChar followChar, UT_UCSChar prevChar);
00080 ABI_EXPORT const gchar* UT_getAttribute(const gchar* name,
00081 const gchar** atts);
00082
00083 ABI_EXPORT gchar ** UT_cloneAndDecodeAttributes (const gchar ** attrs);
00084
00085 UT_sint32 signedHiWord(UT_uint32 dw);
00086 UT_sint32 signedLoWord(UT_uint32 dw);
00087
00088 UT_GenericVector<UT_String*> * simpleSplit (const UT_String & str, char separator = ' ',
00089 size_t max = 0 );
00090
00091 void warpString(UT_String& str, size_t col_max = 75);
00092 UT_uint32 UT_HeadingDepth(const char * szHeadName);
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 #define UT_UID_INVALID 0xffffffff
00103 class ABI_EXPORT UT_UniqueId
00104 {
00105 public:
00106 UT_UniqueId();
00107 ~UT_UniqueId(){};
00108
00109 enum idType
00110 {
00111 List = 0,
00112 Footnote,
00113 Endnote,
00114 Annotation,
00115 HeaderFtr,
00116 Image,
00117 Math,
00118 Embed,
00119
00120
00121 _Last
00122 };
00123
00124 UT_uint32 getUID(idType t);
00125 bool setMinId(idType t, UT_uint32 iMin);
00126 bool isIdUnique(idType t, UT_uint32 iId) const;
00127
00128 private:
00129 UT_uint32 m_iID[(UT_uint32)_Last];
00130 };
00131
00132 ABI_EXPORT bool UT_parseBool (const char * param, bool dfl);
00133
00134
00135 #if 0
00136
00137
00138
00139 #include <time.h>
00140
00141 typedef signed long suseconds_t;
00142
00143 struct timeval
00144 {
00145 time_t tv_sec;
00146 suseconds_t tv_usec;
00147 };
00148 #endif
00149
00155 void UT_gettimeofday(struct timeval *tv);
00156
00157 typedef unsigned char UT_EthernetAddress[6];
00161 bool UT_getEthernetAddress(UT_EthernetAddress &a);
00162
00163 class ABI_EXPORT UT_VersionInfo
00164 {
00165 public:
00166 UT_VersionInfo(UT_uint32 maj, UT_uint32 min, UT_uint32 mic, UT_uint32 nan)
00167 : m_iMajor(maj), m_iMinor(min), m_iMicro(mic), m_iNano(nan) {};
00168
00169 UT_VersionInfo()
00170 : m_iMajor(0), m_iMinor(0), m_iMicro(0), m_iNano(0) {};
00171
00172 UT_uint32 getMajor() const {return m_iMajor;}
00173 UT_uint32 getMinor() const {return m_iMinor;}
00174 UT_uint32 getMicro() const {return m_iMicro;}
00175 UT_uint32 getNano() const {return m_iNano;}
00176
00177 void set(UT_uint32 maj, UT_uint32 min, UT_uint32 mic, UT_uint32 nan)
00178 {m_iMajor = maj; m_iMinor = min; m_iMicro = mic; m_iNano = nan;}
00179
00180 bool operator > (const UT_VersionInfo &v) const
00181 {
00182 if(m_iMajor > v.m_iMajor)
00183 return true;
00184 if(m_iMajor < v.m_iMajor)
00185 return false;
00186
00187 if(m_iMinor > v.m_iMinor)
00188 return true;
00189 if(m_iMinor < v.m_iMinor)
00190 return false;
00191
00192 if(m_iMicro > v.m_iMicro)
00193 return true;
00194 if(m_iMicro < v.m_iMicro)
00195 return false;
00196
00197 if(m_iNano > v.m_iNano)
00198 return true;
00199 if(m_iNano < v.m_iNano)
00200 return false;
00201
00202 return false;
00203 }
00204
00205 const UT_UTF8String & getString() const;
00206
00207
00208 private:
00209 UT_uint32 m_iMajor;
00210 UT_uint32 m_iMinor;
00211 UT_uint32 m_iMicro;
00212 UT_uint32 m_iNano;
00213 };
00214
00215
00216
00217
00218
00219
00220
00221
00222 const gchar ** UT_setPropsToNothing(const gchar ** props);
00223
00224 const gchar ** UT_setPropsToValue(const gchar ** props, const gchar * value);
00225
00226 const gchar ** UT_splitPropsToArray(gchar * props);
00227
00228 UT_uint64 UT_hash64(const char * p, UT_uint32 bytelen = 0);
00229 UT_uint32 UT_hash32(const char * p, UT_uint32 bytelen = 0);
00230
00231
00232 #ifdef TOOLKIT_GTK
00233 #include <gtk/gtk.h>
00234 typedef GtkWidget AbiNativeWidget;
00235 #else
00236
00237 typedef void AbiNativeWidget;
00238 #endif
00239
00240 #endif