00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef XAP_APP_H
00025 #define XAP_APP_H
00026
00027
00028
00029
00030
00031 #ifndef UT_TYPES_H
00032 #include "ut_types.h"
00033 #endif
00034 #include "ut_vector.h"
00035 #include "ut_hash.h"
00036 #include "ut_Language.h"
00037 #include "ut_string_class.h"
00038 #include "xap_AppImpl.h"
00039 #include "xav_Listener.h"
00040 #include <map>
00041 #include <string>
00042 #include <list>
00043
00044 #define NUM_MODELESSID 39
00045
00046 class XAP_DialogFactory;
00047 class XAP_Dialog_Modeless;
00048 class XAP_Toolbar_ControlFactory;
00049 class XAP_Frame;
00050 class EV_EditMethodContainer;
00051 class EV_EditBindingMap;
00052 class EV_EditEventMapper;
00053 class EV_Menu_ActionSet;
00054 class EV_Toolbar_ActionSet;
00055 class XAP_BindingSet;
00056 class XAP_Prefs;
00057 class XAP_StringSet;
00058 class XAP_Dictionary;
00059 class PD_DocumentRange;
00060 class AV_View;
00061 class AD_Document;
00062 class XAP_EncodingManager;
00063 class UT_String;
00064 class XAP_Menu_Factory;
00065 class XAP_Toolbar_Factory;
00066 class UT_UUIDGenerator;
00067 class GR_GraphicsFactory;
00068 class GR_Graphics;
00069 class GR_AllocInfo;
00070 class XAP_InputModes;
00071 class AV_Listener;
00072 class GR_EmbedManager;
00073 class XAP_Module;
00074 class UT_ScriptLibrary;
00075
00076
00077 #define XAP_SD_FILENAME_LENGTH 256
00078 #define XAP_SD_MAX_FILES 5
00079
00085 struct ABI_EXPORT XAP_StateData
00086 {
00087 XAP_StateData();
00088 UT_uint32 iFileCount;
00089 char filenames[XAP_SD_MAX_FILES][XAP_SD_FILENAME_LENGTH];
00090 UT_uint32 iDocPos[XAP_SD_MAX_FILES];
00091 UT_sint32 iXScroll[XAP_SD_MAX_FILES];
00092 UT_sint32 iYScroll[XAP_SD_MAX_FILES];
00093 };
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 class ABI_EXPORT XAP_App
00104 {
00105 public:
00106 static const char* s_szBuild_ID;
00107 static const char* s_szBuild_Version;
00108 static const char* s_szBuild_Options;
00109 static const char* s_szBuild_Target;
00110 static const char* s_szBuild_CompileTime;
00111 static const char* s_szBuild_CompileDate;
00112 static const char* s_szAbiSuite_Home;
00113
00114 public:
00115 static const char* getBuildId ();
00116 static const char* getBuildVersion ();
00117 static const char* getBuildOptions ();
00118 static const char* getBuildTarget ();
00119 static const char* getBuildCompileTime ();
00120 static const char* getBuildCompileDate ();
00121 static const char* getAbiSuiteHome ();
00122
00123 public:
00124 XAP_App(const char * szAppName);
00125 virtual ~XAP_App();
00126
00127 XAP_AppImpl* getImpl()
00128 { return m_pImpl; }
00129
00130 virtual const char * getDefaultEncoding () const = 0 ;
00131
00132 virtual bool initialize(const char * szKeyBindingsKey, const char * szKeyBindingsDefaultValue);
00133 virtual bool rememberFrame(XAP_Frame* pFrame, XAP_Frame* pCloneOf = 0);
00134 virtual bool forgetFrame(XAP_Frame * pFrame);
00135 virtual bool forgetClones(XAP_Frame * pFrame);
00136 virtual bool getClones(UT_GenericVector<XAP_Frame*> *pvClonesCopy, XAP_Frame * pFrame);
00137 virtual XAP_Frame * newFrame() = 0;
00138 virtual void reallyExit() = 0;
00139
00140 bool updateClones(XAP_Frame * pFrame);
00141
00142 virtual void notifyFrameCountChange ();
00143 UT_sint32 getFrameCount() const;
00144 XAP_Frame * getFrame(UT_sint32 ndx) const;
00145 UT_sint32 findFrame(XAP_Frame * pFrame) const;
00146 UT_sint32 findFrame(const char * szFilename) const;
00147
00148 void enumerateFrames(UT_Vector & v) const;
00149 std::list< AD_Document* > getDocuments( const AD_Document * pExclude = 0 ) const;
00150 void enumerateDocuments(UT_Vector & v, const AD_Document * pExclude) const;
00151 const char * getApplicationTitleForTitleBar() const;
00152 const char * getApplicationName() const;
00153
00154 virtual void rebuildMenus(void);
00155
00156 EV_EditMethodContainer * getEditMethodContainer() const;
00157 EV_EditBindingMap * getBindingMap(const char * szName);
00158 XAP_BindingSet * getBindingSet(void)
00159 { return m_pBindingSet;}
00160 const EV_Menu_ActionSet * getMenuActionSet() const;
00161 const EV_Toolbar_ActionSet * getToolbarActionSet() const;
00162 const XAP_EncodingManager * getEncodingManager() const;
00163 EV_Menu_ActionSet * getMenuActionSet();
00164 EV_Toolbar_ActionSet * getToolbarActionSet();
00165
00166
00167 bool addWordToDict(const UT_UCSChar * pWord, UT_uint32 len);
00168 bool isWordInDict(const UT_UCSChar * pWord, UT_uint32 len) const;
00169 void suggestWord(UT_GenericVector<UT_UCSChar*> * pVecSuggestions, const UT_UCSChar * pWord, UT_uint32 lenWord);
00170 XAP_Prefs * getPrefs() const;
00171 bool getPrefsValue(const gchar * szKey, const gchar ** pszValue) const;
00172 bool getPrefsValue(const UT_String &stKey, UT_String &stValue) const;
00173 bool getPrefsValueBool(const gchar * szKey, bool * pbValue) const;
00174
00175 static XAP_App * getApp();
00176
00177 virtual XAP_DialogFactory * getDialogFactory() = 0;
00178 virtual XAP_Toolbar_ControlFactory * getControlFactory() = 0;
00179
00180 virtual const XAP_StringSet * getStringSet() const = 0;
00181 virtual void migrate(const char *oldName, const char *newName, const char *path) const;
00182 virtual const char * getUserPrivateDirectory() = 0;
00183 virtual const char * getAbiSuiteLibDir() const;
00184 virtual const char * getAbiSuiteAppDir() const = 0;
00185 virtual bool findAbiSuiteLibFile(UT_String & path, const char * filename, const char * subdir = 0);
00186 virtual bool findAbiSuiteAppFile(UT_String & path, const char * filename, const char * subdir = 0);
00187 virtual void copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard = true) = 0;
00188 virtual void pasteFromClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard, bool bHonorFormatting = true) = 0;
00189 virtual bool canPasteFromClipboard() = 0;
00190 virtual void cacheCurrentSelection(AV_View *) = 0;
00191 virtual void addClipboardFmt (const char * ) {}
00192 virtual void deleteClipboardFmt (const char * ) {}
00193 void rememberFocussedFrame(void * pJustFocussedFrame);
00194 XAP_Frame * getLastFocussedFrame() const;
00195 XAP_Frame * findValidFrame() const;
00196 bool safeCompare(XAP_Frame * lff, XAP_Frame * f);
00197 UT_sint32 safefindFrame(XAP_Frame * f) const;
00198 void clearLastFocussedFrame();
00199 void clearIdTable();
00200 bool setDebugBool(void) { m_bDebugBool = true; return m_bDebugBool; }
00201 bool clearDebugBool(void) { m_bDebugBool = false; return m_bDebugBool; }
00202 bool isDebug(void) { return m_bDebugBool; }
00203 void rememberModelessId(UT_sint32 id, XAP_Dialog_Modeless * pDialog);
00204 void forgetModelessId(UT_sint32 id);
00205 bool isModelessRunning(UT_sint32 id);
00206 XAP_Dialog_Modeless * getModelessDialog(UT_sint32 id);
00207 void closeModelessDlgs();
00208 void notifyModelessDlgsOfActiveFrame(XAP_Frame *p_Frame);
00209 void notifyModelessDlgsCloseFrame(XAP_Frame *p_Frame);
00210
00211 virtual void setViewSelection(AV_View * ) {};
00212 virtual AV_View * getViewSelection() { return static_cast<AV_View *>(NULL);} ;
00213
00214 virtual bool setGeometry(UT_sint32 x, UT_sint32 y,
00215 UT_uint32 width, UT_uint32 height, UT_uint32 flags = 0);
00216 virtual bool getGeometry(UT_sint32 *x, UT_sint32 *y,
00217 UT_uint32 *width, UT_uint32 *height, UT_uint32 *flags = 0);
00218 virtual void parseAndSetGeometry(const char *string);
00219 virtual UT_sint32 makeDirectory(const char * szPath, const UT_sint32 mode ) const = 0;
00220 XAP_Menu_Factory * getMenuFactory(void) const { return m_pMenuFactory; }
00221 XAP_Toolbar_Factory * getToolbarFactory(void) const { return m_pToolbarFactory; }
00222
00223 typedef enum {BIDI_SUPPORT_NONE, BIDI_SUPPORT_GUI, BIDI_SUPPORT_FULL} BidiSupportType;
00224
00225 virtual BidiSupportType theOSHasBidiSupport() const {return BIDI_SUPPORT_NONE;}
00226 void setEnableSmoothScrolling(bool b);
00227 bool isSmoothScrollingEnabled(void) { return m_bEnableSmoothScrolling; }
00228
00229 void setBonoboRunning(void) { m_bBonoboRunning = true; }
00230 bool isBonoboRunning(void) const { return m_bBonoboRunning; }
00231 virtual void getDefaultGeometry(UT_uint32& ,
00232 UT_uint32& ,
00233 UT_uint32& ) {}
00234
00235 const UT_LangRecord * getKbdLanguage() const { return m_pKbdLang; }
00236 void setKbdLanguage(const char * pszLang);
00237
00238 UT_UUIDGenerator * getUUIDGenerator() const { return m_pUUIDGenerator; }
00239 std::string createUUIDString() const;
00240
00241 bool openURL(const char * url) { return m_pImpl->openURL(url); }
00242 bool openHelpURL(const char * url) { return m_pImpl->openHelpURL(url); }
00243 UT_String localizeHelpUrl(const char * pathBeforeLang,
00244 const char * pathAfterLang, const char * remoteURLbase)
00245 { return m_pImpl->localizeHelpUrl(pathBeforeLang, pathAfterLang, remoteURLbase); }
00246
00247 GR_GraphicsFactory * getGraphicsFactory() const { return m_pGraphicsFactory; }
00248 void setDefaultGraphicsId(UT_uint32 i);
00249
00250 GR_Graphics * newGraphics(GR_AllocInfo &ai) const;
00251
00252 GR_Graphics * newGraphics(UT_uint32 iClassId, GR_AllocInfo &ai) const;
00253 virtual GR_Graphics * newDefaultScreenGraphics() const = 0;
00254
00255 virtual UT_sint32 setInputMode(const char * szName, bool bForce=false);
00256 const char * getInputMode() const;
00257 EV_EditEventMapper * getEditEventMapper() const;
00258 bool addListener(AV_Listener * pListener, AV_ListenerId * pListenerId);
00259 bool removeListener(AV_ListenerId listenerId);
00260 virtual bool notifyListeners(AV_View * pView, const AV_ChangeMask hint,void * pPrivateData = NULL);
00261
00262 bool registerEmbeddable(GR_EmbedManager * pEmbed, const char *uid = NULL);
00263 bool unRegisterEmbeddable(const char *uid);
00264 GR_EmbedManager * getEmbeddableManager(GR_Graphics * pG, const char * szObjectType);
00265 XAP_Module * getPlugin(const char * szPluginName);
00266
00267 static const char* findNearestFont(const char* pszFontFamily,
00268 const char* pszFontStyle,
00269 const char* pszFontVariant,
00270 const char* pszFontWeight,
00271 const char* pszFontStretch,
00272 const char* pszFontSize,
00273 const char* pszLang);
00274
00275 bool saveState(bool bQuit);
00276 bool retrieveState();
00277 virtual void clearStateInfo(){};
00278
00279 bool getDisableDoubleBuffering() const;
00280 void setDisableDoubleBuffering( bool v );
00281 bool getNoGUI() const;
00282 void setNoGUI( bool v );
00283
00284 protected:
00285 void _setAbiSuiteLibDir(const char * sz);
00286 virtual const char * _getKbdLanguage() {return NULL;}
00287 void _setUUIDGenerator(UT_UUIDGenerator * pG) { m_pUUIDGenerator = pG; }
00288
00289 virtual bool _saveState(XAP_StateData & sd);
00290 virtual bool _retrieveState(XAP_StateData & sd);
00291
00292 const char * m_szAppName;
00293 const char * m_szAbiSuiteLibDir;
00294
00295 EV_EditMethodContainer * m_pEMC;
00296 XAP_BindingSet * m_pBindingSet;
00297 EV_Menu_ActionSet * m_pMenuActionSet;
00298 EV_Toolbar_ActionSet * m_pToolbarActionSet;
00299 XAP_Dictionary * m_pDict;
00300 XAP_Prefs * m_prefs;
00301
00302 UT_GenericVector<XAP_Frame*> m_vecFrames;
00303 UT_GenericStringMap<UT_GenericVector<XAP_Frame*>*> m_hashClones;
00304 XAP_Frame * m_lastFocussedFrame;
00305 XAP_Menu_Factory * m_pMenuFactory;
00306 XAP_Toolbar_Factory * m_pToolbarFactory;
00307
00308 struct modeless_pair
00309 {
00310 UT_sint32 id;
00311 XAP_Dialog_Modeless * pDialog;
00312 } m_IdTable[NUM_MODELESSID+1];
00313
00314 static XAP_App * m_pApp;
00315 bool m_bAllowCustomizing;
00316 bool m_bAreCustomized;
00317 bool m_bDebugBool;
00318 bool m_bBonoboRunning;
00319 bool m_bEnableSmoothScrolling;
00320 bool m_bDisableDoubleBuffering;
00321 bool m_bNoGUI;
00322 private:
00323 const UT_LangRecord * m_pKbdLang;
00324 UT_UUIDGenerator * m_pUUIDGenerator;
00325
00326 GR_GraphicsFactory * m_pGraphicsFactory;
00327 UT_uint32 m_iDefaultGraphicsId;
00328
00329 XAP_InputModes * m_pInputModes;
00330 std::map<std::string, GR_EmbedManager *> m_mapEmbedManagers;
00331 XAP_App(const XAP_App&);
00332 void operator=(const XAP_App&);
00333 #ifdef DEBUG
00334 void _fundamentalAsserts() const;
00335 #endif
00336 XAP_AppImpl* m_pImpl;
00337 UT_GenericVector<AV_Listener *> m_vecPluginListeners;
00338 UT_ScriptLibrary * m_pScriptLibrary;
00339 };
00340
00341 #endif