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