1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
24cdf0e10cSrcweir #define _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "ModelImpl.hxx"
27cdf0e10cSrcweir #include "documenteventnotifier.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir /** === begin UNO includes === **/
30cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
31cdf0e10cSrcweir #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XModel2.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XTitle.hpp>
34cdf0e10cSrcweir #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
35cdf0e10cSrcweir #include <com/sun/star/frame/XUntitledNumbers.hpp>
36cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
37cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
38cdf0e10cSrcweir #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
39cdf0e10cSrcweir #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
40cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
41cdf0e10cSrcweir #include <com/sun/star/view/XPrintable.hpp>
42cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
45cdf0e10cSrcweir #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
46cdf0e10cSrcweir #include <com/sun/star/embed/XTransactionListener.hpp>
47cdf0e10cSrcweir #include <com/sun/star/document/XStorageBasedDocument.hpp>
48cdf0e10cSrcweir #include <com/sun/star/document/XEmbeddedScripts.hpp>
49cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
50cdf0e10cSrcweir #include <com/sun/star/document/XScriptInvocationContext.hpp>
51cdf0e10cSrcweir #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
52cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
53cdf0e10cSrcweir #include <com/sun/star/frame/XLoadable.hpp>
54cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp>
55cdf0e10cSrcweir #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
56cdf0e10cSrcweir #include <com/sun/star/document/XDocumentRecovery.hpp>
57cdf0e10cSrcweir /** === end UNO includes === **/
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17)
60cdf0e10cSrcweir #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
61cdf0e10cSrcweir #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 17
62cdf0e10cSrcweir #include <comphelper/implbase_var.hxx>
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #include <cppuhelper/compbase10.hxx>
66cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
67cdf0e10cSrcweir #include <rtl/ref.hxx>
68cdf0e10cSrcweir 
69cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
70cdf0e10cSrcweir #include <boost/noncopyable.hpp>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir namespace comphelper {
73cdf0e10cSrcweir     class NamedValueCollection;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //........................................................................
77cdf0e10cSrcweir namespace dbaccess
78cdf0e10cSrcweir {
79cdf0e10cSrcweir //........................................................................
80cdf0e10cSrcweir 
81cdf0e10cSrcweir class DocumentEvents;
82cdf0e10cSrcweir class DocumentEventExecutor;
83cdf0e10cSrcweir class DocumentGuard;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > >   Controllers;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir //============================================================
88cdf0e10cSrcweir //= ViewMonitor
89cdf0e10cSrcweir //============================================================
90cdf0e10cSrcweir /** helper class monitoring the views of a document, and firing appropriate events
91cdf0e10cSrcweir     when views are attached / detached
92cdf0e10cSrcweir */
93cdf0e10cSrcweir class ViewMonitor : public boost::noncopyable
94cdf0e10cSrcweir {
95cdf0e10cSrcweir public:
ViewMonitor(DocumentEventNotifier & _rEventNotifier)96cdf0e10cSrcweir     ViewMonitor( DocumentEventNotifier& _rEventNotifier )
97cdf0e10cSrcweir         :m_rEventNotifier( _rEventNotifier )
98cdf0e10cSrcweir         ,m_bIsNewDocument( true )
99cdf0e10cSrcweir         ,m_bEverHadController( false )
100cdf0e10cSrcweir         ,m_bLastIsFirstEverController( false )
101cdf0e10cSrcweir         ,m_xLastConnectedController()
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir     }
104cdf0e10cSrcweir 
reset()105cdf0e10cSrcweir     void    reset()
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         m_bEverHadController = false;
108cdf0e10cSrcweir         m_bLastIsFirstEverController = false;
109cdf0e10cSrcweir         m_xLastConnectedController.clear();
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     /** to be called when a view (aka controller) has been connected to the document
113cdf0e10cSrcweir         @return
114cdf0e10cSrcweir             <TRUE/> if and only if this was the first-ever controller connected to the document
115cdf0e10cSrcweir     */
116cdf0e10cSrcweir     bool    onControllerConnected(
117cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
118cdf0e10cSrcweir              );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     /**  to be called when a controller is set as current controller
121cdf0e10cSrcweir         @return <TRUE/>
122cdf0e10cSrcweir             if and only if the controller connection indicates that loading the document is finished. This
123cdf0e10cSrcweir             is the case if the given controller has previously been connected, and it was the first controller
124cdf0e10cSrcweir             ever for which this happened.
125cdf0e10cSrcweir     */
126cdf0e10cSrcweir     bool    onSetCurrentController(
127cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
128cdf0e10cSrcweir              );
129cdf0e10cSrcweir 
onLoadedDocument()130cdf0e10cSrcweir     void    onLoadedDocument() { m_bIsNewDocument = false; }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir private:
133cdf0e10cSrcweir     DocumentEventNotifier&  m_rEventNotifier;
134cdf0e10cSrcweir     bool                    m_bIsNewDocument;
135cdf0e10cSrcweir     bool                    m_bEverHadController;
136cdf0e10cSrcweir     bool                    m_bLastIsFirstEverController;
137cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
138cdf0e10cSrcweir                             m_xLastConnectedController;
139cdf0e10cSrcweir };
140cdf0e10cSrcweir 
141cdf0e10cSrcweir //============================================================
142cdf0e10cSrcweir //= ODatabaseDocument
143cdf0e10cSrcweir //============================================================
144cdf0e10cSrcweir typedef ::comphelper::WeakComponentImplHelper17 <   ::com::sun::star::frame::XModel2
145cdf0e10cSrcweir                                                 ,   ::com::sun::star::util::XModifiable
146cdf0e10cSrcweir                                                 ,   ::com::sun::star::frame::XStorable
147cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XEventBroadcaster
148cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XDocumentEventBroadcaster
149cdf0e10cSrcweir                                                 ,   ::com::sun::star::view::XPrintable
150cdf0e10cSrcweir                                                 ,   ::com::sun::star::util::XCloseable
151cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XServiceInfo
152cdf0e10cSrcweir                                                 ,   ::com::sun::star::sdb::XOfficeDatabaseDocument
153cdf0e10cSrcweir                                                 ,   ::com::sun::star::ui::XUIConfigurationManagerSupplier
154cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XStorageBasedDocument
155cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XEmbeddedScripts
156cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XScriptInvocationContext
157cdf0e10cSrcweir                                                 ,   ::com::sun::star::script::provider::XScriptProviderSupplier
158cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XEventsSupplier
159cdf0e10cSrcweir                                                 ,   ::com::sun::star::frame::XLoadable
160cdf0e10cSrcweir                                                 ,   ::com::sun::star::document::XDocumentRecovery
161cdf0e10cSrcweir                                                 >   ODatabaseDocument_OfficeDocument;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir typedef ::cppu::ImplHelper3<    ::com::sun::star::frame::XTitle
164cdf0e10cSrcweir                             ,	::com::sun::star::frame::XTitleChangeBroadcaster
165cdf0e10cSrcweir                             ,	::com::sun::star::frame::XUntitledNumbers
166cdf0e10cSrcweir                             >   ODatabaseDocument_Title;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir class ODatabaseDocument	:public ModelDependentComponent             // ModelDependentComponent must be first!
169cdf0e10cSrcweir                         ,public ODatabaseDocument_OfficeDocument
170cdf0e10cSrcweir                         ,public ODatabaseDocument_Title
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     enum InitState
173cdf0e10cSrcweir     {
174cdf0e10cSrcweir         NotInitialized,
175cdf0e10cSrcweir         Initializing,
176cdf0e10cSrcweir         Initialized
177cdf0e10cSrcweir     };
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers >,TNumberedController);
180cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager>			m_xUIConfigurationManager;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper					                                        m_aModifyListeners;
183cdf0e10cSrcweir 	::cppu::OInterfaceContainerHelper					                                        m_aCloseListener;
184cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper					                                        m_aStorageListeners;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     DocumentEvents*                                                                             m_pEventContainer;
187cdf0e10cSrcweir     ::rtl::Reference< DocumentEventExecutor >                                                   m_pEventExecutor;
188cdf0e10cSrcweir     DocumentEventNotifier                                                                       m_aEventNotifier;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >                    m_xCurrentController;
191cdf0e10cSrcweir     Controllers                                                                                 m_aControllers;
192cdf0e10cSrcweir     ViewMonitor                                                                                 m_aViewMonitor;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >	        m_xForms;
195cdf0e10cSrcweir 	::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >	        m_xReports;
196cdf0e10cSrcweir     ::com::sun::star::uno::WeakReference< ::com::sun::star::script::provider::XScriptProvider > m_xScriptProvider;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     /** @short  such module manager is used to classify new opened documents. */
199cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >                 m_xModuleManager;
200cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle >                         m_xTitleHelper;
201cdf0e10cSrcweir     TNumberedController                                                                         m_aNumberedControllers;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
204cdf0e10cSrcweir         the document has be initialized implicitly - see storeAsURL
205cdf0e10cSrcweir     */
206cdf0e10cSrcweir     InitState                                                                                   m_eInitState;
207cdf0e10cSrcweir     bool                                                                                        m_bClosing;
208cdf0e10cSrcweir     bool                                                                                        m_bAllowDocumentScripting;
209cdf0e10cSrcweir     bool                                                                                        m_bHasBeenRecovered;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     enum StoreType { SAVE, SAVE_AS };
212cdf0e10cSrcweir     /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
213cdf0e10cSrcweir         the modified flag, and notifies any listeners as required
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         @param _rURL
216cdf0e10cSrcweir             the URL to store the document to
217cdf0e10cSrcweir         @param _rArguments
218cdf0e10cSrcweir             arguments for storing the document (MediaDescriptor)
219cdf0e10cSrcweir         @param _eType
220cdf0e10cSrcweir             the type of the store process (Save or SaveAs). The method will automatically
221cdf0e10cSrcweir             notify the proper events for this type.
222cdf0e10cSrcweir         @param _rGuard
223cdf0e10cSrcweir             the instance lock to be released before doing synchronous notifications
224cdf0e10cSrcweir     */
225cdf0e10cSrcweir     void impl_storeAs_throw(
226cdf0e10cSrcweir             const ::rtl::OUString& _rURL,
227cdf0e10cSrcweir             const ::comphelper::NamedValueCollection& _rArguments,
228cdf0e10cSrcweir             const StoreType _eType,
229cdf0e10cSrcweir             DocumentGuard& _rGuard
230cdf0e10cSrcweir          )
231cdf0e10cSrcweir          throw  (   ::com::sun::star::io::IOException
232cdf0e10cSrcweir                 ,   ::com::sun::star::uno::RuntimeException );
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     /** notifies our storage change listeners that our underlying storage changed
235cdf0e10cSrcweir 
236cdf0e10cSrcweir         @param _rxNewRootStorage
237cdf0e10cSrcweir             the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
238cdf0e10cSrcweir             happened, and the listeners are not notified.
239cdf0e10cSrcweir     */
240cdf0e10cSrcweir     void    impl_notifyStorageChange_nolck_nothrow(
241cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
242cdf0e10cSrcweir             );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     /// write a single XML stream into the package
245cdf0e10cSrcweir 	void WriteThroughComponent(
246cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > & xComponent,  /// the component we export
247cdf0e10cSrcweir 		const sal_Char* pStreamName,		                                                        /// the stream name
248cdf0e10cSrcweir 		const sal_Char* pServiceName,		                                                        /// service name of the component
249cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> & rArguments,            /// the argument (XInitialization)
250cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc,/// output descriptor
251cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _xStorageToSaveTo
252cdf0e10cSrcweir     ) const;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	/// write a single output stream
256cdf0e10cSrcweir 	/// (to be called either directly or by WriteThroughComponent(...))
257cdf0e10cSrcweir 	void WriteThroughComponent(
258cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
259cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
260cdf0e10cSrcweir 		const sal_Char* pServiceName,
261cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
262cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
263cdf0e10cSrcweir     ) const;
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	/** writes the content and settings
266cdf0e10cSrcweir 		@param	sURL
267cdf0e10cSrcweir 			The URL
268cdf0e10cSrcweir 		@param	lArguments
269cdf0e10cSrcweir 			The media descriptor
270cdf0e10cSrcweir 		@param	_xStorageToSaveTo
271cdf0e10cSrcweir 			The storage which should be used for saving
272cdf0e10cSrcweir 	*/
273cdf0e10cSrcweir 	void impl_writeStorage_throw(
274cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
275cdf0e10cSrcweir         const ::comphelper::NamedValueCollection& _rMediaDescriptor
276cdf0e10cSrcweir     ) const;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     // ModelDependentComponent overridables
279cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle >             impl_getTitleHelper_throw();
282cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers >   impl_getUntitledHelper_throw(
283cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
284cdf0e10cSrcweir 
285cdf0e10cSrcweir private:
286cdf0e10cSrcweir 	ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
287cdf0e10cSrcweir     // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
288cdf0e10cSrcweir     // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
289cdf0e10cSrcweir     // If you create a ODatabaseDocument directly, you might easily create a leak.
290cdf0e10cSrcweir     // #i50905# / 2005-06-20 / frank.schonheit@sun.com
291cdf0e10cSrcweir 
292cdf0e10cSrcweir protected:
293cdf0e10cSrcweir     virtual void SAL_CALL disposing();
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	virtual ~ODatabaseDocument();
296cdf0e10cSrcweir 
297cdf0e10cSrcweir public:
FactoryAccessdbaccess::ODatabaseDocument::FactoryAccess298cdf0e10cSrcweir     struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
createDatabaseDocument(const::rtl::Reference<ODatabaseModelImpl> & _pImpl,FactoryAccess)299cdf0e10cSrcweir     static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
300cdf0e10cSrcweir     {
301cdf0e10cSrcweir         return new ODatabaseDocument( _pImpl );
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     // XServiceInfo
305cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
306cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
307cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
308cdf0e10cSrcweir 
309cdf0e10cSrcweir     // ::com::sun::star::lang::XServiceInfo - static methods
310cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
311cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
312cdf0e10cSrcweir 	static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
313cdf0e10cSrcweir 		SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     // XInterface
316cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any	SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
317cdf0e10cSrcweir 	virtual void SAL_CALL acquire(  ) throw ();
318cdf0e10cSrcweir 	virtual void SAL_CALL release(  ) throw ();
319cdf0e10cSrcweir 
320cdf0e10cSrcweir     // XTypeProvider
321cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
322cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw (::com::sun::star::uno::RuntimeException);
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	// XEventListener
325cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     // XComponent
328cdf0e10cSrcweir 	virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
329cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
330cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     // XModel
333cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& URL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException) ;
334cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getURL(  ) throw (::com::sun::star::uno::RuntimeException) ;
335cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs(  ) throw (::com::sun::star::uno::RuntimeException) ;
336cdf0e10cSrcweir     virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException) ;
337cdf0e10cSrcweir     virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException) ;
338cdf0e10cSrcweir     virtual void SAL_CALL lockControllers(  ) throw (::com::sun::star::uno::RuntimeException) ;
339cdf0e10cSrcweir     virtual void SAL_CALL unlockControllers(  ) throw (::com::sun::star::uno::RuntimeException) ;
340cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasControllersLocked(  ) throw (::com::sun::star::uno::RuntimeException) ;
341cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController(  ) throw (::com::sun::star::uno::RuntimeException) ;
342cdf0e10cSrcweir     virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) ;
343cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection(  ) throw (::com::sun::star::uno::RuntimeException) ;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     // XModel2
346cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL getControllers(  ) throw (::com::sun::star::uno::RuntimeException) ;
347cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableViewControllerNames(  ) throw (::com::sun::star::uno::RuntimeException) ;
348cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createDefaultViewController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ;
349cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createViewController( const ::rtl::OUString& ViewName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) ;
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     // XStorable
352cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL hasLocation(  ) throw (::com::sun::star::uno::RuntimeException) ;
353cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException) ;
354cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isReadonly(  ) throw (::com::sun::star::uno::RuntimeException) ;
355cdf0e10cSrcweir     virtual void SAL_CALL store(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ;
356cdf0e10cSrcweir     virtual void SAL_CALL storeAsURL( const ::rtl::OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ;
357cdf0e10cSrcweir     virtual void SAL_CALL storeToURL( const ::rtl::OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) ;
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     // XModifyBroadcaster
360cdf0e10cSrcweir 	virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
361cdf0e10cSrcweir     virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     // ::com::sun::star::util::XModifiable
364cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isModified(  ) throw (::com::sun::star::uno::RuntimeException) ;
365cdf0e10cSrcweir     virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException) ;
366cdf0e10cSrcweir 
367cdf0e10cSrcweir     // XEventBroadcaster
368cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
369cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
370cdf0e10cSrcweir 
371cdf0e10cSrcweir     // XDocumentEventBroadcaster
372cdf0e10cSrcweir     virtual void SAL_CALL addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
373cdf0e10cSrcweir     virtual void SAL_CALL removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
374cdf0e10cSrcweir     virtual void SAL_CALL notifyDocumentEvent( const ::rtl::OUString& _EventName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController, const ::com::sun::star::uno::Any& _Supplement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
375cdf0e10cSrcweir 
376cdf0e10cSrcweir     // XPrintable
377cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter(  ) throw (::com::sun::star::uno::RuntimeException) ;
378cdf0e10cSrcweir     virtual void SAL_CALL setPrinter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aPrinter ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
379cdf0e10cSrcweir     virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     // XFormDocumentsSupplier
382cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments(  ) throw (::com::sun::star::uno::RuntimeException);
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     // XReportDocumentsSupplier
385cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments(  ) throw (::com::sun::star::uno::RuntimeException);
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     // XCloseable
388cdf0e10cSrcweir 	virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
389cdf0e10cSrcweir 	virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
390cdf0e10cSrcweir     virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
391cdf0e10cSrcweir 
392cdf0e10cSrcweir     // XUIConfigurationManagerSupplier
393cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager(  ) throw (::com::sun::star::uno::RuntimeException);
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     // XDocumentSubStorageSupplier
396cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw (::com::sun::star::uno::RuntimeException);
397cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     // XOfficeDatabaseDocument
400cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException);
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     // XStorageBasedDocument
403cdf0e10cSrcweir     virtual void SAL_CALL loadFromStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
404cdf0e10cSrcweir     virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
405cdf0e10cSrcweir     virtual void SAL_CALL switchToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
406cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentStorage(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
407cdf0e10cSrcweir     virtual void SAL_CALL addStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
408cdf0e10cSrcweir     virtual void SAL_CALL removeStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     // XEmbeddedScripts
411cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (::com::sun::star::uno::RuntimeException);
412cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (::com::sun::star::uno::RuntimeException);
413cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException);
414cdf0e10cSrcweir 
415cdf0e10cSrcweir     // XScriptInvocationContext
416cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException);
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     // XScriptProviderSupplier
419cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::provider::XScriptProvider > SAL_CALL getScriptProvider(  ) throw (::com::sun::star::uno::RuntimeException);
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     // XEventsSupplier
422cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents(  ) throw (::com::sun::star::uno::RuntimeException);
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     // XLoadable
425cdf0e10cSrcweir     virtual void SAL_CALL initNew(  ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
426cdf0e10cSrcweir     virtual void SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     // css.document.XDocumentRecovery
429cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( ::com::sun::star::uno::RuntimeException );
430cdf0e10cSrcweir     virtual void SAL_CALL storeToRecoveryFile( const ::rtl::OUString& i_TargetLocation, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException );
431cdf0e10cSrcweir     virtual void SAL_CALL recoverFromFile( const ::rtl::OUString& i_SourceLocation, const ::rtl::OUString& i_SalvagedFile, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     // XTitle
434cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getTitle(  ) throw (::com::sun::star::uno::RuntimeException);
435cdf0e10cSrcweir     virtual void SAL_CALL setTitle( const ::rtl::OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException);
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     // XTitleChangeBroadcaster
438cdf0e10cSrcweir     virtual void SAL_CALL addTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
439cdf0e10cSrcweir     virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
440cdf0e10cSrcweir 
441cdf0e10cSrcweir     // XUntitledNumbers
442cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL leaseNumber( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
443cdf0e10cSrcweir     virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
444cdf0e10cSrcweir     virtual void SAL_CALL releaseNumberForComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
445cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getUntitledPrefix(  ) throw (::com::sun::star::uno::RuntimeException);
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     /** clears the given object container
448cdf0e10cSrcweir 
449cdf0e10cSrcweir         Clearing is done via disposal - the method calls XComponent::dispose at the given object,
450cdf0e10cSrcweir         which must be one of our impl's or our object containers (m_xForms, m_xReports,
451cdf0e10cSrcweir         m_xTableDefinitions, m_xCommandDefinitions)
452cdf0e10cSrcweir 
453cdf0e10cSrcweir         @param _rxContainer
454cdf0e10cSrcweir             the container to clear
455cdf0e10cSrcweir     */
456cdf0e10cSrcweir     static void clearObjectContainer(
457cdf0e10cSrcweir                 ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer);
458cdf0e10cSrcweir 
459cdf0e10cSrcweir     /** checks whether the component is already initialized, throws a NotInitializedException if not
460cdf0e10cSrcweir     */
checkInitialized() const461cdf0e10cSrcweir     inline void checkInitialized() const
462cdf0e10cSrcweir     {
463cdf0e10cSrcweir         if ( !impl_isInitialized() )
464cdf0e10cSrcweir             throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() );
465cdf0e10cSrcweir     }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     /** checks the document is currently in the initialization phase, or already initialized.
468cdf0e10cSrcweir         Throws NotInitializedException if not so.
469cdf0e10cSrcweir     */
checkNotUninitilized() const470cdf0e10cSrcweir     inline void checkNotUninitilized() const
471cdf0e10cSrcweir     {
472cdf0e10cSrcweir         if ( impl_isInitialized() || impl_isInitializing() )
473cdf0e10cSrcweir             // fine
474cdf0e10cSrcweir             return;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir         throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() );
477cdf0e10cSrcweir     }
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     /** checks whether the document is currently being initialized, or already initialized,
480cdf0e10cSrcweir         throws a DoubleInitializationException if so
481cdf0e10cSrcweir     */
checkNotInitialized() const482cdf0e10cSrcweir     inline void checkNotInitialized() const
483cdf0e10cSrcweir     {
484cdf0e10cSrcweir         if ( impl_isInitializing() || impl_isInitialized() )
485cdf0e10cSrcweir             throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), getThis() );
486cdf0e10cSrcweir     }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir private:
489cdf0e10cSrcweir     /** returns whether the model is currently being initialized
490cdf0e10cSrcweir     */
impl_isInitializing() const491cdf0e10cSrcweir     bool    impl_isInitializing() const { return m_eInitState == Initializing; }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir     /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
494cdf0e10cSrcweir     */
impl_isInitialized() const495cdf0e10cSrcweir     bool    impl_isInitialized() const { return m_eInitState == Initialized; }
496cdf0e10cSrcweir 
497cdf0e10cSrcweir     /// tells the model it is being initialized now
impl_setInitializing()498cdf0e10cSrcweir     void    impl_setInitializing() { m_eInitState = Initializing; }
499cdf0e10cSrcweir 
500cdf0e10cSrcweir     /// tells the model its initialization is done
501cdf0e10cSrcweir     void    impl_setInitialized();
502cdf0e10cSrcweir 
503cdf0e10cSrcweir     /** closes the frames of all connected controllers
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     @param _bDeliverOwnership
506cdf0e10cSrcweir         determines if the ownership should be transfered to the component which
507cdf0e10cSrcweir         possibly vetos the closing
508cdf0e10cSrcweir 
509cdf0e10cSrcweir     @raises ::com::sun::star::util::CloseVetoException
510cdf0e10cSrcweir         if the closing was vetoed by any instance
511cdf0e10cSrcweir     */
512cdf0e10cSrcweir     void    impl_closeControllerFrames_nolck_throw( sal_Bool _bDeliverOwnership );
513cdf0e10cSrcweir 
514cdf0e10cSrcweir     /** disposes the frames of all controllers which are still left in m_aControllers.
515cdf0e10cSrcweir     */
516cdf0e10cSrcweir     void    impl_disposeControllerFrames_nothrow();
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     /** does a reparenting at the given object container to ourself
519cdf0e10cSrcweir 
520cdf0e10cSrcweir         Calls XChild::setParent at the given object, which must be one of our impl's or our
521cdf0e10cSrcweir         object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
522cdf0e10cSrcweir     */
523cdf0e10cSrcweir     void    impl_reparent_nothrow( const ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer );
524cdf0e10cSrcweir 
525cdf0e10cSrcweir     /** retrieves the forms or reports contained, creates and initializes it, if necessary
526cdf0e10cSrcweir 
527cdf0e10cSrcweir         @raises DisposedException
528cdf0e10cSrcweir             if the instance is already disposed
529cdf0e10cSrcweir         @raises IllegalArgumentException
530cdf0e10cSrcweir             if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
531cdf0e10cSrcweir     */
532cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
533cdf0e10cSrcweir             impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     /** resets everything
536cdf0e10cSrcweir 
537cdf0e10cSrcweir         @precond
538cdf0e10cSrcweir             m_pImpl is not <NULLL/>
539cdf0e10cSrcweir     */
540cdf0e10cSrcweir     void
541cdf0e10cSrcweir             impl_reset_nothrow();
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     /** imports the document from the given resource.
544cdf0e10cSrcweir     */
545cdf0e10cSrcweir     static void
546cdf0e10cSrcweir             impl_import_nolck_throw(
547cdf0e10cSrcweir                 const ::comphelper::ComponentContext _rContext,
548cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
549cdf0e10cSrcweir                 const ::comphelper::NamedValueCollection& _rResource
550cdf0e10cSrcweir             );
551cdf0e10cSrcweir 
552cdf0e10cSrcweir     /** creates a storage for the given URL, truncating it if a file with this name already exists
553cdf0e10cSrcweir 
554cdf0e10cSrcweir         @throws Exception
555cdf0e10cSrcweir             if creating the storage failed
556cdf0e10cSrcweir 
557cdf0e10cSrcweir         @return
558cdf0e10cSrcweir             the newly created storage for the file at the given URL
559cdf0e10cSrcweir     */
560cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
561cdf0e10cSrcweir             impl_createStorageFor_throw(
562cdf0e10cSrcweir                 const ::rtl::OUString& _rURL
563cdf0e10cSrcweir             ) const;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     /** sets our "modified" flag
566cdf0e10cSrcweir 
567cdf0e10cSrcweir         will notify all our respective listeners, if the "modified" state actually changed
568cdf0e10cSrcweir 
569cdf0e10cSrcweir         @param _bModified
570cdf0e10cSrcweir             the (new) flag indicating whether the document is currently modified or not
571cdf0e10cSrcweir         @param _rGuard
572cdf0e10cSrcweir             the guard for our instance. At method entry, the guard must hold the lock. At the moment
573cdf0e10cSrcweir             of method leave, the lock will be released.
574cdf0e10cSrcweir         @precond
575cdf0e10cSrcweir             our mutex is locked
576cdf0e10cSrcweir         @postcond
577cdf0e10cSrcweir             our mutex is not locked
578cdf0e10cSrcweir     */
579cdf0e10cSrcweir     void    impl_setModified_nothrow( sal_Bool _bModified, DocumentGuard& _rGuard );
580cdf0e10cSrcweir 
581cdf0e10cSrcweir     /** stores the document to the given storage
582cdf0e10cSrcweir 
583cdf0e10cSrcweir         Note that the document is actually not rebased to this storage, it just stores a copy of itself
584cdf0e10cSrcweir         to the given target storage.
585cdf0e10cSrcweir 
586cdf0e10cSrcweir         @param _rxTargetStorage
587cdf0e10cSrcweir             denotes the storage to store the document into
588cdf0e10cSrcweir         @param _rMediaDescriptor
589cdf0e10cSrcweir             contains additional parameters for storing the document
590cdf0e10cSrcweir         @param _rDocGuard
591cdf0e10cSrcweir             a guard which holds the (only) lock to the document, and which will be temporarily
592cdf0e10cSrcweir             released where necessary (e.g. for notifications, or calling into other components)
593cdf0e10cSrcweir 
594cdf0e10cSrcweir         @throws ::com::sun::star::uno::IllegalArgumentException
595cdf0e10cSrcweir             if the given storage is <NULL/>.
596cdf0e10cSrcweir 
597cdf0e10cSrcweir         @throws ::com::sun::star::uno::RuntimeException
598cdf0e10cSrcweir             when any of the used operations throws it
599cdf0e10cSrcweir 
600cdf0e10cSrcweir         @throws ::com::sun::star::io::IOException
601cdf0e10cSrcweir             when any of the used operations throws it, or any other exception occurs which is no
602cdf0e10cSrcweir             RuntimeException and no IOException
603cdf0e10cSrcweir     */
604cdf0e10cSrcweir     void    impl_storeToStorage_throw(
605cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
606cdf0e10cSrcweir                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor,
607cdf0e10cSrcweir                 DocumentGuard& _rDocGuard
608cdf0e10cSrcweir             ) const;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     /** impl-version of attachResource
612cdf0e10cSrcweir 
613cdf0e10cSrcweir         @param  i_rLogicalDocumentURL
614cdf0e10cSrcweir             denotes the logical URL of the document, to be reported by getURL/getLocation
615cdf0e10cSrcweir         @param  i_rMediaDescriptor
616cdf0e10cSrcweir             denotes additional document parameters
617cdf0e10cSrcweir         @param  _rDocGuard
618cdf0e10cSrcweir             is the guard which currently protects the document instance
619cdf0e10cSrcweir 
620cdf0e10cSrcweir     */
621cdf0e10cSrcweir     sal_Bool    impl_attachResource(
622cdf0e10cSrcweir                     const ::rtl::OUString& i_rLogicalDocumentURL,
623cdf0e10cSrcweir                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rMediaDescriptor,
624cdf0e10cSrcweir                     DocumentGuard& _rDocGuard
625cdf0e10cSrcweir                 );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     /** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
628cdf0e10cSrcweir         the given caught non-IOException error
629cdf0e10cSrcweir     */
630cdf0e10cSrcweir     void        impl_throwIOExceptionCausedBySave_throw(
631cdf0e10cSrcweir                     const ::com::sun::star::uno::Any& i_rError,
632cdf0e10cSrcweir                     const ::rtl::OUString& i_rTargetURL
633cdf0e10cSrcweir                 ) const;
634cdf0e10cSrcweir };
635cdf0e10cSrcweir 
636cdf0e10cSrcweir /** an extended version of the ModelMethodGuard, which also cares for the initialization state
637cdf0e10cSrcweir     of the document
638cdf0e10cSrcweir */
639cdf0e10cSrcweir class DocumentGuard : private ModelMethodGuard
640cdf0e10cSrcweir {
641cdf0e10cSrcweir public:
642cdf0e10cSrcweir     enum MethodType
643cdf0e10cSrcweir     {
644cdf0e10cSrcweir         // a method which is to initialize the document
645cdf0e10cSrcweir         InitMethod,
646cdf0e10cSrcweir         // a default method
647cdf0e10cSrcweir         DefaultMethod,
648cdf0e10cSrcweir         // a method which is used (externally) during the initialization phase
649cdf0e10cSrcweir         MethodUsedDuringInit,
650cdf0e10cSrcweir         // a method which does not need initialization - use with care!
651cdf0e10cSrcweir         MethodWithoutInit
652cdf0e10cSrcweir     };
653cdf0e10cSrcweir 
654cdf0e10cSrcweir     /** constructs the guard
655cdf0e10cSrcweir 
656cdf0e10cSrcweir         @param _document
657cdf0e10cSrcweir             the ODatabaseDocument instance
658cdf0e10cSrcweir 
659cdf0e10cSrcweir         @throws ::com::sun::star::lang::DisposedException
660cdf0e10cSrcweir             If the given component is already disposed
661cdf0e10cSrcweir 
662cdf0e10cSrcweir         @throws ::com::sun::star::frame::DoubleInitializationException
663cdf0e10cSrcweir             if _eType is InitMethod, and the given component is already initialized, or currently being initialized.
664cdf0e10cSrcweir 
665cdf0e10cSrcweir         @throws ::com::sun::star::lang::NotInitializedException
666cdf0e10cSrcweir             if _eType is DefaultMethod, and the given component is not yet initialized; or if _eType
667cdf0e10cSrcweir             is MethodUsedDuringInit, and the component is still uninitialized, and not in the initialization
668cdf0e10cSrcweir             phase currently.
669cdf0e10cSrcweir     */
DocumentGuard(const ODatabaseDocument & _document,MethodType _eType=DefaultMethod)670cdf0e10cSrcweir     DocumentGuard( const ODatabaseDocument& _document, MethodType _eType = DefaultMethod )
671cdf0e10cSrcweir         :ModelMethodGuard( _document )
672cdf0e10cSrcweir         ,m_document( _document )
673cdf0e10cSrcweir     {
674cdf0e10cSrcweir         switch ( _eType )
675cdf0e10cSrcweir         {
676cdf0e10cSrcweir             case InitMethod:            m_document.checkNotInitialized();    break;
677cdf0e10cSrcweir             case DefaultMethod:         m_document.checkInitialized();       break;
678cdf0e10cSrcweir             case MethodUsedDuringInit:  m_document.checkNotUninitilized();   break;
679cdf0e10cSrcweir             case MethodWithoutInit:                                         break;
680cdf0e10cSrcweir         }
681cdf0e10cSrcweir     }
682cdf0e10cSrcweir 
~DocumentGuard()683cdf0e10cSrcweir     ~DocumentGuard()
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir     }
686cdf0e10cSrcweir 
clear()687cdf0e10cSrcweir     void clear()
688cdf0e10cSrcweir     {
689cdf0e10cSrcweir         ModelMethodGuard::clear();
690cdf0e10cSrcweir     }
reset()691cdf0e10cSrcweir     void reset()
692cdf0e10cSrcweir     {
693cdf0e10cSrcweir         ModelMethodGuard::reset();
694cdf0e10cSrcweir         m_document.checkDisposed();
695cdf0e10cSrcweir     }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir private:
698cdf0e10cSrcweir 
699cdf0e10cSrcweir     const ODatabaseDocument& m_document;
700cdf0e10cSrcweir };
701cdf0e10cSrcweir 
702cdf0e10cSrcweir //........................................................................
703cdf0e10cSrcweir }	// namespace dbaccess
704cdf0e10cSrcweir //........................................................................
705cdf0e10cSrcweir #endif // _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
706