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 101 : class ViewMonitor : public boost::noncopyable
89 : {
90 : public:
91 109 : ViewMonitor( DocumentEventNotifier& _rEventNotifier )
92 : :m_rEventNotifier( _rEventNotifier )
93 : ,m_bIsNewDocument( true )
94 : ,m_bEverHadController( false )
95 : ,m_bLastIsFirstEverController( false )
96 109 : ,m_xLastConnectedController()
97 : {
98 109 : }
99 :
100 108 : void reset()
101 : {
102 108 : m_bEverHadController = false;
103 108 : m_bLastIsFirstEverController = false;
104 108 : m_xLastConnectedController.clear();
105 108 : }
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 17 : 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 : /// If XModel::attachResource() was called to inform us that the document is embedded into an other one.
204 : bool m_bEmbedded;
205 :
206 : enum StoreType { SAVE, SAVE_AS };
207 : /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
208 : the modified flag, and notifies any listeners as required
209 :
210 : @param _rURL
211 : the URL to store the document to
212 : @param _rArguments
213 : arguments for storing the document (MediaDescriptor)
214 : @param _eType
215 : the type of the store process (Save or SaveAs). The method will automatically
216 : notify the proper events for this type.
217 : @param _rGuard
218 : the instance lock to be released before doing synchronous notifications
219 : */
220 : void impl_storeAs_throw(
221 : const OUString& _rURL,
222 : const ::comphelper::NamedValueCollection& _rArguments,
223 : const StoreType _eType,
224 : DocumentGuard& _rGuard
225 : )
226 : throw (css::io::IOException,
227 : css::uno::RuntimeException,
228 : std::exception);
229 :
230 : /** notifies our storage change listeners that our underlying storage changed
231 :
232 : @param _rxNewRootStorage
233 : the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
234 : happened, and the listeners are not notified.
235 : */
236 : void impl_notifyStorageChange_nolck_nothrow(
237 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
238 : );
239 :
240 : /// write a single XML stream into the package
241 : void WriteThroughComponent(
242 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > & xComponent, /// the component we export
243 : const sal_Char* pStreamName, /// the stream name
244 : const sal_Char* pServiceName, /// service name of the component
245 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> & rArguments, /// the argument (XInitialization)
246 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc,/// output descriptor
247 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _xStorageToSaveTo
248 : ) const;
249 :
250 : /// write a single output stream
251 : /// (to be called either directly or by WriteThroughComponent(...))
252 : void WriteThroughComponent(
253 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
254 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
255 : const sal_Char* pServiceName,
256 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
257 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
258 : ) const;
259 :
260 : /** writes the content and settings
261 : @param sURL
262 : The URL
263 : @param lArguments
264 : The media descriptor
265 : @param _xStorageToSaveTo
266 : The storage which should be used for saving
267 : */
268 : void impl_writeStorage_throw(
269 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
270 : const ::comphelper::NamedValueCollection& _rMediaDescriptor
271 : ) const;
272 :
273 : // ModelDependentComponent overridables
274 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const SAL_OVERRIDE;
275 :
276 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper_throw();
277 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
278 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
279 :
280 : private:
281 : ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
282 : // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
283 : // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
284 : // If you create a ODatabaseDocument directly, you might easily create a leak.
285 : // #i50905#
286 :
287 : protected:
288 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
289 :
290 : virtual ~ODatabaseDocument();
291 :
292 : public:
293 109 : struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
294 109 : static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
295 : {
296 109 : return new ODatabaseDocument( _pImpl );
297 : }
298 :
299 : // XServiceInfo
300 : virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
302 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
303 :
304 : // ::com::sun::star::lang::XServiceInfo - static methods
305 : static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static() throw( ::com::sun::star::uno::RuntimeException );
306 : static OUString getImplementationName_static() throw( ::com::sun::star::uno::RuntimeException );
307 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
308 : SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
309 :
310 : // XInterface
311 : 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;
312 : virtual void SAL_CALL acquire( ) throw () SAL_OVERRIDE;
313 : virtual void SAL_CALL release( ) throw () SAL_OVERRIDE;
314 :
315 : // XTypeProvider
316 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
317 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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 467 : inline void checkInitialized() const
454 : {
455 467 : if ( !impl_isInitialized() )
456 80 : throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
457 387 : }
458 :
459 : /** checks the document is currently in the initialization phase, or already initialized.
460 : Throws NotInitializedException if not so.
461 : */
462 893 : inline void checkNotUninitilized() const
463 : {
464 893 : if ( impl_isInitialized() || impl_isInitializing() )
465 : // fine
466 1786 : 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 16 : inline void checkNotInitialized() const
475 : {
476 16 : if ( impl_isInitializing() || impl_isInitialized() )
477 0 : throw ::com::sun::star::frame::DoubleInitializationException( OUString(), getThis() );
478 16 : }
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 518 : 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 3087 : bool impl_isInitialized() const { return m_eInitState == Initialized; }
490 :
491 : /// tells the model it is being initialized now
492 108 : 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 transferred 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( 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( 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 : 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 __InitMethod
635 : {
636 : // a method which is to initialize the document
637 : InitMethod,
638 : };
639 :
640 : enum __DefaultMethod
641 : {
642 : // a default method
643 : DefaultMethod
644 : };
645 :
646 : enum __MethodUsedDuringInit
647 : {
648 : // a method which is used (externally) during the initialization phase
649 : MethodUsedDuringInit
650 : };
651 :
652 : enum __MethodWithoutInit
653 : {
654 : // a method which does not need initialization - use with care!
655 : MethodWithoutInit
656 : };
657 :
658 :
659 : /** constructs the guard
660 :
661 : @param _document
662 : the ODatabaseDocument instance
663 :
664 : @throws ::com::sun::star::lang::DisposedException
665 : If the given component is already disposed
666 :
667 : @throws ::com::sun::star::lang::NotInitializedException
668 : if the given component is not yet initialized
669 : */
670 467 : DocumentGuard(const ODatabaseDocument& _document, __DefaultMethod)
671 : : ModelMethodGuard(_document)
672 547 : , m_document(_document )
673 : {
674 467 : m_document.checkInitialized();
675 387 : }
676 :
677 : /** constructs the guard
678 :
679 : @param _document
680 : the ODatabaseDocument instance
681 :
682 : @throws ::com::sun::star::lang::DisposedException
683 : If the given component is already disposed
684 :
685 : @throws ::com::sun::star::frame::DoubleInitializationException
686 : if the given component is already initialized, or currently being initialized.
687 : */
688 16 : DocumentGuard(const ODatabaseDocument& _document, __InitMethod)
689 : : ModelMethodGuard(_document)
690 16 : , m_document(_document)
691 : {
692 16 : m_document.checkNotInitialized();
693 16 : }
694 :
695 : /** constructs the guard
696 :
697 : @param _document
698 : the ODatabaseDocument instance
699 :
700 : @throws ::com::sun::star::lang::DisposedException
701 : If the given component is already disposed
702 :
703 : @throws ::com::sun::star::lang::NotInitializedException
704 : if the component is still uninitialized, and not in the initialization
705 : phase currently.
706 : */
707 894 : DocumentGuard(const ODatabaseDocument& _document, __MethodUsedDuringInit)
708 : : ModelMethodGuard(_document)
709 894 : , m_document(_document)
710 : {
711 893 : m_document.checkNotUninitilized();
712 893 : }
713 :
714 : /** constructs the guard
715 :
716 : @param _document
717 : the ODatabaseDocument instance
718 :
719 : @throws ::com::sun::star::lang::DisposedException
720 : If the given component is already disposed
721 : */
722 2311 : DocumentGuard(const ODatabaseDocument& _document, __MethodWithoutInit)
723 : : ModelMethodGuard( _document )
724 2311 : , m_document( _document )
725 : {
726 2311 : }
727 :
728 3607 : ~DocumentGuard()
729 3607 : {
730 3607 : }
731 :
732 318 : void clear()
733 : {
734 318 : ModelMethodGuard::clear();
735 318 : }
736 119 : void reset()
737 : {
738 119 : ModelMethodGuard::reset();
739 119 : m_document.checkDisposed();
740 119 : }
741 :
742 : private:
743 :
744 : const ODatabaseDocument& m_document;
745 : };
746 :
747 : } // namespace dbaccess
748 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
749 :
750 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|