build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / core / dataaccess / databasedocument.hxx
blobafdd5ffb350c2f633cf7acb4050d57fd2277dcfd
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 #include <cppuhelper/compbase.hxx>
59 #include <cppuhelper/implbase3.hxx>
60 #include <rtl/ref.hxx>
62 namespace comphelper {
63 class NamedValueCollection;
66 namespace dbaccess
69 class DocumentEvents;
70 class DocumentEventExecutor;
71 class DocumentGuard;
73 typedef ::std::vector< css::uno::Reference< css::frame::XController > > Controllers;
75 // ViewMonitor
76 /** helper class monitoring the views of a document, and firing appropriate events
77 when views are attached / detached
79 class ViewMonitor
81 public:
82 explicit ViewMonitor( DocumentEventNotifier& _rEventNotifier )
83 :m_rEventNotifier( _rEventNotifier )
84 ,m_bIsNewDocument( true )
85 ,m_bEverHadController( false )
86 ,m_bLastIsFirstEverController( false )
87 ,m_xLastConnectedController()
91 ViewMonitor(const ViewMonitor&) = delete;
92 const ViewMonitor& operator=(const ViewMonitor&) = delete;
94 void reset()
96 m_bEverHadController = false;
97 m_bLastIsFirstEverController = false;
98 m_xLastConnectedController.clear();
101 /** to be called when a view (aka controller) has been connected to the document
102 @return
103 <TRUE/> if and only if this was the first-ever controller connected to the document
105 bool onControllerConnected(
106 const css::uno::Reference< css::frame::XController >& _rxController
109 /** to be called when a controller is set as current controller
110 @return <TRUE/>
111 if and only if the controller connection indicates that loading the document is finished. This
112 is the case if the given controller has previously been connected, and it was the first controller
113 ever for which this happened.
115 bool onSetCurrentController(
116 const css::uno::Reference< css::frame::XController >& _rxController
119 void onLoadedDocument() { m_bIsNewDocument = false; }
121 private:
122 DocumentEventNotifier& m_rEventNotifier;
123 bool m_bIsNewDocument;
124 bool m_bEverHadController;
125 bool m_bLastIsFirstEverController;
126 css::uno::Reference< css::frame::XController >
127 m_xLastConnectedController;
130 // ODatabaseDocument
131 typedef cppu::PartialWeakComponentImplHelper< css::frame::XModel2
132 , css::util::XModifiable
133 , css::frame::XStorable
134 , css::document::XEventBroadcaster
135 , css::document::XDocumentEventBroadcaster
136 , css::view::XPrintable
137 , css::util::XCloseable
138 , css::lang::XServiceInfo
139 , css::sdb::XOfficeDatabaseDocument
140 , css::ui::XUIConfigurationManagerSupplier
141 , css::document::XStorageBasedDocument
142 , css::document::XEmbeddedScripts
143 , css::document::XScriptInvocationContext
144 , css::script::provider::XScriptProviderSupplier
145 , css::document::XEventsSupplier
146 , css::frame::XLoadable
147 , css::document::XDocumentRecovery
148 > ODatabaseDocument_OfficeDocument;
150 typedef ::cppu::ImplHelper3< css::frame::XTitle
151 , css::frame::XTitleChangeBroadcaster
152 , css::frame::XUntitledNumbers
153 > ODatabaseDocument_Title;
155 class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first!
156 ,public ODatabaseDocument_OfficeDocument
157 ,public ODatabaseDocument_Title
159 enum InitState
161 NotInitialized,
162 Initializing,
163 Initialized
166 typedef std::map< OUString, css::uno::Reference< css::frame::XUntitledNumbers > > TNumberedController;
167 css::uno::Reference< css::ui::XUIConfigurationManager2> m_xUIConfigurationManager;
169 ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners;
170 ::comphelper::OInterfaceContainerHelper2 m_aCloseListener;
171 ::comphelper::OInterfaceContainerHelper2 m_aStorageListeners;
173 DocumentEvents* m_pEventContainer;
174 ::rtl::Reference< DocumentEventExecutor > m_pEventExecutor;
175 DocumentEventNotifier m_aEventNotifier;
177 css::uno::Reference< css::frame::XController > m_xCurrentController;
178 Controllers m_aControllers;
179 ViewMonitor m_aViewMonitor;
181 css::uno::WeakReference< css::container::XNameAccess > m_xForms;
182 css::uno::WeakReference< css::container::XNameAccess > m_xReports;
183 css::uno::WeakReference< css::script::provider::XScriptProvider > m_xScriptProvider;
185 /** @short such module manager is used to classify new opened documents. */
186 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
187 css::uno::Reference< css::frame::XTitle > m_xTitleHelper;
188 TNumberedController m_aNumberedControllers;
190 /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
191 the document has be initialized implicitly - see storeAsURL
193 InitState m_eInitState;
194 bool m_bClosing;
195 bool m_bAllowDocumentScripting;
196 bool m_bHasBeenRecovered;
197 /// If XModel::attachResource() was called to inform us that the document is embedded into an other one.
198 bool m_bEmbedded;
200 enum StoreType { SAVE, SAVE_AS };
201 /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
202 the modified flag, and notifies any listeners as required
204 @param _rURL
205 the URL to store the document to
206 @param _rArguments
207 arguments for storing the document (MediaDescriptor)
208 @param _eType
209 the type of the store process (Save or SaveAs). The method will automatically
210 notify the proper events for this type.
211 @param _rGuard
212 the instance lock to be released before doing synchronous notifications
213 @throws css::io::IOException
214 @throws css::uno::RuntimeException
216 void impl_storeAs_throw(
217 const OUString& _rURL,
218 const ::comphelper::NamedValueCollection& _rArguments,
219 const StoreType _eType,
220 DocumentGuard& _rGuard
222 throw (css::io::IOException,
223 css::uno::RuntimeException,
224 std::exception);
226 /** notifies our storage change listeners that our underlying storage changed
228 @param _rxNewRootStorage
229 the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
230 happened, and the listeners are not notified.
232 void impl_notifyStorageChange_nolck_nothrow(
233 const css::uno::Reference< css::embed::XStorage >& _rxNewRootStorage
236 /// write a single XML stream into the package
237 void WriteThroughComponent(
238 const css::uno::Reference< css::lang::XComponent > & xComponent, /// the component we export
239 const sal_Char* pStreamName, /// the stream name
240 const sal_Char* pServiceName, /// service name of the component
241 const css::uno::Sequence< css::uno::Any> & rArguments, /// the argument (XInitialization)
242 const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc,/// output descriptor
243 const css::uno::Reference< css::embed::XStorage >& _xStorageToSaveTo
244 ) const;
246 /// write a single output stream
247 /// (to be called either directly or by WriteThroughComponent(...))
248 void WriteThroughComponent(
249 const css::uno::Reference< css::io::XOutputStream >& xOutputStream,
250 const css::uno::Reference< css::lang::XComponent >& xComponent,
251 const sal_Char* pServiceName,
252 const css::uno::Sequence< css::uno::Any >& rArguments,
253 const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc
254 ) const;
256 /** writes the content and settings
257 @param sURL
258 The URL
259 @param lArguments
260 The media descriptor
261 @param _xStorageToSaveTo
262 The storage which should be used for saving
264 void impl_writeStorage_throw(
265 const css::uno::Reference< css::embed::XStorage >& _rxTargetStorage,
266 const ::comphelper::NamedValueCollection& _rMediaDescriptor
267 ) const;
269 // ModelDependentComponent overridables
270 virtual css::uno::Reference< css::uno::XInterface > getThis() const override;
272 css::uno::Reference< css::frame::XTitle > const & impl_getTitleHelper_throw();
273 css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
274 const css::uno::Reference< css::uno::XInterface >& _xComponent = css::uno::Reference< css::uno::XInterface >());
276 private:
277 explicit ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
278 // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
279 // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
280 // If you create a ODatabaseDocument directly, you might easily create a leak.
281 // #i50905#
283 protected:
284 virtual void SAL_CALL disposing() override;
286 virtual ~ODatabaseDocument() override;
288 public:
289 struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
290 static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
292 return new ODatabaseDocument( _pImpl );
295 // XServiceInfo
296 virtual OUString SAL_CALL getImplementationName( ) throw(css::uno::RuntimeException, std::exception) override;
297 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) override;
298 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(css::uno::RuntimeException, std::exception) override;
300 // XInterface
301 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) throw (css::uno::RuntimeException, std::exception) override;
302 virtual void SAL_CALL acquire( ) throw () override;
303 virtual void SAL_CALL release( ) throw () override;
305 // XTypeProvider
306 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw (css::uno::RuntimeException, std::exception) override;
307 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (css::uno::RuntimeException, std::exception) override;
309 // XComponent
310 virtual void SAL_CALL dispose( ) throw (css::uno::RuntimeException, std::exception) override;
311 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw (css::uno::RuntimeException, std::exception) override;
312 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
314 // XModel
315 virtual sal_Bool SAL_CALL attachResource( const OUString& URL, const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) throw (css::uno::RuntimeException, std::exception) override ;
316 virtual OUString SAL_CALL getURL( ) throw (css::uno::RuntimeException, std::exception) override ;
317 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs( ) throw (css::uno::RuntimeException, std::exception) override ;
318 virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& Controller ) throw (css::uno::RuntimeException, std::exception) override ;
319 virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& Controller ) throw (css::uno::RuntimeException, std::exception) override ;
320 virtual void SAL_CALL lockControllers( ) throw (css::uno::RuntimeException, std::exception) override ;
321 virtual void SAL_CALL unlockControllers( ) throw (css::uno::RuntimeException, std::exception) override ;
322 virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (css::uno::RuntimeException, std::exception) override ;
323 virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController( ) throw (css::uno::RuntimeException, std::exception) override ;
324 virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& Controller ) throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception) override ;
325 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (css::uno::RuntimeException, std::exception) override ;
327 // XModel2
328 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL getControllers( ) throw (css::uno::RuntimeException, std::exception) override ;
329 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) throw (css::uno::RuntimeException, std::exception) override ;
330 virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createDefaultViewController( const css::uno::Reference< css::frame::XFrame >& Frame ) throw (css::lang::IllegalArgumentException, css::uno::Exception, css::uno::RuntimeException, std::exception) override ;
331 virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createViewController( const OUString& ViewName, const css::uno::Sequence< css::beans::PropertyValue >& Arguments, const css::uno::Reference< css::frame::XFrame >& Frame ) throw (css::lang::IllegalArgumentException, css::uno::Exception, css::uno::RuntimeException, std::exception) override ;
333 // XStorable
334 virtual sal_Bool SAL_CALL hasLocation( ) throw (css::uno::RuntimeException, std::exception) override ;
335 virtual OUString SAL_CALL getLocation( ) throw (css::uno::RuntimeException, std::exception) override ;
336 virtual sal_Bool SAL_CALL isReadonly( ) throw (css::uno::RuntimeException, std::exception) override ;
337 virtual void SAL_CALL store( ) throw (css::io::IOException, css::uno::RuntimeException, std::exception) override ;
338 virtual void SAL_CALL storeAsURL( const OUString& sURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw (css::io::IOException, css::uno::RuntimeException, std::exception) override ;
339 virtual void SAL_CALL storeToURL( const OUString& sURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw (css::io::IOException, css::uno::RuntimeException, std::exception) override ;
341 // XModifyBroadcaster
342 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
343 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
345 // css::util::XModifiable
346 virtual sal_Bool SAL_CALL isModified( ) throw (css::uno::RuntimeException, std::exception) override ;
347 virtual void SAL_CALL setModified( sal_Bool bModified ) throw (css::beans::PropertyVetoException, css::uno::RuntimeException, std::exception) override ;
349 // XEventBroadcaster
350 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::document::XEventListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
351 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& aListener ) throw (css::uno::RuntimeException, std::exception) override;
353 // XDocumentEventBroadcaster
354 virtual void SAL_CALL addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override;
355 virtual void SAL_CALL removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override;
356 virtual void SAL_CALL notifyDocumentEvent( const OUString& EventName, const css::uno::Reference< css::frame::XController2 >& ViewController, const css::uno::Any& Supplement ) throw (css::lang::IllegalArgumentException, css::lang::NoSupportException, css::uno::RuntimeException, std::exception) override;
358 // XPrintable
359 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPrinter( ) throw (css::uno::RuntimeException, std::exception) override ;
360 virtual void SAL_CALL setPrinter( const css::uno::Sequence< css::beans::PropertyValue >& aPrinter ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override ;
361 virtual void SAL_CALL print( const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override ;
363 // XFormDocumentsSupplier
364 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getFormDocuments( ) throw (css::uno::RuntimeException, std::exception) override;
366 // XReportDocumentsSupplier
367 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReportDocuments( ) throw (css::uno::RuntimeException, std::exception) override;
369 // XCloseable
370 virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (css::util::CloseVetoException, css::uno::RuntimeException, std::exception) override;
371 virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override;
372 virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) throw (css::uno::RuntimeException, std::exception) override;
374 // XUIConfigurationManagerSupplier
375 virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) throw (css::uno::RuntimeException, std::exception) override;
377 // XDocumentSubStorageSupplier
378 virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) throw (css::uno::RuntimeException, std::exception) override;
379 virtual css::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (css::io::IOException, css::uno::RuntimeException, std::exception) override;
381 // XOfficeDatabaseDocument
382 virtual css::uno::Reference< css::sdbc::XDataSource > SAL_CALL getDataSource() throw (css::uno::RuntimeException, std::exception) override;
384 // XStorageBasedDocument
385 virtual void SAL_CALL loadFromStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) throw (css::lang::IllegalArgumentException, css::frame::DoubleInitializationException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
386 virtual void SAL_CALL storeToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) throw (css::lang::IllegalArgumentException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
387 virtual void SAL_CALL switchToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) throw (css::lang::IllegalArgumentException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
388 virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentStorage( ) throw (css::io::IOException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
389 virtual void SAL_CALL addStorageChangeListener( const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) override;
390 virtual void SAL_CALL removeStorageChangeListener( const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) override;
392 // XEmbeddedScripts
393 virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (css::uno::RuntimeException, std::exception) override;
394 virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (css::uno::RuntimeException, std::exception) override;
395 virtual sal_Bool SAL_CALL getAllowMacroExecution() throw (css::uno::RuntimeException, std::exception) override;
397 // XScriptInvocationContext
398 virtual css::uno::Reference< css::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (css::uno::RuntimeException, std::exception) override;
400 // XScriptProviderSupplier
401 virtual css::uno::Reference< css::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) throw (css::uno::RuntimeException, std::exception) override;
403 // XEventsSupplier
404 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) throw (css::uno::RuntimeException, std::exception) override;
406 // XLoadable
407 virtual void SAL_CALL initNew( ) throw (css::frame::DoubleInitializationException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
408 virtual void SAL_CALL load( const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw (css::frame::DoubleInitializationException, css::io::IOException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
410 // css.document.XDocumentRecovery
411 virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( css::uno::RuntimeException, std::exception ) override;
412 virtual void SAL_CALL storeToRecoveryFile( const OUString& i_TargetLocation, const css::uno::Sequence< css::beans::PropertyValue >& i_MediaDescriptor ) throw ( css::uno::RuntimeException, css::io::IOException, css::lang::WrappedTargetException, std::exception ) override;
413 virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const css::uno::Sequence< css::beans::PropertyValue >& i_MediaDescriptor ) throw ( css::uno::RuntimeException, css::io::IOException, css::lang::WrappedTargetException, std::exception ) override;
415 // XTitle
416 virtual OUString SAL_CALL getTitle( ) throw (css::uno::RuntimeException, std::exception) override;
417 virtual void SAL_CALL setTitle( const OUString& sTitle ) throw (css::uno::RuntimeException, std::exception) override;
419 // XTitleChangeBroadcaster
420 virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) override;
421 virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) override;
423 // XUntitledNumbers
424 virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override;
425 virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override;
426 virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override;
427 virtual OUString SAL_CALL getUntitledPrefix( ) throw (css::uno::RuntimeException, std::exception) override;
429 /** clears the given object container
431 Clearing is done via disposal - the method calls XComponent::dispose at the given object,
432 which must be one of our impl's or our object containers (m_xForms, m_xReports,
433 m_xTableDefinitions, m_xCommandDefinitions)
435 @param _rxContainer
436 the container to clear
438 static void clearObjectContainer(
439 css::uno::WeakReference< css::container::XNameAccess >& _rxContainer);
441 /** checks whether the component is already initialized, throws a NotInitializedException if not
443 inline void checkInitialized() const
445 if ( !impl_isInitialized() )
446 throw css::lang::NotInitializedException( OUString(), getThis() );
449 /** checks the document is currently in the initialization phase, or already initialized.
450 Throws NotInitializedException if not so.
452 inline void checkNotUninitilized() const
454 if ( impl_isInitialized() || impl_isInitializing() )
455 // fine
456 return;
458 throw css::lang::NotInitializedException( OUString(), getThis() );
461 /** checks whether the document is currently being initialized, or already initialized,
462 throws a DoubleInitializationException if so
464 inline void checkNotInitialized() const
466 if ( impl_isInitializing() || impl_isInitialized() )
467 throw css::frame::DoubleInitializationException( OUString(), getThis() );
470 private:
471 /// @throws css::uno::RuntimeException
472 css::uno::Reference< css::ui::XUIConfigurationManager2 > const & getUIConfigurationManager2() throw (css::uno::RuntimeException);
474 /** returns whether the model is currently being initialized
476 bool impl_isInitializing() const { return m_eInitState == Initializing; }
478 /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
480 bool impl_isInitialized() const { return m_eInitState == Initialized; }
482 /// tells the model it is being initialized now
483 void impl_setInitializing() { m_eInitState = Initializing; }
485 /// tells the model its initialization is done
486 void impl_setInitialized();
488 /** closes the frames of all connected controllers
490 @param _bDeliverOwnership
491 determines if the ownership should be transferred to the component which
492 possibly vetos the closing
494 @throws css::util::CloseVetoException
495 if the closing was vetoed by any instance
497 void impl_closeControllerFrames_nolck_throw( bool _bDeliverOwnership );
499 /** disposes the frames of all controllers which are still left in m_aControllers.
501 void impl_disposeControllerFrames_nothrow();
503 /** does a reparenting at the given object container to ourself
505 Calls XChild::setParent at the given object, which must be one of our impl's or our
506 object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
508 void impl_reparent_nothrow( const css::uno::WeakReference< css::container::XNameAccess >& _rxContainer );
510 /** retrieves the forms or reports contained, creates and initializes it, if necessary
512 @throws DisposedException
513 if the instance is already disposed
514 @throws IllegalArgumentException
515 if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
517 css::uno::Reference< css::container::XNameAccess >
518 impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
520 /** resets everything
522 @precond
523 m_pImpl is not <NULL/>
525 void
526 impl_reset_nothrow();
528 /** imports the document from the given resource.
530 static void
531 impl_import_nolck_throw(
532 const css::uno::Reference< css::uno::XComponentContext >& _rContext,
533 const css::uno::Reference< css::uno::XInterface >& _rxTargetComponent,
534 const ::comphelper::NamedValueCollection& _rResource
537 /** creates a storage for the given URL, truncating it if a file with this name already exists
539 @throws Exception
540 if creating the storage failed
542 @return
543 the newly created storage for the file at the given URL
545 css::uno::Reference< css::embed::XStorage >
546 impl_createStorageFor_throw(
547 const OUString& _rURL
548 ) const;
550 /** sets our "modified" flag
552 will notify all our respective listeners, if the "modified" state actually changed
554 @param _bModified
555 the (new) flag indicating whether the document is currently modified or not
556 @param _rGuard
557 the guard for our instance. At method entry, the guard must hold the lock. At the moment
558 of method leave, the lock will be released.
559 @precond
560 our mutex is locked
561 @postcond
562 our mutex is not locked
564 void impl_setModified_nothrow( bool _bModified, DocumentGuard& _rGuard );
566 /** stores the document to the given storage
568 Note that the document is actually not rebased to this storage, it just stores a copy of itself
569 to the given target storage.
571 @param _rxTargetStorage
572 denotes the storage to store the document into
573 @param _rMediaDescriptor
574 contains additional parameters for storing the document
575 @param _rDocGuard
576 a guard which holds the (only) lock to the document, and which will be temporarily
577 released where necessary (e.g. for notifications, or calling into other components)
579 @throws css::uno::IllegalArgumentException
580 if the given storage is <NULL/>.
582 @throws css::uno::RuntimeException
583 when any of the used operations throws it
585 @throws css::io::IOException
586 when any of the used operations throws it, or any other exception occurs which is no
587 RuntimeException and no IOException
589 void impl_storeToStorage_throw(
590 const css::uno::Reference< css::embed::XStorage >& _rxTargetStorage,
591 const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor,
592 DocumentGuard& _rDocGuard
593 ) const;
595 /** impl-version of attachResource
597 @param i_rLogicalDocumentURL
598 denotes the logical URL of the document, to be reported by getURL/getLocation
599 @param i_rMediaDescriptor
600 denotes additional document parameters
601 @param _rDocGuard
602 is the guard which currently protects the document instance
604 bool impl_attachResource(
605 const OUString& i_rLogicalDocumentURL,
606 const css::uno::Sequence< css::beans::PropertyValue >& i_rMediaDescriptor,
607 DocumentGuard& _rDocGuard
610 /** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
611 the given caught non-IOException error
613 void impl_throwIOExceptionCausedBySave_throw(
614 const css::uno::Any& i_rError,
615 const OUString& i_rTargetURL
616 ) const;
619 /** an extended version of the ModelMethodGuard, which also cares for the initialization state
620 of the document
622 class DocumentGuard : private ModelMethodGuard
624 public:
625 enum InitMethod_
627 // a method which is to initialize the document
628 InitMethod,
631 enum DefaultMethod_
633 // a default method
634 DefaultMethod
637 enum MethodUsedDuringInit_
639 // a method which is used (externally) during the initialization phase
640 MethodUsedDuringInit
643 enum MethodWithoutInit_
645 // a method which does not need initialization - use with care!
646 MethodWithoutInit
650 /** constructs the guard
652 @param _document
653 the ODatabaseDocument instance
655 @throws css::lang::DisposedException
656 If the given component is already disposed
658 @throws css::lang::NotInitializedException
659 if the given component is not yet initialized
661 DocumentGuard(const ODatabaseDocument& _document, DefaultMethod_)
662 : ModelMethodGuard(_document)
663 , m_document(_document )
665 m_document.checkInitialized();
668 /** constructs the guard
670 @param _document
671 the ODatabaseDocument instance
673 @throws css::lang::DisposedException
674 If the given component is already disposed
676 @throws css::frame::DoubleInitializationException
677 if the given component is already initialized, or currently being initialized.
679 DocumentGuard(const ODatabaseDocument& _document, InitMethod_)
680 : ModelMethodGuard(_document)
681 , m_document(_document)
683 m_document.checkNotInitialized();
686 /** constructs the guard
688 @param _document
689 the ODatabaseDocument instance
691 @throws css::lang::DisposedException
692 If the given component is already disposed
694 @throws css::lang::NotInitializedException
695 if the component is still uninitialized, and not in the initialization
696 phase currently.
698 DocumentGuard(const ODatabaseDocument& _document, MethodUsedDuringInit_)
699 : ModelMethodGuard(_document)
700 , m_document(_document)
702 m_document.checkNotUninitilized();
705 /** constructs the guard
707 @param _document
708 the ODatabaseDocument instance
710 @throws css::lang::DisposedException
711 If the given component is already disposed
713 DocumentGuard(const ODatabaseDocument& _document, MethodWithoutInit_)
714 : ModelMethodGuard( _document )
715 , m_document( _document )
719 ~DocumentGuard()
723 void clear()
725 ModelMethodGuard::clear();
727 void reset()
729 ModelMethodGuard::reset();
730 m_document.checkDisposed();
733 private:
735 const ODatabaseDocument& m_document;
738 } // namespace dbaccess
739 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
741 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */