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