tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / source / core / dataaccess / databasedocument.hxx
blob46d86d278dc9f75bfd4acd00b00caf4d67680482
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 #pragma once
21 #include <sal/config.h>
23 #include <atomic>
24 #include <map>
25 #include <memory>
27 #include <ModelImpl.hxx>
28 #include "documenteventnotifier.hxx"
30 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
31 #include <com/sun/star/frame/DoubleInitializationException.hpp>
32 #include <com/sun/star/frame/XModel3.hpp>
33 #include <com/sun/star/frame/XTitle.hpp>
34 #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
35 #include <com/sun/star/frame/XUntitledNumbers.hpp>
36 #include <com/sun/star/frame/XStorable.hpp>
37 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
38 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
39 #include <com/sun/star/view/XPrintable.hpp>
40 #include <com/sun/star/frame/XModuleManager2.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/NotInitializedException.hpp>
44 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
45 #include <com/sun/star/embed/XTransactionListener.hpp>
46 #include <com/sun/star/document/XStorageBasedDocument.hpp>
47 #include <com/sun/star/document/XEmbeddedScripts.hpp>
48 #include <com/sun/star/document/XEventsSupplier.hpp>
49 #include <com/sun/star/document/XScriptInvocationContext.hpp>
50 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
51 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
52 #include <com/sun/star/frame/XLoadable.hpp>
53 #include <com/sun/star/document/XEventBroadcaster.hpp>
54 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
55 #include <com/sun/star/document/XDocumentRecovery.hpp>
56 #include <com/sun/star/ui/XUIConfigurationManager2.hpp>
57 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
58 #include <com/sun/star/util/XCloseable.hpp>
59 #include <com/sun/star/util/XModifiable.hpp>
61 #include <comphelper/interfacecontainer3.hxx>
62 #include <cppuhelper/compbase.hxx>
63 #include <cppuhelper/implbase3.hxx>
64 #include <rtl/ref.hxx>
66 namespace comphelper {
67 class NamedValueCollection;
69 namespace framework { class TitleHelper; }
71 namespace dbaccess
74 class DocumentEvents;
75 class DocumentEventExecutor;
76 class DocumentGuard;
77 class OCommandContainer;
79 typedef std::vector< css::uno::Reference< css::frame::XController > > Controllers;
81 // ViewMonitor
82 /** helper class monitoring the views of a document, and firing appropriate events
83 when views are attached / detached
85 class ViewMonitor
87 public:
88 explicit ViewMonitor( DocumentEventNotifier& _rEventNotifier )
89 :m_rEventNotifier( _rEventNotifier )
90 ,m_bIsNewDocument( true )
91 ,m_bEverHadController( false )
92 ,m_bLastIsFirstEverController( false )
93 ,m_xLastConnectedController()
97 ViewMonitor(const ViewMonitor&) = delete;
98 const ViewMonitor& operator=(const ViewMonitor&) = delete;
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 css::uno::Reference< css::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 css::uno::Reference< css::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 css::uno::Reference< css::frame::XController >
133 m_xLastConnectedController;
136 // ODatabaseDocument
137 typedef cppu::PartialWeakComponentImplHelper< css::frame::XModel3
138 , css::util::XModifiable
139 , css::frame::XStorable
140 , css::document::XEventBroadcaster
141 , css::document::XDocumentEventBroadcaster
142 , css::view::XPrintable
143 , css::util::XCloseable
144 , css::lang::XServiceInfo
145 , css::sdb::XOfficeDatabaseDocument
146 , css::ui::XUIConfigurationManagerSupplier
147 , css::document::XStorageBasedDocument
148 , css::document::XEmbeddedScripts
149 , css::document::XScriptInvocationContext
150 , css::script::provider::XScriptProviderSupplier
151 , css::document::XEventsSupplier
152 , css::frame::XLoadable
153 , css::document::XDocumentRecovery
154 , css::frame::XTitle
155 , css::frame::XTitleChangeBroadcaster
156 , css::frame::XUntitledNumbers
157 > ODatabaseDocument_OfficeDocument;
159 class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first!
160 ,public ODatabaseDocument_OfficeDocument
162 enum InitState
164 NotInitialized,
165 Initializing,
166 Initialized
169 typedef std::map< OUString, css::uno::Reference< css::frame::XUntitledNumbers > > TNumberedController;
170 css::uno::Reference< css::ui::XUIConfigurationManager2> m_xUIConfigurationManager;
172 ::comphelper::OInterfaceContainerHelper3<css::util::XModifyListener> m_aModifyListeners;
173 ::comphelper::OInterfaceContainerHelper3<css::util::XCloseListener> m_aCloseListener;
174 ::comphelper::OInterfaceContainerHelper3<css::document::XStorageChangeListener> m_aStorageListeners;
176 std::unique_ptr<DocumentEvents> m_pEventContainer;
177 ::rtl::Reference< DocumentEventExecutor > m_pEventExecutor;
178 DocumentEventNotifier m_aEventNotifier;
180 css::uno::Reference< css::frame::XController > m_xCurrentController;
181 Controllers m_aControllers;
182 ViewMonitor m_aViewMonitor;
184 css::uno::WeakReference< css::container::XNameAccess > m_xForms;
185 css::uno::WeakReference< css::container::XNameAccess > m_xReports;
186 css::uno::WeakReference< css::script::provider::XScriptProvider > m_xScriptProvider;
188 /** @short such module manager is used to classify new opened documents. */
189 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
190 rtl::Reference< ::framework::TitleHelper > m_xTitleHelper;
191 TNumberedController m_aNumberedControllers;
193 /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
194 the document has be initialized implicitly - see storeAsURL
196 InitState m_eInitState;
197 bool m_bClosing;
198 /// Using atomic because locking around accessing this will lead to deadlock in queryInterface
199 std::atomic<bool> m_bAllowDocumentScripting;
200 bool m_bHasBeenRecovered;
201 /// If XModel::attachResource() was called to inform us that the document is embedded into another one.
202 bool m_bEmbedded;
204 enum StoreType { SAVE, SAVE_AS };
205 /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
206 the modified flag, and notifies any listeners as required
208 @param _rURL
209 the URL to store the document to
210 @param _rArguments
211 arguments for storing the document (MediaDescriptor)
212 @param _eType
213 the type of the store process (Save or SaveAs). The method will automatically
214 notify the proper events for this type.
215 @param _rGuard
216 the instance lock to be released before doing synchronous notifications
217 @throws css::io::IOException
218 @throws css::uno::RuntimeException
220 void impl_storeAs_throw(
221 const OUString& _rURL,
222 const ::comphelper::NamedValueCollection& _rArguments,
223 const StoreType _eType,
224 DocumentGuard& _rGuard
227 /** notifies our storage change listeners that our underlying storage changed
229 @param _rxNewRootStorage
230 the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
231 happened, and the listeners are not notified.
233 void impl_notifyStorageChange_nolck_nothrow(
234 const css::uno::Reference< css::embed::XStorage >& _rxNewRootStorage
237 /// write a single XML stream into the package
238 void WriteThroughComponent(
239 const css::uno::Reference< css::lang::XComponent > & xComponent, /// the component we export
240 const OUString& rStreamName, /// the stream name
241 const OUString& rServiceName, /// service name of the component
242 const css::uno::Sequence< css::uno::Any> & rArguments, /// the argument (XInitialization)
243 const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc,/// output descriptor
244 const css::uno::Reference< css::embed::XStorage >& _xStorageToSaveTo
245 ) const;
247 /// write a single output stream
248 /// (to be called either directly or by WriteThroughComponent(...))
249 void WriteThroughComponent(
250 const css::uno::Reference< css::io::XOutputStream >& xOutputStream,
251 const css::uno::Reference< css::lang::XComponent >& xComponent,
252 const OUString& rServiceName,
253 const css::uno::Sequence< css::uno::Any >& rArguments,
254 const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc
255 ) const;
257 /** writes the content and settings
258 @param sURL
259 The URL
260 @param lArguments
261 The media descriptor
262 @param _xStorageToSaveTo
263 The storage which should be used for saving
265 void impl_writeStorage_throw(
266 const css::uno::Reference< css::embed::XStorage >& _rxTargetStorage,
267 const ::comphelper::NamedValueCollection& _rMediaDescriptor
268 ) const;
270 // ModelDependentComponent overridables
271 virtual css::uno::Reference< css::uno::XInterface > getThis() const override;
273 rtl::Reference< ::framework::TitleHelper> const & impl_getTitleHelper_throw();
274 css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
275 const css::uno::Reference< css::uno::XInterface >& _xComponent = css::uno::Reference< css::uno::XInterface >());
277 private:
278 explicit ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
279 // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
280 // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
281 // If you create a ODatabaseDocument directly, you might easily create a leak.
282 // #i50905#
284 protected:
285 virtual void SAL_CALL disposing() override;
287 virtual ~ODatabaseDocument() override;
289 public:
290 struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
291 static rtl::Reference<ODatabaseDocument> createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
293 return new ODatabaseDocument( _pImpl );
296 // XServiceInfo
297 virtual OUString SAL_CALL getImplementationName( ) override;
298 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
299 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
301 // XInterface
302 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
304 // XTypeProvider
305 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
306 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
308 // XComponent
309 virtual void SAL_CALL dispose( ) override;
310 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
311 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
313 // XModel
314 virtual sal_Bool SAL_CALL attachResource( const OUString& URL, const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override ;
315 virtual OUString SAL_CALL getURL( ) override ;
316 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs( ) override ;
317 virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& Controller ) override ;
318 virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& Controller ) override ;
319 virtual void SAL_CALL lockControllers( ) override ;
320 virtual void SAL_CALL unlockControllers( ) override ;
321 virtual sal_Bool SAL_CALL hasControllersLocked( ) override ;
322 virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController( ) override ;
323 virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& Controller ) override ;
324 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection( ) override ;
326 // XModel2
327 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL getControllers( ) override ;
328 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) override ;
329 virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createDefaultViewController( const css::uno::Reference< css::frame::XFrame >& Frame ) override ;
330 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 ) override ;
331 virtual void SAL_CALL setArgs(const css::uno::Sequence<css::beans::PropertyValue>& aArgs) override;
333 // XModel3
334 virtual ::css::uno::Sequence< ::css::beans::PropertyValue > SAL_CALL getArgs2( const ::css::uno::Sequence< ::rtl::OUString >& requestedArgs ) override;
336 // XStorable
337 virtual sal_Bool SAL_CALL hasLocation( ) override ;
338 virtual OUString SAL_CALL getLocation( ) override ;
339 virtual sal_Bool SAL_CALL isReadonly( ) override ;
340 virtual void SAL_CALL store( ) override ;
341 virtual void SAL_CALL storeAsURL( const OUString& sURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override ;
342 virtual void SAL_CALL storeToURL( const OUString& sURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override ;
344 // XModifyBroadcaster
345 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
346 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
348 // css::util::XModifiable
349 virtual sal_Bool SAL_CALL isModified( ) override ;
350 virtual void SAL_CALL setModified( sal_Bool bModified ) override ;
352 // XEventBroadcaster
353 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::document::XEventListener >& aListener ) override;
354 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& aListener ) override;
356 // XDocumentEventBroadcaster
357 virtual void SAL_CALL addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& Listener ) override;
358 virtual void SAL_CALL removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& Listener ) override;
359 virtual void SAL_CALL notifyDocumentEvent( const OUString& EventName, const css::uno::Reference< css::frame::XController2 >& ViewController, const css::uno::Any& Supplement ) override;
361 // XPrintable
362 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPrinter( ) override ;
363 virtual void SAL_CALL setPrinter( const css::uno::Sequence< css::beans::PropertyValue >& aPrinter ) override ;
364 virtual void SAL_CALL print( const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override ;
366 // XFormDocumentsSupplier
367 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getFormDocuments( ) override;
369 // XReportDocumentsSupplier
370 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReportDocuments( ) override;
372 // XCloseable
373 virtual void SAL_CALL close( sal_Bool DeliverOwnership ) override;
374 virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
375 virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
377 // XUIConfigurationManagerSupplier
378 virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) override;
380 // XDocumentSubStorageSupplier
381 virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) override;
382 virtual css::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) override;
384 // XOfficeDatabaseDocument
385 virtual css::uno::Reference< css::sdbc::XDataSource > SAL_CALL getDataSource() override;
387 // XStorageBasedDocument
388 virtual void SAL_CALL loadFromStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) override;
389 virtual void SAL_CALL storeToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescriptor ) override;
390 virtual void SAL_CALL switchToStorage( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
391 virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentStorage( ) override;
392 virtual void SAL_CALL addStorageChangeListener( const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) override;
393 virtual void SAL_CALL removeStorageChangeListener( const css::uno::Reference< css::document::XStorageChangeListener >& xListener ) override;
395 // XEmbeddedScripts
396 virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() override;
397 virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() override;
398 virtual sal_Bool SAL_CALL getAllowMacroExecution() override;
400 // XScriptInvocationContext
401 virtual css::uno::Reference< css::document::XEmbeddedScripts > SAL_CALL getScriptContainer() override;
403 // XScriptProviderSupplier
404 virtual css::uno::Reference< css::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) override;
406 // XEventsSupplier
407 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
409 // XLoadable
410 virtual void SAL_CALL initNew( ) override;
411 virtual void SAL_CALL load( const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
413 // css.document.XDocumentRecovery
414 virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() override;
415 virtual void SAL_CALL storeToRecoveryFile( const OUString& i_TargetLocation, const css::uno::Sequence< css::beans::PropertyValue >& i_MediaDescriptor ) override;
416 virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const css::uno::Sequence< css::beans::PropertyValue >& i_MediaDescriptor ) override;
418 // XTitle
419 virtual OUString SAL_CALL getTitle( ) override;
420 virtual void SAL_CALL setTitle( const OUString& sTitle ) override;
422 // XTitleChangeBroadcaster
423 virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override;
424 virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) override;
426 // XUntitledNumbers
427 virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
428 virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) override;
429 virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) override;
430 virtual OUString SAL_CALL getUntitledPrefix( ) override;
432 /** clears the given object container
434 Clearing is done via disposal - the method calls XComponent::dispose at the given object,
435 which must be one of our impl's or our object containers (m_xForms, m_xReports,
436 m_xTableDefinitions, m_xCommandDefinitions)
438 @param _rxContainer
439 the container to clear
441 static void clearObjectContainer(
442 css::uno::WeakReference< css::container::XNameAccess >& _rxContainer);
443 static void clearObjectContainer(
444 unotools::WeakReference< OCommandContainer >& _rxContainer);
446 /** checks whether the component is already initialized, throws a NotInitializedException if not
448 void checkInitialized() const
450 if ( !impl_isInitialized() )
451 throw css::lang::NotInitializedException( OUString(), getThis() );
454 /** checks the document is currently in the initialization phase, or already initialized.
455 Throws NotInitializedException if not so.
457 void checkNotUninitialized() const
459 if ( impl_isInitialized() || impl_isInitializing() )
460 // fine
461 return;
463 throw css::lang::NotInitializedException( OUString(), getThis() );
466 /** checks whether the document is currently being initialized, or already initialized,
467 throws a DoubleInitializationException if so
469 void checkNotInitialized() const
471 if ( impl_isInitializing() || impl_isInitialized() )
472 throw css::frame::DoubleInitializationException( OUString(), getThis() );
475 private:
476 /// @throws css::uno::RuntimeException
477 css::uno::Reference< css::ui::XUIConfigurationManager2 > const & getUIConfigurationManager2();
479 /** returns whether the model is currently being initialized
481 bool impl_isInitializing() const { return m_eInitState == Initializing; }
483 /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
485 bool impl_isInitialized() const { return m_eInitState == Initialized; }
487 /// tells the model it is being initialized now
488 void impl_setInitializing() { m_eInitState = Initializing; }
490 /// tells the model its initialization is done
491 void impl_setInitialized();
493 /** closes the frames of all connected controllers
495 @param _bDeliverOwnership
496 determines if the ownership should be transferred to the component which
497 possibly vetos the closing
499 @throws css::util::CloseVetoException
500 if the closing was vetoed by any instance
502 void impl_closeControllerFrames_nolck_throw( bool _bDeliverOwnership );
504 /** disposes the frames of all controllers which are still left in m_aControllers.
506 void impl_disposeControllerFrames_nothrow();
508 /** does a reparenting at the given object container to ourself
510 Calls XChild::setParent at the given object, which must be one of our impl's or our
511 object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
513 void impl_reparent_nothrow( const css::uno::WeakReference< css::container::XNameAccess >& _rxContainer );
515 /** retrieves the forms or reports contained, creates and initializes it, if necessary
517 @throws DisposedException
518 if the instance is already disposed
519 @throws IllegalArgumentException
520 if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
522 css::uno::Reference< css::container::XNameAccess >
523 impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
525 /** resets everything
527 @precond
528 m_pImpl is not <NULL/>
530 void
531 impl_reset_nothrow();
533 /** imports the document from the given resource.
535 static void
536 impl_import_nolck_throw(
537 const css::uno::Reference< css::uno::XComponentContext >& _rContext,
538 const css::uno::Reference< css::uno::XInterface >& _rxTargetComponent,
539 const ::comphelper::NamedValueCollection& _rResource
542 /** creates a storage for the given URL, truncating it if a file with this name already exists
544 @throws Exception
545 if creating the storage failed
547 @return
548 the newly created storage for the file at the given URL
550 css::uno::Reference< css::embed::XStorage >
551 impl_createStorageFor_throw(
552 const OUString& _rURL
553 ) const;
555 /** Extracts storage from arguments, or creates for the given URL, truncating it if a file with
556 this name already exists
558 @throws Exception
559 if creating the storage failed
561 @return
562 the storage that is either extracted from arguments, or newly created for the file at
563 the given URL
565 css::uno::Reference<css::embed::XStorage> impl_GetStorageOrCreateFor_throw(
566 const ::comphelper::NamedValueCollection& _rArguments, const OUString& _rURL) const;
568 /** sets our "modified" flag
570 will notify all our respective listeners, if the "modified" state actually changed
572 @param _bModified
573 the (new) flag indicating whether the document is currently modified or not
574 @param _rGuard
575 the guard for our instance. At method entry, the guard must hold the lock. At the moment
576 of method leave, the lock will be released.
577 @precond
578 our mutex is locked
579 @postcond
580 our mutex is not locked
582 void impl_setModified_nothrow( bool _bModified, DocumentGuard& _rGuard );
584 /** stores the document to the given storage
586 Note that the document is actually not rebased to this storage, it just stores a copy of itself
587 to the given target storage.
589 @param _rxTargetStorage
590 denotes the storage to store the document into
591 @param _rMediaDescriptor
592 contains additional parameters for storing the document
593 @param _rDocGuard
594 a guard which holds the (only) lock to the document, and which will be temporarily
595 released where necessary (e.g. for notifications, or calling into other components)
597 @throws css::uno::IllegalArgumentException
598 if the given storage is <NULL/>.
600 @throws css::uno::RuntimeException
601 when any of the used operations throws it
603 @throws css::io::IOException
604 when any of the used operations throws it, or any other exception occurs which is no
605 RuntimeException and no IOException
607 void impl_storeToStorage_throw(
608 const css::uno::Reference< css::embed::XStorage >& _rxTargetStorage,
609 const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor,
610 DocumentGuard& _rDocGuard
611 ) const;
613 /** impl-version of attachResource
615 @param i_rLogicalDocumentURL
616 denotes the logical URL of the document, to be reported by getURL/getLocation
617 @param i_rMediaDescriptor
618 denotes additional document parameters
619 @param _rDocGuard
620 is the guard which currently protects the document instance
622 bool impl_attachResource(
623 const OUString& i_rLogicalDocumentURL,
624 const css::uno::Sequence< css::beans::PropertyValue >& i_rMediaDescriptor,
625 DocumentGuard& _rDocGuard
628 /** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
629 the given caught non-IOException error
631 void impl_throwIOExceptionCausedBySave_throw(
632 const css::uno::Any& i_rError,
633 std::u16string_view i_rTargetURL
634 ) const;
637 /** an extended version of the ModelMethodGuard, which also cares for the initialization state
638 of the document
640 class DocumentGuard : private ModelMethodGuard
642 public:
643 enum InitMethod_
645 // a method which is to initialize the document
646 InitMethod,
649 enum DefaultMethod_
651 // a default method
652 DefaultMethod
655 enum MethodUsedDuringInit_
657 // a method which is used (externally) during the initialization phase
658 MethodUsedDuringInit
661 enum MethodWithoutInit_
663 // a method which does not need initialization - use with care!
664 MethodWithoutInit
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::lang::NotInitializedException
677 if the given component is not yet initialized
679 DocumentGuard(const ODatabaseDocument& _document, DefaultMethod_)
680 : ModelMethodGuard(_document)
681 , m_document(_document )
683 m_document.checkInitialized();
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::frame::DoubleInitializationException
695 if the given component is already initialized, or currently being initialized.
697 DocumentGuard(const ODatabaseDocument& _document, InitMethod_)
698 : ModelMethodGuard(_document)
699 , m_document(_document)
701 m_document.checkNotInitialized();
704 /** constructs the guard
706 @param _document
707 the ODatabaseDocument instance
709 @throws css::lang::DisposedException
710 If the given component is already disposed
712 @throws css::lang::NotInitializedException
713 if the component is still uninitialized, and not in the initialization
714 phase currently.
716 DocumentGuard(const ODatabaseDocument& _document, MethodUsedDuringInit_)
717 : ModelMethodGuard(_document)
718 , m_document(_document)
720 m_document.checkNotUninitialized();
723 /** constructs the guard
725 @param _document
726 the ODatabaseDocument instance
728 @throws css::lang::DisposedException
729 If the given component is already disposed
731 DocumentGuard(const ODatabaseDocument& _document, MethodWithoutInit_)
732 : ModelMethodGuard( _document )
733 , m_document( _document )
737 void clear()
739 ModelMethodGuard::clear();
741 void reset()
743 ModelMethodGuard::reset();
744 m_document.checkDisposed();
747 private:
749 const ODatabaseDocument& m_document;
752 } // namespace dbaccess
754 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */