1*96821c26SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96821c26SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96821c26SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96821c26SAndrew Rist * distributed with this work for additional information 6*96821c26SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96821c26SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96821c26SAndrew Rist * "License"); you may not use this file except in compliance 9*96821c26SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*96821c26SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*96821c26SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96821c26SAndrew Rist * software distributed under the License is distributed on an 15*96821c26SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96821c26SAndrew Rist * KIND, either express or implied. See the License for the 17*96821c26SAndrew Rist * specific language governing permissions and limitations 18*96821c26SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*96821c26SAndrew Rist *************************************************************/ 21*96821c26SAndrew Rist 22*96821c26SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SCRIPTDOCUMENT_HXX 25cdf0e10cSrcweir #define SCRIPTDOCUMENT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir /** === begin UNO includes === **/ 28cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp> 29cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 30cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicator.hpp> 31cdf0e10cSrcweir #include <com/sun/star/io/XInputStreamProvider.hpp> 32cdf0e10cSrcweir /** === end UNO includes === **/ 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 35cdf0e10cSrcweir #include <vector> 36cdf0e10cSrcweir 37cdf0e10cSrcweir class BasicManager; 38cdf0e10cSrcweir class SfxListener; 39cdf0e10cSrcweir 40cdf0e10cSrcweir //........................................................................ 41cdf0e10cSrcweir namespace basctl 42cdf0e10cSrcweir { 43cdf0e10cSrcweir //........................................................................ 44cdf0e10cSrcweir 45cdf0e10cSrcweir //==================================================================== 46cdf0e10cSrcweir //= LibraryContainerType 47cdf0e10cSrcweir //==================================================================== 48cdf0e10cSrcweir enum LibraryContainerType 49cdf0e10cSrcweir { 50cdf0e10cSrcweir E_SCRIPTS, 51cdf0e10cSrcweir E_DIALOGS 52cdf0e10cSrcweir }; 53cdf0e10cSrcweir 54cdf0e10cSrcweir enum LibraryLocation 55cdf0e10cSrcweir { 56cdf0e10cSrcweir LIBRARY_LOCATION_UNKNOWN, 57cdf0e10cSrcweir LIBRARY_LOCATION_USER, 58cdf0e10cSrcweir LIBRARY_LOCATION_SHARE, 59cdf0e10cSrcweir LIBRARY_LOCATION_DOCUMENT 60cdf0e10cSrcweir }; 61cdf0e10cSrcweir 62cdf0e10cSrcweir enum LibraryType 63cdf0e10cSrcweir { 64cdf0e10cSrcweir LIBRARY_TYPE_UNKNOWN, 65cdf0e10cSrcweir LIBRARY_TYPE_MODULE, 66cdf0e10cSrcweir LIBRARY_TYPE_DIALOG, 67cdf0e10cSrcweir LIBRARY_TYPE_ALL 68cdf0e10cSrcweir }; 69cdf0e10cSrcweir 70cdf0e10cSrcweir //==================================================================== 71cdf0e10cSrcweir //= ScriptDocument 72cdf0e10cSrcweir //==================================================================== 73cdf0e10cSrcweir class ScriptDocument_Impl; 74cdf0e10cSrcweir 75cdf0e10cSrcweir class ScriptDocument; 76cdf0e10cSrcweir typedef ::std::vector< ScriptDocument > ScriptDocuments; 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** encapsulates a document which contains Basic scripts and dialogs 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir class ScriptDocument 81cdf0e10cSrcweir { 82cdf0e10cSrcweir private: 83cdf0e10cSrcweir ::boost::shared_ptr< ScriptDocument_Impl > m_pImpl; 84cdf0e10cSrcweir 85cdf0e10cSrcweir private: 86cdf0e10cSrcweir /** creates a ScriptDocument instance which operates on the application-wide 87cdf0e10cSrcweir scripts and dialogs 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir ScriptDocument(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir public: 92cdf0e10cSrcweir enum SpecialDocument { NoDocument }; 93cdf0e10cSrcweir /** creates a ScriptDocument instance which does refers to neither the application-wide, 94cdf0e10cSrcweir nor a specific real document's scripts. 95cdf0e10cSrcweir 96cdf0e10cSrcweir This constructor might come handy when you need some kind of uninitialized 97cdf0e10cSrcweir ScriptDocument, which you do not want to operate on (yet), but initialize later 98cdf0e10cSrcweir by assignment. 99cdf0e10cSrcweir 100cdf0e10cSrcweir <member>isValid</member> will return <FALSE/> for a ScriptDocument constructed 101cdf0e10cSrcweir this way. 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir explicit ScriptDocument( SpecialDocument _eType ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** creates a ScriptDocument instance which refers to a document given as 106cdf0e10cSrcweir XModel 107cdf0e10cSrcweir 108cdf0e10cSrcweir @param _rxDocument 109cdf0e10cSrcweir the document. Must not be <NULL/>. 110cdf0e10cSrcweir */ 111cdf0e10cSrcweir explicit ScriptDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir /// copy constructor 114cdf0e10cSrcweir ScriptDocument( const ScriptDocument& _rSource ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir /// destructor 117cdf0e10cSrcweir ~ScriptDocument(); 118cdf0e10cSrcweir 119cdf0e10cSrcweir /** returns a reference to a shared ScriptDocument instance which 120cdf0e10cSrcweir operates on the application-wide scripts and dialogs 121cdf0e10cSrcweir */ 122cdf0e10cSrcweir static const ScriptDocument& 123cdf0e10cSrcweir getApplicationScriptDocument(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** returns a (newly created) ScriptDocument instance for the document to 126cdf0e10cSrcweir which a given BasicManager belongs 127cdf0e10cSrcweir 128cdf0e10cSrcweir If the basic manager is the application's basic manager, then the (shared) 129cdf0e10cSrcweir ScriptDocument instance which is responsible for the application is returned. 130cdf0e10cSrcweir 131cdf0e10cSrcweir @see getApplicationScriptDocument 132cdf0e10cSrcweir */ 133cdf0e10cSrcweir static ScriptDocument 134cdf0e10cSrcweir getDocumentForBasicManager( const BasicManager* _pManager ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir /** returns a (newly created) ScriptDocument instance for the document 137cdf0e10cSrcweir with a given caption or URL 138cdf0e10cSrcweir 139cdf0e10cSrcweir If there is no document with the given caption, then the (shared) 140cdf0e10cSrcweir ScriptDocument instance which is responsible for the application is returned. 141cdf0e10cSrcweir 142cdf0e10cSrcweir @see getApplicationScriptDocument 143cdf0e10cSrcweir */ 144cdf0e10cSrcweir static ScriptDocument 145cdf0e10cSrcweir getDocumentWithURLOrCaption( const ::rtl::OUString& _rUrlOrCaption ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir /** operation mode for getAllScriptDocuments 148cdf0e10cSrcweir */ 149cdf0e10cSrcweir enum ScriptDocumentList 150cdf0e10cSrcweir { 151cdf0e10cSrcweir /** all ScriptDocuments, including the dedicated one which represents 152cdf0e10cSrcweir the application-wide scripts/dialogs. 153cdf0e10cSrcweir */ 154cdf0e10cSrcweir AllWithApplication, 155cdf0e10cSrcweir /** real documents only 156cdf0e10cSrcweir */ 157cdf0e10cSrcweir DocumentsOnly, 158cdf0e10cSrcweir /** real documents only, sorted lexicographically by their title (using the sys locale's default 159cdf0e10cSrcweir collator) 160cdf0e10cSrcweir */ 161cdf0e10cSrcweir DocumentsSorted 162cdf0e10cSrcweir }; 163cdf0e10cSrcweir 164cdf0e10cSrcweir /** returns the set of ScriptDocument instances, one for each open document which 165cdf0e10cSrcweir contains Basic/Dialog containers; plus an additional instance for 166cdf0e10cSrcweir the application, if desired 167cdf0e10cSrcweir 168cdf0e10cSrcweir Documents which are not visible - i.e. do not have a visible frame. 169cdf0e10cSrcweir 170cdf0e10cSrcweir @param _bIncludingApplication 171cdf0e10cSrcweir <TRUE/> if the application-wide scripts/dialogs should also be represented 172cdf0e10cSrcweir by a ScriptDocument 173cdf0e10cSrcweir */ 174cdf0e10cSrcweir static ScriptDocuments 175cdf0e10cSrcweir getAllScriptDocuments( ScriptDocumentList _eListType ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir // comparison 178cdf0e10cSrcweir bool operator==( const ScriptDocument& _rhs ) const; operator !=(const ScriptDocument & _rhs) const179cdf0e10cSrcweir inline bool operator!=( const ScriptDocument& _rhs ) const { return !( *this == _rhs ); } 180cdf0e10cSrcweir 181cdf0e10cSrcweir /// retrieves a (pretty simple) hash code for the document 182cdf0e10cSrcweir sal_Int32 hashCode() const; 183cdf0e10cSrcweir 184cdf0e10cSrcweir /** determines whether the document is actually able to contain Basic/Dialog libraries 185cdf0e10cSrcweir 186cdf0e10cSrcweir Note that validity does not automatically imply the document can be used for active 187cdf0e10cSrcweir work. Instead, it is possible the document is closed already (or being closed currently). 188cdf0e10cSrcweir In this case, isValid will return <TRUE/>, but isAlive will return <FALSE/>. 189cdf0e10cSrcweir 190cdf0e10cSrcweir @return 191cdf0e10cSrcweir <TRUE/> if the instance refers to a document which contains Basic/Dialog libraries, 192cdf0e10cSrcweir or the application as a whole, <FALSE/> otherwise. 193cdf0e10cSrcweir 194cdf0e10cSrcweir @see isAlive 195cdf0e10cSrcweir */ 196cdf0e10cSrcweir bool isValid() const; 197cdf0e10cSrcweir 198cdf0e10cSrcweir /** determines whether the document instance is alive 199cdf0e10cSrcweir 200cdf0e10cSrcweir If the instance is not valid, <FALSE/> is returned. 201cdf0e10cSrcweir 202cdf0e10cSrcweir If the instance refers to a real document, which is already closed, or just being closed, 203cdf0e10cSrcweir the method returns <FALSE/>. 204cdf0e10cSrcweir 205cdf0e10cSrcweir If the instance refers to the application, <TRUE/> is returned. 206cdf0e10cSrcweir 207cdf0e10cSrcweir @see isValid 208cdf0e10cSrcweir */ 209cdf0e10cSrcweir bool isAlive() const; 210cdf0e10cSrcweir 211cdf0e10cSrcweir bool isInVBAMode() const; 212cdf0e10cSrcweir /// returns the BasicManager associated with this instance 213cdf0e10cSrcweir BasicManager* 214cdf0e10cSrcweir getBasicManager() const; 215cdf0e10cSrcweir 216cdf0e10cSrcweir /** returns the UNO component representing the document which the instance operates on 217cdf0e10cSrcweir 218cdf0e10cSrcweir Must not be used when the instance operates on the application-wide 219cdf0e10cSrcweir Basic/Dialog libraries. 220cdf0e10cSrcweir */ 221cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > 222cdf0e10cSrcweir getDocument() const; 223cdf0e10cSrcweir 224cdf0e10cSrcweir /** returns the UNO component representing the document which the instance operates on 225cdf0e10cSrcweir 226cdf0e10cSrcweir May be used when the instance operates on the application-wide 227cdf0e10cSrcweir Basic/Dialog libraries, in this case it returns <NULL/>. 228cdf0e10cSrcweir */ 229cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > 230cdf0e10cSrcweir getDocumentOrNull() const; 231cdf0e10cSrcweir 232cdf0e10cSrcweir /** returns the Basic or Dialog library container of the document 233cdf0e10cSrcweir 234cdf0e10cSrcweir If the document is not valid, <NULL/> is returned. 235cdf0e10cSrcweir */ 236cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer > 237cdf0e10cSrcweir getLibraryContainer( LibraryContainerType _eType ) const; 238cdf0e10cSrcweir 239cdf0e10cSrcweir /** determines whether there exists a library of the given type, with the given name 240cdf0e10cSrcweir */ 241cdf0e10cSrcweir bool hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const; 242cdf0e10cSrcweir 243cdf0e10cSrcweir /** returns a script or dialog library given by name 244cdf0e10cSrcweir 245cdf0e10cSrcweir @param _eType 246cdf0e10cSrcweir the type of library to load 247cdf0e10cSrcweir @param _rLibName 248cdf0e10cSrcweir the name of the script library 249cdf0e10cSrcweir @param _bLoadLibrary 250cdf0e10cSrcweir <TRUE/> if and only if the library should be loaded. 251cdf0e10cSrcweir 252cdf0e10cSrcweir @throws NoSuchElementException 253cdf0e10cSrcweir if there is no script library with the given name 254cdf0e10cSrcweir */ 255cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > 256cdf0e10cSrcweir getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const 257cdf0e10cSrcweir SAL_THROW((::com::sun::star::container::NoSuchElementException)); 258cdf0e10cSrcweir 259cdf0e10cSrcweir /** creates a script or dialog library in the document, or returns an existing one 260cdf0e10cSrcweir 261cdf0e10cSrcweir If <code>_rLibName</code> denotes an existing library which does not need to be created, 262cdf0e10cSrcweir then this library will automatically be loaded, and then returned. 263cdf0e10cSrcweir */ 264cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > 265cdf0e10cSrcweir getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const; 266cdf0e10cSrcweir 267cdf0e10cSrcweir /** returns the names of the modules in a given script or dialog library of the document 268cdf0e10cSrcweir */ 269cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > 270cdf0e10cSrcweir getObjectNames( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const; 271cdf0e10cSrcweir 272cdf0e10cSrcweir /** retrieves a name for a newly to be created module or dialog 273cdf0e10cSrcweir */ 274cdf0e10cSrcweir ::rtl::OUString 275cdf0e10cSrcweir createObjectName( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const; 276cdf0e10cSrcweir 277cdf0e10cSrcweir /** loads a script or dialog library given by name, if there is such a library 278cdf0e10cSrcweir */ 279cdf0e10cSrcweir void loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary ); 280cdf0e10cSrcweir 281cdf0e10cSrcweir /// retrieves the (combined) names of all script and dialog libraries 282cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > 283cdf0e10cSrcweir getLibraryNames() const; 284cdf0e10cSrcweir 285cdf0e10cSrcweir /** removes a given script module from the document 286cdf0e10cSrcweir 287cdf0e10cSrcweir @return 288cdf0e10cSrcweir <TRUE/> if and only if the removal was successful. When <FALSE/> is returned, 289cdf0e10cSrcweir this will reported as assertion in a non-product build. 290cdf0e10cSrcweir */ 291cdf0e10cSrcweir bool removeModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName ) const; 292cdf0e10cSrcweir 293cdf0e10cSrcweir /** creates a module with the given name in the given library 294cdf0e10cSrcweir @param _rLibName 295cdf0e10cSrcweir the library name 296cdf0e10cSrcweir @param _rModName 297cdf0e10cSrcweir the name of the to-be-created module 298cdf0e10cSrcweir @param _bCreateMain 299cdf0e10cSrcweir determines whether or not a function Main should be created 300cdf0e10cSrcweir @param _out_rNewModuleCode 301cdf0e10cSrcweir the source code of the newly created module 302cdf0e10cSrcweir @return 303cdf0e10cSrcweir <TRUE/> if and only if the creation was successful 304cdf0e10cSrcweir */ 305cdf0e10cSrcweir bool createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const; 306cdf0e10cSrcweir 307cdf0e10cSrcweir /** inserts a given piece as code as module 308cdf0e10cSrcweir @param _rLibName 309cdf0e10cSrcweir the name of the library to insert the module into. If a library with this name does 310cdf0e10cSrcweir not yet exist, it will be created. 311cdf0e10cSrcweir @param _rModName 312cdf0e10cSrcweir the name of the module to insert the code as. Must denote a name which is not yet 313cdf0e10cSrcweir used in the module library. 314cdf0e10cSrcweir @param _rModuleCode 315cdf0e10cSrcweir the code of the new module 316cdf0e10cSrcweir @return 317cdf0e10cSrcweir <TRUE/> if and only if the insertion was successful. 318cdf0e10cSrcweir */ 319cdf0e10cSrcweir bool insertModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const; 320cdf0e10cSrcweir 321cdf0e10cSrcweir /** updates a given module with new code 322cdf0e10cSrcweir @param _rLibName 323cdf0e10cSrcweir the name of the library the modules lives in. Must denote an existing module library. 324cdf0e10cSrcweir @param _rModName 325cdf0e10cSrcweir the name of the module to update. Must denote an existing module in the given library. 326cdf0e10cSrcweir @param _rModuleCode 327cdf0e10cSrcweir the new module code. 328cdf0e10cSrcweir @return 329cdf0e10cSrcweir <TRUE/> if and only if the insertion was successful. 330cdf0e10cSrcweir */ 331cdf0e10cSrcweir bool updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const; 332cdf0e10cSrcweir 333cdf0e10cSrcweir /// determines whether a module with the given name exists in the given library 334cdf0e10cSrcweir bool hasModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName ) const; 335cdf0e10cSrcweir 336cdf0e10cSrcweir /** retrieves a module's source 337cdf0e10cSrcweir @param _rLibName 338cdf0e10cSrcweir the library name where the module is located 339cdf0e10cSrcweir @param _rModName 340cdf0e10cSrcweir the module name 341cdf0e10cSrcweir @param _out_rModuleSource 342cdf0e10cSrcweir takes the module's source upon successful return 343cdf0e10cSrcweir @return 344cdf0e10cSrcweir <TRUE/> if and only if the code could be successfully retrieved, <FALSE/> otherwise 345cdf0e10cSrcweir */ 346cdf0e10cSrcweir bool getModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, ::rtl::OUString& _rModuleSource ) const; 347cdf0e10cSrcweir 348cdf0e10cSrcweir /** renames a module 349cdf0e10cSrcweir @param _rLibName 350cdf0e10cSrcweir the library where the module lives in. Must denote an existing library. 351cdf0e10cSrcweir @param _rOldName 352cdf0e10cSrcweir the old module name. Must denote an existing module. 353cdf0e10cSrcweir @param _rNewName 354cdf0e10cSrcweir the new module name 355cdf0e10cSrcweir @return 356cdf0e10cSrcweir <TRUE/> if and only if renaming was successful. 357cdf0e10cSrcweir */ 358cdf0e10cSrcweir bool renameModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName ) const; 359cdf0e10cSrcweir 360cdf0e10cSrcweir /** removes a given dialog from the document 361cdf0e10cSrcweir 362cdf0e10cSrcweir @return 363cdf0e10cSrcweir <TRUE/> if and only if the removal was successful. When <FALSE/> is returned, 364cdf0e10cSrcweir this will reported as assertion in a non-product build. 365cdf0e10cSrcweir */ 366cdf0e10cSrcweir bool removeDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const; 367cdf0e10cSrcweir 368cdf0e10cSrcweir /// determines whether a dialog with the given name exists in the given library 369cdf0e10cSrcweir bool hasDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const; 370cdf0e10cSrcweir 371cdf0e10cSrcweir /** retrieves a dialog 372cdf0e10cSrcweir @param _rLibName 373cdf0e10cSrcweir the library name where the module is located 374cdf0e10cSrcweir @param _rDialogName 375cdf0e10cSrcweir the dialog's name 376cdf0e10cSrcweir @param _out_rDialogSource 377cdf0e10cSrcweir takes the provider for the dialog's desription, upon successful return 378cdf0e10cSrcweir @return 379cdf0e10cSrcweir <TRUE/> if and only if the dialog could be successfully retrieved, <FALSE/> otherwise 380cdf0e10cSrcweir */ 381cdf0e10cSrcweir bool getDialog( 382cdf0e10cSrcweir const ::rtl::OUString& _rLibName, 383cdf0e10cSrcweir const ::rtl::OUString& _rDialogName, 384cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& _out_rDialogProvider 385cdf0e10cSrcweir ) const; 386cdf0e10cSrcweir 387cdf0e10cSrcweir /** renames a dialog 388cdf0e10cSrcweir @param _rLibName 389cdf0e10cSrcweir the library where the dialog lives in. Must denote an existing library. 390cdf0e10cSrcweir @param _rOldName 391cdf0e10cSrcweir the old dialog name. Must denote an existing dialog. 392cdf0e10cSrcweir @param _rNewName 393cdf0e10cSrcweir the new dialog name 394cdf0e10cSrcweir @param _rxExistingDialogModel 395cdf0e10cSrcweir the existing model of the dialog, if already loaded in the IDE 396cdf0e10cSrcweir @return 397cdf0e10cSrcweir <TRUE/> if and only if renaming was successful. 398cdf0e10cSrcweir */ 399cdf0e10cSrcweir bool renameDialog( 400cdf0e10cSrcweir const ::rtl::OUString& _rLibName, 401cdf0e10cSrcweir const ::rtl::OUString& _rOldName, 402cdf0e10cSrcweir const ::rtl::OUString& _rNewName, 403cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxExistingDialogModel 404cdf0e10cSrcweir ) const; 405cdf0e10cSrcweir 406cdf0e10cSrcweir /** create a dialog 407cdf0e10cSrcweir @param _rLibName 408cdf0e10cSrcweir the library name where the module is located 409cdf0e10cSrcweir @param _rDialogName 410cdf0e10cSrcweir the dialog's name 411cdf0e10cSrcweir @param _out_rDialogSource 412cdf0e10cSrcweir takes the provider for the dialog's desription, upon successful return 413cdf0e10cSrcweir @return 414cdf0e10cSrcweir <TRUE/> if and only if the dialog could be successfully retrieved, <FALSE/> otherwise 415cdf0e10cSrcweir */ 416cdf0e10cSrcweir bool createDialog( 417cdf0e10cSrcweir const ::rtl::OUString& _rLibName, 418cdf0e10cSrcweir const ::rtl::OUString& _rDialogName, 419cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& _out_rDialogProvider 420cdf0e10cSrcweir ) const; 421cdf0e10cSrcweir 422cdf0e10cSrcweir /** inserts a given dialog into a given library 423cdf0e10cSrcweir 424cdf0e10cSrcweir @param _rLibName 425cdf0e10cSrcweir the name of the library to insert the dialog into. If a library with this name does 426cdf0e10cSrcweir not yet exist, it will be created. 427cdf0e10cSrcweir @param _rModName 428cdf0e10cSrcweir the name of the dialog to insert. Must denote a name which is not yet 429cdf0e10cSrcweir used in the dialog library. 430cdf0e10cSrcweir @param _rDialogProvider 431cdf0e10cSrcweir the provider of the dialog's description 432cdf0e10cSrcweir @return 433cdf0e10cSrcweir <TRUE/> if and only if the insertion was successful. 434cdf0e10cSrcweir */ 435cdf0e10cSrcweir bool insertDialog( 436cdf0e10cSrcweir const ::rtl::OUString& _rLibName, 437cdf0e10cSrcweir const ::rtl::OUString& _rDialogName, 438cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& _rDialogProvider 439cdf0e10cSrcweir ) const; 440cdf0e10cSrcweir 441cdf0e10cSrcweir /** determines whether the document is read-only 442cdf0e10cSrcweir 443cdf0e10cSrcweir cannot be called if the document operates on the application-wide scripts 444cdf0e10cSrcweir */ 445cdf0e10cSrcweir bool isReadOnly() const; 446cdf0e10cSrcweir 447cdf0e10cSrcweir /** determines whether the ScriptDocument instance operates on the whole application, 448cdf0e10cSrcweir as opposed to a real document 449cdf0e10cSrcweir */ 450cdf0e10cSrcweir bool isApplication() const; 451cdf0e10cSrcweir 452cdf0e10cSrcweir /** determines whether the ScriptDocument instance operates on a real document, 453cdf0e10cSrcweir as opposed to the whole application 454cdf0e10cSrcweir */ isDocument() const455cdf0e10cSrcweir bool isDocument() const { return isValid() && !isApplication(); } 456cdf0e10cSrcweir 457cdf0e10cSrcweir /** marks the document as modified 458cdf0e10cSrcweir @precond 459cdf0e10cSrcweir the instance operates on a real document, not on the application 460cdf0e10cSrcweir @see isDocument 461cdf0e10cSrcweir */ 462cdf0e10cSrcweir void setDocumentModified() const; 463cdf0e10cSrcweir 464cdf0e10cSrcweir /** determines whether the document is modified 465cdf0e10cSrcweir @precond 466cdf0e10cSrcweir the instance operates on a real document, not on the application 467cdf0e10cSrcweir @see isDocument 468cdf0e10cSrcweir */ 469cdf0e10cSrcweir bool isDocumentModified() const; 470cdf0e10cSrcweir 471cdf0e10cSrcweir /** saves the document, if the instance refers to a real document 472cdf0e10cSrcweir @precond 473cdf0e10cSrcweir <code>isApplication</code> returns <FALSE/> 474cdf0e10cSrcweir */ 475cdf0e10cSrcweir bool saveDocument( 476cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& _rxStatusIndicator 477cdf0e10cSrcweir ) const; 478cdf0e10cSrcweir 479cdf0e10cSrcweir /// returns the location of a library given by name 480cdf0e10cSrcweir LibraryLocation 481cdf0e10cSrcweir getLibraryLocation( const ::rtl::OUString& _rLibName ) const; 482cdf0e10cSrcweir 483cdf0e10cSrcweir /// returns the title for the document 484cdf0e10cSrcweir ::rtl::OUString 485cdf0e10cSrcweir getTitle( LibraryLocation _eLocation, LibraryType _eType = LIBRARY_TYPE_ALL ) const; 486cdf0e10cSrcweir 487cdf0e10cSrcweir /** returns the title of the document 488cdf0e10cSrcweir 489cdf0e10cSrcweir to be used for valid documents only 490cdf0e10cSrcweir */ 491cdf0e10cSrcweir ::rtl::OUString 492cdf0e10cSrcweir getTitle() const; 493cdf0e10cSrcweir 494cdf0e10cSrcweir /** returns the URL of the document 495cdf0e10cSrcweir 496cdf0e10cSrcweir to be used for valid documents only 497cdf0e10cSrcweir */ 498cdf0e10cSrcweir ::rtl::OUString 499cdf0e10cSrcweir getURL() const; 500cdf0e10cSrcweir 501cdf0e10cSrcweir /** determines whether the document is currently the one-and-only application-wide active document 502cdf0e10cSrcweir */ 503cdf0e10cSrcweir bool isActive() const; 504cdf0e10cSrcweir 505cdf0e10cSrcweir /** determines whether macro execution for this document is allowed 506cdf0e10cSrcweir 507cdf0e10cSrcweir only to be called for real documents (->isDocument) 508cdf0e10cSrcweir */ 509cdf0e10cSrcweir bool allowMacros() const; 510cdf0e10cSrcweir }; 511cdf0e10cSrcweir 512cdf0e10cSrcweir //........................................................................ 513cdf0e10cSrcweir } // namespace basctl 514cdf0e10cSrcweir //........................................................................ 515cdf0e10cSrcweir 516cdf0e10cSrcweir // convenience ... better would be all classes in the project are in 517cdf0e10cSrcweir // the same namespace ... 518cdf0e10cSrcweir using ::basctl::ScriptDocument; 519cdf0e10cSrcweir using ::basctl::ScriptDocuments; 520cdf0e10cSrcweir using ::basctl::E_SCRIPTS; 521cdf0e10cSrcweir using ::basctl::E_DIALOGS; 522cdf0e10cSrcweir using ::basctl::LibraryLocation; 523cdf0e10cSrcweir using ::basctl::LIBRARY_LOCATION_UNKNOWN; 524cdf0e10cSrcweir using ::basctl::LIBRARY_LOCATION_USER; 525cdf0e10cSrcweir using ::basctl::LIBRARY_LOCATION_SHARE; 526cdf0e10cSrcweir using ::basctl::LIBRARY_LOCATION_DOCUMENT; 527cdf0e10cSrcweir using ::basctl::LibraryType; 528cdf0e10cSrcweir using ::basctl::LIBRARY_TYPE_UNKNOWN; 529cdf0e10cSrcweir using ::basctl::LIBRARY_TYPE_MODULE; 530cdf0e10cSrcweir using ::basctl::LIBRARY_TYPE_DIALOG; 531cdf0e10cSrcweir using ::basctl::LIBRARY_TYPE_ALL; 532cdf0e10cSrcweir 533cdf0e10cSrcweir #endif // SCRIPTDOCUMENT_HXX 534