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 INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
21 :
22 : #include <sal/config.h>
23 :
24 : #include <map>
25 :
26 : #include "ModelImpl.hxx"
27 : #include "documenteventnotifier.hxx"
28 :
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>
57 :
58 : #ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
59 : #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
60 : #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 17
61 : #include <comphelper/implbase_var.hxx>
62 : #endif
63 :
64 : #include <cppuhelper/compbase10.hxx>
65 : #include <cppuhelper/implbase3.hxx>
66 : #include <rtl/ref.hxx>
67 :
68 : #include <boost/shared_ptr.hpp>
69 : #include <boost/noncopyable.hpp>
70 :
71 : namespace comphelper {
72 : class NamedValueCollection;
73 : }
74 :
75 : namespace dbaccess
76 : {
77 :
78 : class DocumentEvents;
79 : class DocumentEventExecutor;
80 : class DocumentGuard;
81 :
82 : typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers;
83 :
84 : // ViewMonitor
85 : /** helper class monitoring the views of a document, and firing appropriate events
86 : when views are attached / detached
87 : */
88 0 : class ViewMonitor : public boost::noncopyable
89 : {
90 : public:
91 0 : ViewMonitor( DocumentEventNotifier& _rEventNotifier )
92 : :m_rEventNotifier( _rEventNotifier )
93 : ,m_bIsNewDocument( true )
94 : ,m_bEverHadController( false )
95 : ,m_bLastIsFirstEverController( false )
96 0 : ,m_xLastConnectedController()
97 : {
98 0 : }
99 :
100 0 : void reset()
101 : {
102 0 : m_bEverHadController = false;
103 0 : m_bLastIsFirstEverController = false;
104 0 : m_xLastConnectedController.clear();
105 0 : }
106 :
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
110 : */
111 : bool onControllerConnected(
112 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
113 : );
114 :
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.
120 : */
121 : bool onSetCurrentController(
122 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
123 : );
124 :
125 0 : void onLoadedDocument() { m_bIsNewDocument = false; }
126 :
127 : private:
128 : DocumentEventNotifier& m_rEventNotifier;
129 : bool m_bIsNewDocument;
130 : bool m_bEverHadController;
131 : bool m_bLastIsFirstEverController;
132 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
133 : m_xLastConnectedController;
134 : };
135 :
136 : // ODatabaseDocument
137 : typedef ::comphelper::PartialWeakComponentImplHelper17 < ::com::sun::star::frame::XModel2
138 : , ::com::sun::star::util::XModifiable
139 : , ::com::sun::star::frame::XStorable
140 : , ::com::sun::star::document::XEventBroadcaster
141 : , ::com::sun::star::document::XDocumentEventBroadcaster
142 : , ::com::sun::star::view::XPrintable
143 : , ::com::sun::star::util::XCloseable
144 : , ::com::sun::star::lang::XServiceInfo
145 : , ::com::sun::star::sdb::XOfficeDatabaseDocument
146 : , ::com::sun::star::ui::XUIConfigurationManagerSupplier
147 : , ::com::sun::star::document::XStorageBasedDocument
148 : , ::com::sun::star::document::XEmbeddedScripts
149 : , ::com::sun::star::document::XScriptInvocationContext
150 : , ::com::sun::star::script::provider::XScriptProviderSupplier
151 : , ::com::sun::star::document::XEventsSupplier
152 : , ::com::sun::star::frame::XLoadable
153 : , ::com::sun::star::document::XDocumentRecovery
154 : > ODatabaseDocument_OfficeDocument;
155 :
156 : typedef ::cppu::ImplHelper3< ::com::sun::star::frame::XTitle
157 : , ::com::sun::star::frame::XTitleChangeBroadcaster
158 : , ::com::sun::star::frame::XUntitledNumbers
159 : > ODatabaseDocument_Title;
160 :
161 : class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first!
162 : ,public ODatabaseDocument_OfficeDocument
163 : ,public ODatabaseDocument_Title
164 : {
165 : enum InitState
166 : {
167 : NotInitialized,
168 : Initializing,
169 : Initialized
170 : };
171 :
172 : typedef std::map< OUString, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > > TNumberedController;
173 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2> m_xUIConfigurationManager;
174 :
175 : ::cppu::OInterfaceContainerHelper m_aModifyListeners;
176 : ::cppu::OInterfaceContainerHelper m_aCloseListener;
177 : ::cppu::OInterfaceContainerHelper m_aStorageListeners;
178 :
179 : DocumentEvents* m_pEventContainer;
180 : ::rtl::Reference< DocumentEventExecutor > m_pEventExecutor;
181 : DocumentEventNotifier m_aEventNotifier;
182 :
183 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xCurrentController;
184 : Controllers m_aControllers;
185 : ViewMonitor m_aViewMonitor;
186 :
187 : ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xForms;
188 : ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xReports;
189 : ::com::sun::star::uno::WeakReference< ::com::sun::star::script::provider::XScriptProvider > m_xScriptProvider;
190 :
191 : /** @short such module manager is used to classify new opened documents. */
192 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
193 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > m_xTitleHelper;
194 : TNumberedController m_aNumberedControllers;
195 :
196 : /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
197 : the document has be initialized implicitly - see storeAsURL
198 : */
199 : InitState m_eInitState;
200 : bool m_bClosing;
201 : bool m_bAllowDocumentScripting;
202 : bool m_bHasBeenRecovered;
203 :
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
207 :
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 : */
218 : void impl_storeAs_throw(
219 : const OUString& _rURL,
220 : const ::comphelper::NamedValueCollection& _rArguments,
221 : const StoreType _eType,
222 : DocumentGuard& _rGuard
223 : )
224 : throw ( ::com::sun::star::io::IOException
225 : , ::com::sun::star::uno::RuntimeException );
226 :
227 : /** notifies our storage change listeners that our underlying storage changed
228 :
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.
232 : */
233 : void impl_notifyStorageChange_nolck_nothrow(
234 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
235 : );
236 :
237 : /// write a single XML stream into the package
238 : void WriteThroughComponent(
239 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > & xComponent, /// the component we export
240 : const sal_Char* pStreamName, /// the stream name
241 : const sal_Char* pServiceName, /// service name of the component
242 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> & rArguments, /// the argument (XInitialization)
243 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc,/// output descriptor
244 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _xStorageToSaveTo
245 : ) const;
246 :
247 : /// write a single output stream
248 : /// (to be called either directly or by WriteThroughComponent(...))
249 : void WriteThroughComponent(
250 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
251 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
252 : const sal_Char* pServiceName,
253 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
254 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
255 : ) const;
256 :
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
264 : */
265 : void impl_writeStorage_throw(
266 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
267 : const ::comphelper::NamedValueCollection& _rMediaDescriptor
268 : ) const;
269 :
270 : // ModelDependentComponent overridables
271 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const SAL_OVERRIDE;
272 :
273 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper_throw();
274 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
275 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
276 :
277 : private:
278 : 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#
283 :
284 : protected:
285 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
286 :
287 : virtual ~ODatabaseDocument();
288 :
289 : public:
290 0 : struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
291 0 : static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
292 : {
293 0 : return new ODatabaseDocument( _pImpl );
294 : }
295 :
296 : // XServiceInfo
297 : virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
298 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
299 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
300 :
301 : // ::com::sun::star::lang::XServiceInfo - static methods
302 : static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
303 : static OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
304 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
305 : SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
306 :
307 : // XInterface
308 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
309 : virtual void SAL_CALL acquire( ) throw () SAL_OVERRIDE;
310 : virtual void SAL_CALL release( ) throw () SAL_OVERRIDE;
311 :
312 : // XTypeProvider
313 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
314 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
315 :
316 : // XEventListener
317 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
318 :
319 : // XComponent
320 : virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
321 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
322 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
323 :
324 : // XModel
325 : virtual sal_Bool SAL_CALL attachResource( const OUString& URL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
326 : virtual OUString SAL_CALL getURL( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
327 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
328 : virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
329 : virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
330 : virtual void SAL_CALL lockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
331 : virtual void SAL_CALL unlockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
332 : virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
333 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
334 : virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
335 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
336 :
337 : // XModel2
338 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL getControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
339 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
340 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createDefaultViewController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
341 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createViewController( const OUString& ViewName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
342 :
343 : // XStorable
344 : virtual sal_Bool SAL_CALL hasLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
345 : virtual OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
346 : virtual sal_Bool SAL_CALL isReadonly( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
347 : virtual void SAL_CALL store( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
348 : virtual void SAL_CALL storeAsURL( const OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
349 : virtual void SAL_CALL storeToURL( const OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
350 :
351 : // XModifyBroadcaster
352 : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
353 : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
354 :
355 : // ::com::sun::star::util::XModifiable
356 : virtual sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
357 : virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
358 :
359 : // XEventBroadcaster
360 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
361 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
362 :
363 : // XDocumentEventBroadcaster
364 : virtual void SAL_CALL addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
365 : virtual void SAL_CALL removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
366 : virtual void SAL_CALL notifyDocumentEvent( const OUString& _EventName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController, const ::com::sun::star::uno::Any& _Supplement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
367 :
368 : // XPrintable
369 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
370 : virtual void SAL_CALL setPrinter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aPrinter ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
371 : virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
372 :
373 : // XFormDocumentsSupplier
374 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
375 :
376 : // XReportDocumentsSupplier
377 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
378 :
379 : // XCloseable
380 : virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
381 : virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 : virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
383 :
384 : // XUIConfigurationManagerSupplier
385 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
386 :
387 : // XDocumentSubStorageSupplier
388 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
389 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
390 :
391 : // XOfficeDatabaseDocument
392 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
393 :
394 : // XStorageBasedDocument
395 : virtual void SAL_CALL loadFromStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
396 : virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
397 : virtual void SAL_CALL switchToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
398 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentStorage( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
399 : virtual void SAL_CALL addStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
400 : virtual void SAL_CALL removeStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
401 :
402 : // XEmbeddedScripts
403 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
404 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
405 : virtual sal_Bool SAL_CALL getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
406 :
407 : // XScriptInvocationContext
408 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
409 :
410 : // XScriptProviderSupplier
411 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
412 :
413 : // XEventsSupplier
414 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
415 :
416 : // XLoadable
417 : virtual void SAL_CALL initNew( ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
418 : virtual void SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
419 :
420 : // css.document.XDocumentRecovery
421 : virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
422 : virtual void SAL_CALL storeToRecoveryFile( const OUString& i_TargetLocation, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE;
423 : virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE;
424 :
425 : // XTitle
426 : virtual OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
427 : virtual void SAL_CALL setTitle( const OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
428 :
429 : // XTitleChangeBroadcaster
430 : virtual void SAL_CALL addTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
431 : virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
432 :
433 : // XUntitledNumbers
434 : virtual ::sal_Int32 SAL_CALL leaseNumber( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
435 : virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
436 : virtual void SAL_CALL releaseNumberForComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
437 : virtual OUString SAL_CALL getUntitledPrefix( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
438 :
439 : /** clears the given object container
440 :
441 : Clearing is done via disposal - the method calls XComponent::dispose at the given object,
442 : which must be one of our impl's or our object containers (m_xForms, m_xReports,
443 : m_xTableDefinitions, m_xCommandDefinitions)
444 :
445 : @param _rxContainer
446 : the container to clear
447 : */
448 : static void clearObjectContainer(
449 : ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer);
450 :
451 : /** checks whether the component is already initialized, throws a NotInitializedException if not
452 : */
453 0 : inline void checkInitialized() const
454 : {
455 0 : if ( !impl_isInitialized() )
456 0 : throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
457 0 : }
458 :
459 : /** checks the document is currently in the initialization phase, or already initialized.
460 : Throws NotInitializedException if not so.
461 : */
462 0 : inline void checkNotUninitilized() const
463 : {
464 0 : if ( impl_isInitialized() || impl_isInitializing() )
465 : // fine
466 0 : return;
467 :
468 0 : throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
469 : }
470 :
471 : /** checks whether the document is currently being initialized, or already initialized,
472 : throws a DoubleInitializationException if so
473 : */
474 0 : inline void checkNotInitialized() const
475 : {
476 0 : if ( impl_isInitializing() || impl_isInitialized() )
477 0 : throw ::com::sun::star::frame::DoubleInitializationException( OUString(), getThis() );
478 0 : }
479 :
480 : private:
481 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2 > getUIConfigurationManager2() throw (::com::sun::star::uno::RuntimeException);
482 :
483 : /** returns whether the model is currently being initialized
484 : */
485 0 : 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 0 : bool impl_isInitialized() const { return m_eInitState == Initialized; }
490 :
491 : /// tells the model it is being initialized now
492 0 : 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 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rContext,
542 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
543 : const ::comphelper::NamedValueCollection& _rResource
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 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 : /** impl-version of attachResource
605 :
606 : @param i_rLogicalDocumentURL
607 : denotes the logical URL of the document, to be reported by getURL/getLocation
608 : @param i_rMediaDescriptor
609 : denotes additional document parameters
610 : @param _rDocGuard
611 : is the guard which currently protects the document instance
612 : */
613 : sal_Bool impl_attachResource(
614 : const OUString& i_rLogicalDocumentURL,
615 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rMediaDescriptor,
616 : DocumentGuard& _rDocGuard
617 : );
618 :
619 : /** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
620 : the given caught non-IOException error
621 : */
622 : void impl_throwIOExceptionCausedBySave_throw(
623 : const ::com::sun::star::uno::Any& i_rError,
624 : const OUString& i_rTargetURL
625 : ) const;
626 : };
627 :
628 : /** an extended version of the ModelMethodGuard, which also cares for the initialization state
629 : of the document
630 : */
631 : class DocumentGuard : private ModelMethodGuard
632 : {
633 : public:
634 : enum MethodType
635 : {
636 : // a method which is to initialize the document
637 : InitMethod,
638 : // a default method
639 : DefaultMethod,
640 : // a method which is used (externally) during the initialization phase
641 : MethodUsedDuringInit,
642 : // a method which does not need initialization - use with care!
643 : MethodWithoutInit
644 : };
645 :
646 : /** constructs the guard
647 :
648 : @param _document
649 : the ODatabaseDocument instance
650 :
651 : @throws ::com::sun::star::lang::DisposedException
652 : If the given component is already disposed
653 :
654 : @throws ::com::sun::star::frame::DoubleInitializationException
655 : if _eType is InitMethod, and the given component is already initialized, or currently being initialized.
656 :
657 : @throws ::com::sun::star::lang::NotInitializedException
658 : if _eType is DefaultMethod, and the given component is not yet initialized; or if _eType
659 : is MethodUsedDuringInit, and the component is still uninitialized, and not in the initialization
660 : phase currently.
661 : */
662 0 : DocumentGuard( const ODatabaseDocument& _document, MethodType _eType = DefaultMethod )
663 : :ModelMethodGuard( _document )
664 0 : ,m_document( _document )
665 : {
666 0 : switch ( _eType )
667 : {
668 0 : case InitMethod: m_document.checkNotInitialized(); break;
669 0 : case DefaultMethod: m_document.checkInitialized(); break;
670 0 : case MethodUsedDuringInit: m_document.checkNotUninitilized(); break;
671 0 : case MethodWithoutInit: break;
672 : }
673 0 : }
674 :
675 0 : ~DocumentGuard()
676 0 : {
677 0 : }
678 :
679 0 : void clear()
680 : {
681 0 : ModelMethodGuard::clear();
682 0 : }
683 0 : void reset()
684 : {
685 0 : ModelMethodGuard::reset();
686 0 : m_document.checkDisposed();
687 0 : }
688 :
689 : private:
690 :
691 : const ODatabaseDocument& m_document;
692 : };
693 :
694 : } // namespace dbaccess
695 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
696 :
697 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|