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 196 : class ViewMonitor : public boost::noncopyable
89 : {
90 : public:
91 210 : ViewMonitor( DocumentEventNotifier& _rEventNotifier )
92 : :m_rEventNotifier( _rEventNotifier )
93 : ,m_bIsNewDocument( true )
94 : ,m_bEverHadController( false )
95 : ,m_bLastIsFirstEverController( false )
96 210 : ,m_xLastConnectedController()
97 : {
98 210 : }
99 :
100 210 : void reset()
101 : {
102 210 : m_bEverHadController = false;
103 210 : m_bLastIsFirstEverController = false;
104 210 : m_xLastConnectedController.clear();
105 210 : }
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 34 : 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 (css::io::IOException,
225 : css::uno::RuntimeException,
226 : std::exception);
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 : /// write a single output stream
249 : /// (to be called either directly or by WriteThroughComponent(...))
250 : void WriteThroughComponent(
251 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
252 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
253 : const sal_Char* pServiceName,
254 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
255 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
256 : ) const;
257 :
258 : /** writes the content and settings
259 : @param sURL
260 : The URL
261 : @param lArguments
262 : The media descriptor
263 : @param _xStorageToSaveTo
264 : The storage which should be used for saving
265 : */
266 : void impl_writeStorage_throw(
267 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
268 : const ::comphelper::NamedValueCollection& _rMediaDescriptor
269 : ) const;
270 :
271 : // ModelDependentComponent overridables
272 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const SAL_OVERRIDE;
273 :
274 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper_throw();
275 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
276 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
277 :
278 : private:
279 : ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
280 : // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
281 : // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
282 : // If you create a ODatabaseDocument directly, you might easily create a leak.
283 : // #i50905#
284 :
285 : protected:
286 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
287 :
288 : virtual ~ODatabaseDocument();
289 :
290 : public:
291 210 : struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
292 210 : static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
293 : {
294 210 : return new ODatabaseDocument( _pImpl );
295 : }
296 :
297 : // XServiceInfo
298 : virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
299 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
300 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 :
302 : // ::com::sun::star::lang::XServiceInfo - static methods
303 : static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
304 : static OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
305 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
306 : SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
307 :
308 : // XInterface
309 : 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;
310 : virtual void SAL_CALL acquire( ) throw () SAL_OVERRIDE;
311 : virtual void SAL_CALL release( ) throw () SAL_OVERRIDE;
312 :
313 : // XTypeProvider
314 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
315 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
316 :
317 : // XEventListener
318 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
319 :
320 : // XComponent
321 : virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
322 : 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;
323 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
324 :
325 : // XModel
326 : 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 ;
327 : virtual OUString SAL_CALL getURL( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
328 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
329 : 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 ;
330 : 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 ;
331 : virtual void SAL_CALL lockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
332 : virtual void SAL_CALL unlockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
333 : virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
334 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
335 : 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 ;
336 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
337 :
338 : // XModel2
339 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL getControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
340 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
341 : 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 ;
342 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createViewController( const OUString& ViewName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
343 :
344 : // XStorable
345 : virtual sal_Bool SAL_CALL hasLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
346 : virtual OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
347 : virtual sal_Bool SAL_CALL isReadonly( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
348 : virtual void SAL_CALL store( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
349 : 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 ;
350 : virtual void SAL_CALL storeToURL( const OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
351 :
352 : // XModifyBroadcaster
353 : 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;
354 : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
355 :
356 : // ::com::sun::star::util::XModifiable
357 : virtual sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
358 : virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
359 :
360 : // XEventBroadcaster
361 : 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;
362 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
363 :
364 : // XDocumentEventBroadcaster
365 : 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;
366 : 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;
367 : virtual void SAL_CALL notifyDocumentEvent( const OUString& _EventName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController, const ::com::sun::star::uno::Any& _Supplement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
368 :
369 : // XPrintable
370 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
371 : 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 ;
372 : virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
373 :
374 : // XFormDocumentsSupplier
375 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
376 :
377 : // XReportDocumentsSupplier
378 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
379 :
380 : // XCloseable
381 : virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 : 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;
383 : virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
384 :
385 : // XUIConfigurationManagerSupplier
386 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
387 :
388 : // XDocumentSubStorageSupplier
389 : 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;
390 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
391 :
392 : // XOfficeDatabaseDocument
393 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
394 :
395 : // XStorageBasedDocument
396 : 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;
397 : 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;
398 : 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;
399 : 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;
400 : 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;
401 : virtual void SAL_CALL removeStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
402 :
403 : // XEmbeddedScripts
404 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
405 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
406 : virtual sal_Bool SAL_CALL getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
407 :
408 : // XScriptInvocationContext
409 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
410 :
411 : // XScriptProviderSupplier
412 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
413 :
414 : // XEventsSupplier
415 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
416 :
417 : // XLoadable
418 : 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;
419 : virtual void SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
420 :
421 : // css.document.XDocumentRecovery
422 : virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
423 : 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;
424 : virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE;
425 :
426 : // XTitle
427 : virtual OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
428 : virtual void SAL_CALL setTitle( const OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
429 :
430 : // XTitleChangeBroadcaster
431 : 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;
432 : virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
433 :
434 : // XUntitledNumbers
435 : 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;
436 : virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
437 : 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;
438 : virtual OUString SAL_CALL getUntitledPrefix( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
439 :
440 : /** clears the given object container
441 :
442 : Clearing is done via disposal - the method calls XComponent::dispose at the given object,
443 : which must be one of our impl's or our object containers (m_xForms, m_xReports,
444 : m_xTableDefinitions, m_xCommandDefinitions)
445 :
446 : @param _rxContainer
447 : the container to clear
448 : */
449 : static void clearObjectContainer(
450 : ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer);
451 :
452 : /** checks whether the component is already initialized, throws a NotInitializedException if not
453 : */
454 928 : inline void checkInitialized() const
455 : {
456 928 : if ( !impl_isInitialized() )
457 170 : throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
458 758 : }
459 :
460 : /** checks the document is currently in the initialization phase, or already initialized.
461 : Throws NotInitializedException if not so.
462 : */
463 1724 : inline void checkNotUninitilized() const
464 : {
465 1724 : if ( impl_isInitialized() || impl_isInitializing() )
466 : // fine
467 3448 : return;
468 :
469 0 : throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
470 : }
471 :
472 : /** checks whether the document is currently being initialized, or already initialized,
473 : throws a DoubleInitializationException if so
474 : */
475 34 : inline void checkNotInitialized() const
476 : {
477 34 : if ( impl_isInitializing() || impl_isInitialized() )
478 0 : throw ::com::sun::star::frame::DoubleInitializationException( OUString(), getThis() );
479 34 : }
480 :
481 : private:
482 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2 > getUIConfigurationManager2() throw (::com::sun::star::uno::RuntimeException);
483 :
484 : /** returns whether the model is currently being initialized
485 : */
486 1002 : bool impl_isInitializing() const { return m_eInitState == Initializing; }
487 :
488 : /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
489 : */
490 6350 : bool impl_isInitialized() const { return m_eInitState == Initialized; }
491 :
492 : /// tells the model it is being initialized now
493 210 : void impl_setInitializing() { m_eInitState = Initializing; }
494 :
495 : /// tells the model its initialization is done
496 : void impl_setInitialized();
497 :
498 : /** closes the frames of all connected controllers
499 :
500 : @param _bDeliverOwnership
501 : determines if the ownership should be transferred to the component which
502 : possibly vetos the closing
503 :
504 : @raises ::com::sun::star::util::CloseVetoException
505 : if the closing was vetoed by any instance
506 : */
507 : void impl_closeControllerFrames_nolck_throw( bool _bDeliverOwnership );
508 :
509 : /** disposes the frames of all controllers which are still left in m_aControllers.
510 : */
511 : void impl_disposeControllerFrames_nothrow();
512 :
513 : /** does a reparenting at the given object container to ourself
514 :
515 : Calls XChild::setParent at the given object, which must be one of our impl's or our
516 : object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
517 : */
518 : void impl_reparent_nothrow( const ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer );
519 :
520 : /** retrieves the forms or reports contained, creates and initializes it, if necessary
521 :
522 : @raises DisposedException
523 : if the instance is already disposed
524 : @raises IllegalArgumentException
525 : if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
526 : */
527 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
528 : impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
529 :
530 : /** resets everything
531 :
532 : @precond
533 : m_pImpl is not <NULLL/>
534 : */
535 : void
536 : impl_reset_nothrow();
537 :
538 : /** imports the document from the given resource.
539 : */
540 : static void
541 : impl_import_nolck_throw(
542 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rContext,
543 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
544 : const ::comphelper::NamedValueCollection& _rResource
545 : );
546 :
547 : /** creates a storage for the given URL, truncating it if a file with this name already exists
548 :
549 : @throws Exception
550 : if creating the storage failed
551 :
552 : @return
553 : the newly created storage for the file at the given URL
554 : */
555 : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
556 : impl_createStorageFor_throw(
557 : const OUString& _rURL
558 : ) const;
559 :
560 : /** sets our "modified" flag
561 :
562 : will notify all our respective listeners, if the "modified" state actually changed
563 :
564 : @param _bModified
565 : the (new) flag indicating whether the document is currently modified or not
566 : @param _rGuard
567 : the guard for our instance. At method entry, the guard must hold the lock. At the moment
568 : of method leave, the lock will be released.
569 : @precond
570 : our mutex is locked
571 : @postcond
572 : our mutex is not locked
573 : */
574 : void impl_setModified_nothrow( bool _bModified, DocumentGuard& _rGuard );
575 :
576 : /** stores the document to the given storage
577 :
578 : Note that the document is actually not rebased to this storage, it just stores a copy of itself
579 : to the given target storage.
580 :
581 : @param _rxTargetStorage
582 : denotes the storage to store the document into
583 : @param _rMediaDescriptor
584 : contains additional parameters for storing the document
585 : @param _rDocGuard
586 : a guard which holds the (only) lock to the document, and which will be temporarily
587 : released where necessary (e.g. for notifications, or calling into other components)
588 :
589 : @throws ::com::sun::star::uno::IllegalArgumentException
590 : if the given storage is <NULL/>.
591 :
592 : @throws ::com::sun::star::uno::RuntimeException
593 : when any of the used operations throws it
594 :
595 : @throws ::com::sun::star::io::IOException
596 : when any of the used operations throws it, or any other exception occurs which is no
597 : RuntimeException and no IOException
598 : */
599 : void impl_storeToStorage_throw(
600 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
601 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor,
602 : DocumentGuard& _rDocGuard
603 : ) const;
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 : bool impl_attachResource(
615 : const 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 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 __InitMethod
636 : {
637 : // a method which is to initialize the document
638 : InitMethod,
639 : };
640 :
641 : enum __DefaultMethod
642 : {
643 : // a default method
644 : DefaultMethod
645 : };
646 :
647 : enum __MethodUsedDuringInit
648 : {
649 : // a method which is used (externally) during the initialization phase
650 : MethodUsedDuringInit
651 : };
652 :
653 : enum __MethodWithoutInit
654 : {
655 : // a method which does not need initialization - use with care!
656 : MethodWithoutInit
657 : };
658 :
659 :
660 : /** constructs the guard
661 :
662 : @param _document
663 : the ODatabaseDocument instance
664 :
665 : @throws ::com::sun::star::lang::DisposedException
666 : If the given component is already disposed
667 :
668 : @throws ::com::sun::star::lang::NotInitializedException
669 : if the given component is not yet initialized
670 : */
671 928 : DocumentGuard(const ODatabaseDocument& _document, __DefaultMethod)
672 : : ModelMethodGuard(_document)
673 1098 : , m_document(_document )
674 : {
675 928 : m_document.checkInitialized();
676 758 : }
677 :
678 : /** constructs the guard
679 :
680 : @param _document
681 : the ODatabaseDocument instance
682 :
683 : @throws ::com::sun::star::lang::DisposedException
684 : If the given component is already disposed
685 :
686 : @throws ::com::sun::star::frame::DoubleInitializationException
687 : if the given component is already initialized, or currently being initialized.
688 : */
689 34 : DocumentGuard(const ODatabaseDocument& _document, __InitMethod)
690 : : ModelMethodGuard(_document)
691 34 : , m_document(_document)
692 : {
693 34 : m_document.checkNotInitialized();
694 34 : }
695 :
696 : /** constructs the guard
697 :
698 : @param _document
699 : the ODatabaseDocument instance
700 :
701 : @throws ::com::sun::star::lang::DisposedException
702 : If the given component is already disposed
703 :
704 : @throws ::com::sun::star::lang::NotInitializedException
705 : if the component is still uninitialized, and not in the initialization
706 : phase currently.
707 : */
708 1728 : DocumentGuard(const ODatabaseDocument& _document, __MethodUsedDuringInit)
709 : : ModelMethodGuard(_document)
710 1728 : , m_document(_document)
711 : {
712 1724 : m_document.checkNotUninitilized();
713 1724 : }
714 :
715 : /** constructs the guard
716 :
717 : @param _document
718 : the ODatabaseDocument instance
719 :
720 : @throws ::com::sun::star::lang::DisposedException
721 : If the given component is already disposed
722 : */
723 4788 : DocumentGuard(const ODatabaseDocument& _document, __MethodWithoutInit)
724 : : ModelMethodGuard( _document )
725 4788 : , m_document( _document )
726 : {
727 4788 : }
728 :
729 7304 : ~DocumentGuard()
730 7304 : {
731 7304 : }
732 :
733 522 : void clear()
734 : {
735 522 : ModelMethodGuard::clear();
736 522 : }
737 230 : void reset()
738 : {
739 230 : ModelMethodGuard::reset();
740 230 : m_document.checkDisposed();
741 230 : }
742 :
743 : private:
744 :
745 : const ODatabaseDocument& m_document;
746 : };
747 :
748 : } // namespace dbaccess
749 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
750 :
751 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|