fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / core / dataaccess / databasedocument.hxx
blob693ad296f7c8fd142a541a8f2a236ee01ffaf27b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
20 #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
22 #include <sal/config.h>
24 #include <map>
26 #include "ModelImpl.hxx"
27 #include "documenteventnotifier.hxx"
29 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
30 #include <com/sun/star/frame/XModel2.hpp>
31 #include <com/sun/star/frame/XTitle.hpp>
32 #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
33 #include <com/sun/star/frame/XUntitledNumbers.hpp>
34 #include <com/sun/star/frame/XStorable.hpp>
35 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
36 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
37 #include <com/sun/star/view/XPrintable.hpp>
38 #include <com/sun/star/frame/XModuleManager2.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
42 #include <com/sun/star/embed/XTransactionListener.hpp>
43 #include <com/sun/star/document/XStorageBasedDocument.hpp>
44 #include <com/sun/star/document/XEmbeddedScripts.hpp>
45 #include <com/sun/star/document/XEventsSupplier.hpp>
46 #include <com/sun/star/document/XScriptInvocationContext.hpp>
47 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
48 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
49 #include <com/sun/star/frame/XLoadable.hpp>
50 #include <com/sun/star/document/XEventBroadcaster.hpp>
51 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
52 #include <com/sun/star/document/XDocumentRecovery.hpp>
53 #include <com/sun/star/ui/XUIConfigurationManager2.hpp>
54 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
55 #include <com/sun/star/util/XCloseable.hpp>
56 #include <com/sun/star/util/XModifiable.hpp>
58 #ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
59 #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
60 #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 17
61 #include <comphelper/implbase_var.hxx>
62 #endif
64 #include <cppuhelper/compbase10.hxx>
65 #include <cppuhelper/implbase3.hxx>
66 #include <rtl/ref.hxx>
68 #include <boost/shared_ptr.hpp>
69 #include <boost/noncopyable.hpp>
71 namespace comphelper {
72 class NamedValueCollection;
75 namespace dbaccess
78 class DocumentEvents;
79 class DocumentEventExecutor;
80 class DocumentGuard;
82 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers;
84 // ViewMonitor
85 /** helper class monitoring the views of a document, and firing appropriate events
86 when views are attached / detached
88 class ViewMonitor : public boost::noncopyable
90 public:
91 ViewMonitor( DocumentEventNotifier& _rEventNotifier )
92 :m_rEventNotifier( _rEventNotifier )
93 ,m_bIsNewDocument( true )
94 ,m_bEverHadController( false )
95 ,m_bLastIsFirstEverController( false )
96 ,m_xLastConnectedController()
100 void reset()
102 m_bEverHadController = false;
103 m_bLastIsFirstEverController = false;
104 m_xLastConnectedController.clear();
107 /** to be called when a view (aka controller) has been connected to the document
108 @return
109 <TRUE/> if and only if this was the first-ever controller connected to the document
111 bool onControllerConnected(
112 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
115 /** to be called when a controller is set as current controller
116 @return <TRUE/>
117 if and only if the controller connection indicates that loading the document is finished. This
118 is the case if the given controller has previously been connected, and it was the first controller
119 ever for which this happened.
121 bool onSetCurrentController(
122 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
125 void onLoadedDocument() { m_bIsNewDocument = false; }
127 private:
128 DocumentEventNotifier& m_rEventNotifier;
129 bool m_bIsNewDocument;
130 bool m_bEverHadController;
131 bool m_bLastIsFirstEverController;
132 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
133 m_xLastConnectedController;
136 // ODatabaseDocument
137 typedef ::comphelper::PartialWeakComponentImplHelper17 < ::com::sun::star::frame::XModel2
138 , ::com::sun::star::util::XModifiable
139 , ::com::sun::star::frame::XStorable
140 , ::com::sun::star::document::XEventBroadcaster
141 , ::com::sun::star::document::XDocumentEventBroadcaster
142 , ::com::sun::star::view::XPrintable
143 , ::com::sun::star::util::XCloseable
144 , ::com::sun::star::lang::XServiceInfo
145 , ::com::sun::star::sdb::XOfficeDatabaseDocument
146 , ::com::sun::star::ui::XUIConfigurationManagerSupplier
147 , ::com::sun::star::document::XStorageBasedDocument
148 , ::com::sun::star::document::XEmbeddedScripts
149 , ::com::sun::star::document::XScriptInvocationContext
150 , ::com::sun::star::script::provider::XScriptProviderSupplier
151 , ::com::sun::star::document::XEventsSupplier
152 , ::com::sun::star::frame::XLoadable
153 , ::com::sun::star::document::XDocumentRecovery
154 > ODatabaseDocument_OfficeDocument;
156 typedef ::cppu::ImplHelper3< ::com::sun::star::frame::XTitle
157 , ::com::sun::star::frame::XTitleChangeBroadcaster
158 , ::com::sun::star::frame::XUntitledNumbers
159 > ODatabaseDocument_Title;
161 class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first!
162 ,public ODatabaseDocument_OfficeDocument
163 ,public ODatabaseDocument_Title
165 enum InitState
167 NotInitialized,
168 Initializing,
169 Initialized
172 typedef std::map< OUString, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > > TNumberedController;
173 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2> m_xUIConfigurationManager;
175 ::cppu::OInterfaceContainerHelper m_aModifyListeners;
176 ::cppu::OInterfaceContainerHelper m_aCloseListener;
177 ::cppu::OInterfaceContainerHelper m_aStorageListeners;
179 DocumentEvents* m_pEventContainer;
180 ::rtl::Reference< DocumentEventExecutor > m_pEventExecutor;
181 DocumentEventNotifier m_aEventNotifier;
183 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xCurrentController;
184 Controllers m_aControllers;
185 ViewMonitor m_aViewMonitor;
187 ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xForms;
188 ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xReports;
189 ::com::sun::star::uno::WeakReference< ::com::sun::star::script::provider::XScriptProvider > m_xScriptProvider;
191 /** @short such module manager is used to classify new opened documents. */
192 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
193 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > m_xTitleHelper;
194 TNumberedController m_aNumberedControllers;
196 /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
197 the document has be initialized implicitly - see storeAsURL
199 InitState m_eInitState;
200 bool m_bClosing;
201 bool m_bAllowDocumentScripting;
202 bool m_bHasBeenRecovered;
203 /// If XModel::attachResource() was called to inform us that the document is embedded into an other one.
204 bool m_bEmbedded;
206 enum StoreType { SAVE, SAVE_AS };
207 /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
208 the modified flag, and notifies any listeners as required
210 @param _rURL
211 the URL to store the document to
212 @param _rArguments
213 arguments for storing the document (MediaDescriptor)
214 @param _eType
215 the type of the store process (Save or SaveAs). The method will automatically
216 notify the proper events for this type.
217 @param _rGuard
218 the instance lock to be released before doing synchronous notifications
220 void impl_storeAs_throw(
221 const OUString& _rURL,
222 const ::comphelper::NamedValueCollection& _rArguments,
223 const StoreType _eType,
224 DocumentGuard& _rGuard
226 throw (css::io::IOException,
227 css::uno::RuntimeException,
228 std::exception);
230 /** notifies our storage change listeners that our underlying storage changed
232 @param _rxNewRootStorage
233 the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
234 happened, and the listeners are not notified.
236 void impl_notifyStorageChange_nolck_nothrow(
237 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
240 /// write a single XML stream into the package
241 void WriteThroughComponent(
242 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > & xComponent, /// the component we export
243 const sal_Char* pStreamName, /// the stream name
244 const sal_Char* pServiceName, /// service name of the component
245 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> & rArguments, /// the argument (XInitialization)
246 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc,/// output descriptor
247 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _xStorageToSaveTo
248 ) const;
250 /// write a single output stream
251 /// (to be called either directly or by WriteThroughComponent(...))
252 void WriteThroughComponent(
253 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
254 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
255 const sal_Char* pServiceName,
256 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
257 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
258 ) const;
260 /** writes the content and settings
261 @param sURL
262 The URL
263 @param lArguments
264 The media descriptor
265 @param _xStorageToSaveTo
266 The storage which should be used for saving
268 void impl_writeStorage_throw(
269 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
270 const ::comphelper::NamedValueCollection& _rMediaDescriptor
271 ) const;
273 // ModelDependentComponent overridables
274 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const SAL_OVERRIDE;
276 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper_throw();
277 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
278 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
280 private:
281 ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
282 // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
283 // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
284 // If you create a ODatabaseDocument directly, you might easily create a leak.
285 // #i50905#
287 protected:
288 virtual void SAL_CALL disposing() SAL_OVERRIDE;
290 virtual ~ODatabaseDocument();
292 public:
293 struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
294 static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
296 return new ODatabaseDocument( _pImpl );
299 // XServiceInfo
300 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
302 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
304 // ::com::sun::star::lang::XServiceInfo - static methods
305 static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static() throw( ::com::sun::star::uno::RuntimeException );
306 static OUString getImplementationName_static() throw( ::com::sun::star::uno::RuntimeException );
307 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
308 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
310 // XInterface
311 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
312 virtual void SAL_CALL acquire( ) throw () SAL_OVERRIDE;
313 virtual void SAL_CALL release( ) throw () SAL_OVERRIDE;
315 // XTypeProvider
316 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
317 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
319 // XComponent
320 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
321 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
322 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
324 // XModel
325 virtual sal_Bool SAL_CALL attachResource( const OUString& URL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
326 virtual OUString SAL_CALL getURL( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
327 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
328 virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
329 virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
330 virtual void SAL_CALL lockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
331 virtual void SAL_CALL unlockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
332 virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
333 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
334 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, std::exception) SAL_OVERRIDE ;
335 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
337 // XModel2
338 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL getControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
339 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
340 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, std::exception) SAL_OVERRIDE ;
341 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createViewController( const 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, std::exception) SAL_OVERRIDE ;
343 // XStorable
344 virtual sal_Bool SAL_CALL hasLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
345 virtual OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
346 virtual sal_Bool SAL_CALL isReadonly( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
347 virtual void SAL_CALL store( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
348 virtual void SAL_CALL storeAsURL( const 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, std::exception) SAL_OVERRIDE ;
349 virtual void SAL_CALL storeToURL( const 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, std::exception) SAL_OVERRIDE ;
351 // XModifyBroadcaster
352 virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
353 virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
355 // ::com::sun::star::util::XModifiable
356 virtual sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
357 virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
359 // XEventBroadcaster
360 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
361 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
363 // XDocumentEventBroadcaster
364 virtual void SAL_CALL addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
365 virtual void SAL_CALL removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
366 virtual void SAL_CALL notifyDocumentEvent( const 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, std::exception) SAL_OVERRIDE;
368 // XPrintable
369 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
370 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, std::exception) SAL_OVERRIDE ;
371 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, std::exception) SAL_OVERRIDE ;
373 // XFormDocumentsSupplier
374 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
376 // XReportDocumentsSupplier
377 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
379 // XCloseable
380 virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
381 virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
384 // XUIConfigurationManagerSupplier
385 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
387 // XDocumentSubStorageSupplier
388 virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
389 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
391 // XOfficeDatabaseDocument
392 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
394 // XStorageBasedDocument
395 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, std::exception) SAL_OVERRIDE;
396 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, std::exception) SAL_OVERRIDE;
397 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, std::exception) SAL_OVERRIDE;
398 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, std::exception) SAL_OVERRIDE;
399 virtual void SAL_CALL addStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
400 virtual void SAL_CALL removeStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
402 // XEmbeddedScripts
403 virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
404 virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
405 virtual sal_Bool SAL_CALL getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
407 // XScriptInvocationContext
408 virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
410 // XScriptProviderSupplier
411 virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
413 // XEventsSupplier
414 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
416 // XLoadable
417 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, std::exception) SAL_OVERRIDE;
418 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, std::exception) SAL_OVERRIDE;
420 // css.document.XDocumentRecovery
421 virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
422 virtual void SAL_CALL storeToRecoveryFile( const 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, std::exception ) SAL_OVERRIDE;
423 virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const 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, std::exception ) SAL_OVERRIDE;
425 // XTitle
426 virtual OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
427 virtual void SAL_CALL setTitle( const OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
429 // XTitleChangeBroadcaster
430 virtual void SAL_CALL addTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
431 virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
433 // XUntitledNumbers
434 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, std::exception) SAL_OVERRIDE;
435 virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
436 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, std::exception) SAL_OVERRIDE;
437 virtual OUString SAL_CALL getUntitledPrefix( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
439 /** clears the given object container
441 Clearing is done via disposal - the method calls XComponent::dispose at the given object,
442 which must be one of our impl's or our object containers (m_xForms, m_xReports,
443 m_xTableDefinitions, m_xCommandDefinitions)
445 @param _rxContainer
446 the container to clear
448 static void clearObjectContainer(
449 ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer);
451 /** checks whether the component is already initialized, throws a NotInitializedException if not
453 inline void checkInitialized() const
455 if ( !impl_isInitialized() )
456 throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
459 /** checks the document is currently in the initialization phase, or already initialized.
460 Throws NotInitializedException if not so.
462 inline void checkNotUninitilized() const
464 if ( impl_isInitialized() || impl_isInitializing() )
465 // fine
466 return;
468 throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
471 /** checks whether the document is currently being initialized, or already initialized,
472 throws a DoubleInitializationException if so
474 inline void checkNotInitialized() const
476 if ( impl_isInitializing() || impl_isInitialized() )
477 throw ::com::sun::star::frame::DoubleInitializationException( OUString(), getThis() );
480 private:
481 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2 > getUIConfigurationManager2() throw (::com::sun::star::uno::RuntimeException);
483 /** returns whether the model is currently being initialized
485 bool impl_isInitializing() const { return m_eInitState == Initializing; }
487 /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
489 bool impl_isInitialized() const { return m_eInitState == Initialized; }
491 /// tells the model it is being initialized now
492 void impl_setInitializing() { m_eInitState = Initializing; }
494 /// tells the model its initialization is done
495 void impl_setInitialized();
497 /** closes the frames of all connected controllers
499 @param _bDeliverOwnership
500 determines if the ownership should be transferred to the component which
501 possibly vetos the closing
503 @raises ::com::sun::star::util::CloseVetoException
504 if the closing was vetoed by any instance
506 void impl_closeControllerFrames_nolck_throw( bool _bDeliverOwnership );
508 /** disposes the frames of all controllers which are still left in m_aControllers.
510 void impl_disposeControllerFrames_nothrow();
512 /** does a reparenting at the given object container to ourself
514 Calls XChild::setParent at the given object, which must be one of our impl's or our
515 object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
517 void impl_reparent_nothrow( const ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer );
519 /** retrieves the forms or reports contained, creates and initializes it, if necessary
521 @raises DisposedException
522 if the instance is already disposed
523 @raises IllegalArgumentException
524 if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
526 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
527 impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
529 /** resets everything
531 @precond
532 m_pImpl is not <NULLL/>
534 void
535 impl_reset_nothrow();
537 /** imports the document from the given resource.
539 static void
540 impl_import_nolck_throw(
541 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rContext,
542 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
543 const ::comphelper::NamedValueCollection& _rResource
546 /** creates a storage for the given URL, truncating it if a file with this name already exists
548 @throws Exception
549 if creating the storage failed
551 @return
552 the newly created storage for the file at the given URL
554 ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
555 impl_createStorageFor_throw(
556 const OUString& _rURL
557 ) const;
559 /** sets our "modified" flag
561 will notify all our respective listeners, if the "modified" state actually changed
563 @param _bModified
564 the (new) flag indicating whether the document is currently modified or not
565 @param _rGuard
566 the guard for our instance. At method entry, the guard must hold the lock. At the moment
567 of method leave, the lock will be released.
568 @precond
569 our mutex is locked
570 @postcond
571 our mutex is not locked
573 void impl_setModified_nothrow( bool _bModified, DocumentGuard& _rGuard );
575 /** stores the document to the given storage
577 Note that the document is actually not rebased to this storage, it just stores a copy of itself
578 to the given target storage.
580 @param _rxTargetStorage
581 denotes the storage to store the document into
582 @param _rMediaDescriptor
583 contains additional parameters for storing the document
584 @param _rDocGuard
585 a guard which holds the (only) lock to the document, and which will be temporarily
586 released where necessary (e.g. for notifications, or calling into other components)
588 @throws ::com::sun::star::uno::IllegalArgumentException
589 if the given storage is <NULL/>.
591 @throws ::com::sun::star::uno::RuntimeException
592 when any of the used operations throws it
594 @throws ::com::sun::star::io::IOException
595 when any of the used operations throws it, or any other exception occurs which is no
596 RuntimeException and no IOException
598 void impl_storeToStorage_throw(
599 const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
600 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor,
601 DocumentGuard& _rDocGuard
602 ) const;
604 /** impl-version of attachResource
606 @param i_rLogicalDocumentURL
607 denotes the logical URL of the document, to be reported by getURL/getLocation
608 @param i_rMediaDescriptor
609 denotes additional document parameters
610 @param _rDocGuard
611 is the guard which currently protects the document instance
613 bool impl_attachResource(
614 const OUString& i_rLogicalDocumentURL,
615 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rMediaDescriptor,
616 DocumentGuard& _rDocGuard
619 /** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
620 the given caught non-IOException error
622 void impl_throwIOExceptionCausedBySave_throw(
623 const ::com::sun::star::uno::Any& i_rError,
624 const OUString& i_rTargetURL
625 ) const;
628 /** an extended version of the ModelMethodGuard, which also cares for the initialization state
629 of the document
631 class DocumentGuard : private ModelMethodGuard
633 public:
634 enum __InitMethod
636 // a method which is to initialize the document
637 InitMethod,
640 enum __DefaultMethod
642 // a default method
643 DefaultMethod
646 enum __MethodUsedDuringInit
648 // a method which is used (externally) during the initialization phase
649 MethodUsedDuringInit
652 enum __MethodWithoutInit
654 // a method which does not need initialization - use with care!
655 MethodWithoutInit
659 /** constructs the guard
661 @param _document
662 the ODatabaseDocument instance
664 @throws ::com::sun::star::lang::DisposedException
665 If the given component is already disposed
667 @throws ::com::sun::star::lang::NotInitializedException
668 if the given component is not yet initialized
670 DocumentGuard(const ODatabaseDocument& _document, __DefaultMethod)
671 : ModelMethodGuard(_document)
672 , m_document(_document )
674 m_document.checkInitialized();
677 /** constructs the guard
679 @param _document
680 the ODatabaseDocument instance
682 @throws ::com::sun::star::lang::DisposedException
683 If the given component is already disposed
685 @throws ::com::sun::star::frame::DoubleInitializationException
686 if the given component is already initialized, or currently being initialized.
688 DocumentGuard(const ODatabaseDocument& _document, __InitMethod)
689 : ModelMethodGuard(_document)
690 , m_document(_document)
692 m_document.checkNotInitialized();
695 /** constructs the guard
697 @param _document
698 the ODatabaseDocument instance
700 @throws ::com::sun::star::lang::DisposedException
701 If the given component is already disposed
703 @throws ::com::sun::star::lang::NotInitializedException
704 if the component is still uninitialized, and not in the initialization
705 phase currently.
707 DocumentGuard(const ODatabaseDocument& _document, __MethodUsedDuringInit)
708 : ModelMethodGuard(_document)
709 , m_document(_document)
711 m_document.checkNotUninitilized();
714 /** constructs the guard
716 @param _document
717 the ODatabaseDocument instance
719 @throws ::com::sun::star::lang::DisposedException
720 If the given component is already disposed
722 DocumentGuard(const ODatabaseDocument& _document, __MethodWithoutInit)
723 : ModelMethodGuard( _document )
724 , m_document( _document )
728 ~DocumentGuard()
732 void clear()
734 ModelMethodGuard::clear();
736 void reset()
738 ModelMethodGuard::reset();
739 m_document.checkDisposed();
742 private:
744 const ODatabaseDocument& m_document;
747 } // namespace dbaccess
748 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
750 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */