1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: databasedocument.hxx,v $
10 * $Revision: 1.20.2.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
31 #define _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_
33 #include "ModelImpl.hxx"
34 #include "documenteventnotifier.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
38 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
39 #include <com/sun/star/frame/XModel2.hpp>
40 #include <com/sun/star/frame/XTitle.hpp>
41 #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
42 #include <com/sun/star/frame/XUntitledNumbers.hpp>
43 #include <com/sun/star/util/XModifiable.hpp>
44 #include <com/sun/star/frame/XStorable.hpp>
45 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
46 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
47 #include <com/sun/star/util/XCloseable.hpp>
48 #include <com/sun/star/view/XPrintable.hpp>
49 #include <com/sun/star/frame/XModuleManager.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
53 #include <com/sun/star/embed/XTransactionListener.hpp>
54 #include <com/sun/star/document/XStorageBasedDocument.hpp>
55 #include <com/sun/star/document/XEmbeddedScripts.hpp>
56 #include <com/sun/star/document/XEventsSupplier.hpp>
57 #include <com/sun/star/document/XScriptInvocationContext.hpp>
58 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
59 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
60 #include <com/sun/star/frame/XLoadable.hpp>
61 #include <com/sun/star/document/XEventBroadcaster.hpp>
62 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
63 /** === end UNO includes === **/
65 #if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_16)
66 #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_16
67 #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 16
68 #include <comphelper/implbase_var.hxx>
71 #include <cppuhelper/compbase10.hxx>
72 #include <cppuhelper/implbase3.hxx>
73 #include <rtl/ref.hxx>
75 #include <boost/shared_ptr.hpp>
76 #include <boost/noncopyable.hpp>
78 namespace comphelper
{
79 class NamedValueCollection
;
82 //........................................................................
85 //........................................................................
88 class DocumentEventExecutor
;
91 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> > Controllers
;
93 //============================================================
95 //============================================================
96 /** helper class monitoring the views of a document, and firing appropriate events
97 when views are attached / detached
99 class ViewMonitor
: public boost::noncopyable
102 ViewMonitor( DocumentEventNotifier
& _rEventNotifier
)
103 :m_rEventNotifier( _rEventNotifier
)
104 ,m_bIsNewDocument( true )
105 ,m_bEverHadController( false )
106 ,m_bLastIsFirstEverController( false )
107 ,m_xLastConnectedController()
113 m_bEverHadController
= false;
114 m_bLastIsFirstEverController
= false;
115 m_xLastConnectedController
.clear();
118 /** to be called when a view (aka controller) has been connected to the document
120 <TRUE/> if and only if this was the first-ever controller connected to the document
122 bool onControllerConnected(
123 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>& _rxController
126 /** to be called when a controller is set as current controller
128 void onSetCurrentController(
129 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>& _rxController
132 void onLoadedDocument() { m_bIsNewDocument
= false; }
135 DocumentEventNotifier
& m_rEventNotifier
;
136 bool m_bIsNewDocument
;
137 bool m_bEverHadController
;
138 bool m_bLastIsFirstEverController
;
139 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>
140 m_xLastConnectedController
;
143 //============================================================
144 //= ODatabaseDocument
145 //============================================================
146 typedef ::comphelper::WeakComponentImplHelper16
< ::com::sun::star::frame::XModel2
147 , ::com::sun::star::util::XModifiable
148 , ::com::sun::star::frame::XStorable
149 , ::com::sun::star::document::XEventBroadcaster
150 , ::com::sun::star::document::XDocumentEventBroadcaster
151 , ::com::sun::star::view::XPrintable
152 , ::com::sun::star::util::XCloseable
153 , ::com::sun::star::lang::XServiceInfo
154 , ::com::sun::star::sdb::XOfficeDatabaseDocument
155 , ::com::sun::star::ui::XUIConfigurationManagerSupplier
156 , ::com::sun::star::document::XStorageBasedDocument
157 , ::com::sun::star::document::XEmbeddedScripts
158 , ::com::sun::star::document::XScriptInvocationContext
159 , ::com::sun::star::script::provider::XScriptProviderSupplier
160 , ::com::sun::star::document::XEventsSupplier
161 , ::com::sun::star::frame::XLoadable
162 > ODatabaseDocument_OfficeDocument
;
164 typedef ::cppu::ImplHelper3
< ::com::sun::star::frame::XTitle
165 , ::com::sun::star::frame::XTitleChangeBroadcaster
166 , ::com::sun::star::frame::XUntitledNumbers
167 > ODatabaseDocument_Title
;
169 class ODatabaseDocument
:public ModelDependentComponent
// ModelDependentComponent must be first!
170 ,public ODatabaseDocument_OfficeDocument
171 ,public ODatabaseDocument_Title
180 DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference
< ::com::sun::star::frame::XUntitledNumbers
>,TNumberedController
);
181 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationManager
> m_xUIConfigurationManager
;
183 ::cppu::OInterfaceContainerHelper m_aModifyListeners
;
184 ::cppu::OInterfaceContainerHelper m_aCloseListener
;
185 ::cppu::OInterfaceContainerHelper m_aStorageListeners
;
187 DocumentEvents
* m_pEventContainer
;
188 ::rtl::Reference
< DocumentEventExecutor
> m_pEventExecutor
;
189 DocumentEventNotifier m_aEventNotifier
;
191 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> m_xCurrentController
;
192 Controllers m_aControllers
;
193 ViewMonitor m_aViewMonitor
;
195 ::com::sun::star::uno::WeakReference
< ::com::sun::star::container::XNameAccess
> m_xForms
;
196 ::com::sun::star::uno::WeakReference
< ::com::sun::star::container::XNameAccess
> m_xReports
;
197 ::com::sun::star::uno::WeakReference
< ::com::sun::star::script::provider::XScriptProvider
> m_xScriptProvider
;
199 /** @short such module manager is used to classify new opened documents. */
200 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModuleManager
> m_xModuleManager
;
201 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XTitle
> m_xTitleHelper
;
202 TNumberedController m_aNumberedControllers
;
204 /** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
205 the document has be initialized implicitly - see storeAsURL
207 InitState m_eInitState
;
209 bool m_bAllowDocumentScripting
;
211 enum StoreType
{ SAVE
, SAVE_AS
};
212 /** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
213 the modified flag, and notifies any listeners as required
216 the URL to store the document to
218 arguments for storing the document (MediaDescriptor)
220 the type of the store process (Save or SaveAs). The method will automatically
221 notify the proper events for this type.
223 the instance lock to be released before doing synchronous notifications
225 void impl_storeAs_throw(
226 const ::rtl::OUString
& _rURL
,
227 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _rArguments
,
228 const StoreType _eType
,
229 DocumentGuard
& _rGuard
232 /** notifies our storage change listeners that our underlying storage changed
234 @param _rxNewRootStorage
235 the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
236 happened, and the listeners are not notified.
238 void impl_notifyStorageChange_nolck_nothrow(
239 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _rxNewRootStorage
242 /// write a single XML stream into the package
243 void WriteThroughComponent(
244 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> & xComponent
, /// the component we export
245 const sal_Char
* pStreamName
, /// the stream name
246 const sal_Char
* pServiceName
, /// service name of the component
247 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> & rArguments
, /// the argument (XInitialization)
248 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> & rMediaDesc
,/// output descriptor
249 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _xStorageToSaveTo
253 /// write a single output stream
254 /// (to be called either directly or by WriteThroughComponent(...))
255 void WriteThroughComponent(
256 const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
>& xOutputStream
,
257 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& xComponent
,
258 const sal_Char
* pServiceName
,
259 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& rArguments
,
260 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> & rMediaDesc
263 /** writes the content and settings
268 @param _xStorageToSaveTo
269 The storage which should be used for saving
271 void impl_writeStorage_throw(
272 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _rxTargetStorage
,
273 const ::comphelper::NamedValueCollection
& _rMediaDescriptor
276 // ModelDependentComponent overridables
277 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getThis() const;
279 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XTitle
> impl_getTitleHelper_throw();
280 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XUntitledNumbers
> impl_getUntitledHelper_throw(
281 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xComponent
= ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>());
284 ODatabaseDocument(const ::rtl::Reference
<ODatabaseModelImpl
>& _pImpl
);
285 // Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
286 // ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
287 // If you create a ODatabaseDocument directly, you might easily create a leak.
288 // #i50905# / 2005-06-20 / frank.schonheit@sun.com
291 virtual void SAL_CALL
disposing();
293 virtual ~ODatabaseDocument();
296 struct FactoryAccess
{ friend class ODatabaseModelImpl
; private: FactoryAccess() { } };
297 static ODatabaseDocument
* createDatabaseDocument( const ::rtl::Reference
<ODatabaseModelImpl
>& _pImpl
, FactoryAccess
/*accessControl*/ )
299 return new ODatabaseDocument( _pImpl
);
303 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
304 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
305 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
307 // ::com::sun::star::lang::XServiceInfo - static methods
308 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException
);
309 static ::rtl::OUString
getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException
);
310 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
311 SAL_CALL
Create(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&);
314 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
315 virtual void SAL_CALL
acquire( ) throw ();
316 virtual void SAL_CALL
release( ) throw ();
319 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw (::com::sun::star::uno::RuntimeException
);
320 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) throw (::com::sun::star::uno::RuntimeException
);
323 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
326 virtual void SAL_CALL
dispose( ) throw (::com::sun::star::uno::RuntimeException
);
327 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
328 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
331 virtual sal_Bool SAL_CALL
attachResource( const ::rtl::OUString
& URL
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& Arguments
) throw (::com::sun::star::uno::RuntimeException
) ;
332 virtual ::rtl::OUString SAL_CALL
getURL( ) throw (::com::sun::star::uno::RuntimeException
) ;
333 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
getArgs( ) throw (::com::sun::star::uno::RuntimeException
) ;
334 virtual void SAL_CALL
connectController( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>& Controller
) throw (::com::sun::star::uno::RuntimeException
) ;
335 virtual void SAL_CALL
disconnectController( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>& Controller
) throw (::com::sun::star::uno::RuntimeException
) ;
336 virtual void SAL_CALL
lockControllers( ) throw (::com::sun::star::uno::RuntimeException
) ;
337 virtual void SAL_CALL
unlockControllers( ) throw (::com::sun::star::uno::RuntimeException
) ;
338 virtual sal_Bool SAL_CALL
hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException
) ;
339 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> SAL_CALL
getCurrentController( ) throw (::com::sun::star::uno::RuntimeException
) ;
340 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
) ;
341 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException
) ;
344 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
getControllers( ) throw (::com::sun::star::uno::RuntimeException
) ;
345 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAvailableViewControllerNames( ) throw (::com::sun::star::uno::RuntimeException
) ;
346 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
) ;
347 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController2
> SAL_CALL
createViewController( const ::rtl::OUString
& ViewName
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& Arguments
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& Frame
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
) ;
350 virtual sal_Bool SAL_CALL
hasLocation( ) throw (::com::sun::star::uno::RuntimeException
) ;
351 virtual ::rtl::OUString SAL_CALL
getLocation( ) throw (::com::sun::star::uno::RuntimeException
) ;
352 virtual sal_Bool SAL_CALL
isReadonly( ) throw (::com::sun::star::uno::RuntimeException
) ;
353 virtual void SAL_CALL
store( ) throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
) ;
354 virtual void SAL_CALL
storeAsURL( const ::rtl::OUString
& sURL
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& lArguments
) throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
) ;
355 virtual void SAL_CALL
storeToURL( const ::rtl::OUString
& sURL
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& lArguments
) throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
) ;
357 // XModifyBroadcaster
358 virtual void SAL_CALL
addModifyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
359 virtual void SAL_CALL
removeModifyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
361 // ::com::sun::star::util::XModifiable
362 virtual sal_Bool SAL_CALL
isModified( ) throw (::com::sun::star::uno::RuntimeException
) ;
363 virtual void SAL_CALL
setModified( sal_Bool bModified
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::uno::RuntimeException
) ;
366 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
367 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
369 // XDocumentEventBroadcaster
370 virtual void SAL_CALL
addDocumentEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XDocumentEventListener
>& _Listener
) throw (::com::sun::star::uno::RuntimeException
);
371 virtual void SAL_CALL
removeDocumentEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XDocumentEventListener
>& _Listener
) throw (::com::sun::star::uno::RuntimeException
);
372 virtual void SAL_CALL
notifyDocumentEvent( const ::rtl::OUString
& _EventName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController2
>& _ViewController
, const ::com::sun::star::uno::Any
& _Supplement
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
);
375 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
getPrinter( ) throw (::com::sun::star::uno::RuntimeException
) ;
376 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
) ;
377 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
) ;
379 // XFormDocumentsSupplier
380 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getFormDocuments( ) throw (::com::sun::star::uno::RuntimeException
);
382 // XReportDocumentsSupplier
383 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getReportDocuments( ) throw (::com::sun::star::uno::RuntimeException
);
386 virtual void SAL_CALL
close( sal_Bool DeliverOwnership
) throw (::com::sun::star::util::CloseVetoException
, ::com::sun::star::uno::RuntimeException
);
387 virtual void SAL_CALL
addCloseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
388 virtual void SAL_CALL
removeCloseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
390 // XUIConfigurationManagerSupplier
391 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationManager
> SAL_CALL
getUIConfigurationManager( ) throw (::com::sun::star::uno::RuntimeException
);
393 // XDocumentSubStorageSupplier
394 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
> SAL_CALL
getDocumentSubStorage( const ::rtl::OUString
& aStorageName
, sal_Int32 nMode
) throw (::com::sun::star::uno::RuntimeException
);
395 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
397 // XOfficeDatabaseDocument
398 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
> SAL_CALL
getDataSource() throw (::com::sun::star::uno::RuntimeException
);
400 // XStorageBasedDocument
401 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
);
402 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
);
403 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
);
404 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
);
405 virtual void SAL_CALL
addStorageChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XStorageChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
406 virtual void SAL_CALL
removeStorageChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XStorageChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
409 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::script::XStorageBasedLibraryContainer
> SAL_CALL
getBasicLibraries() throw (::com::sun::star::uno::RuntimeException
);
410 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::script::XStorageBasedLibraryContainer
> SAL_CALL
getDialogLibraries() throw (::com::sun::star::uno::RuntimeException
);
411 virtual ::sal_Bool SAL_CALL
getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException
);
413 // XScriptInvocationContext
414 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::document::XEmbeddedScripts
> SAL_CALL
getScriptContainer() throw (::com::sun::star::uno::RuntimeException
);
416 // XScriptProviderSupplier
417 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::script::provider::XScriptProvider
> SAL_CALL
getScriptProvider( ) throw (::com::sun::star::uno::RuntimeException
);
420 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameReplace
> SAL_CALL
getEvents( ) throw (::com::sun::star::uno::RuntimeException
);
423 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
);
424 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
);
427 virtual ::rtl::OUString SAL_CALL
getTitle( ) throw (::com::sun::star::uno::RuntimeException
);
428 virtual void SAL_CALL
setTitle( const ::rtl::OUString
& sTitle
) throw (::com::sun::star::uno::RuntimeException
);
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
);
432 virtual void SAL_CALL
removeTitleChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XTitleChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
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
);
436 virtual void SAL_CALL
releaseNumber( ::sal_Int32 nNumber
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
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
);
438 virtual ::rtl::OUString SAL_CALL
getUntitledPrefix( ) throw (::com::sun::star::uno::RuntimeException
);
440 /** clears the given object container
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)
447 the container to clear
449 static void clearObjectContainer(
450 ::com::sun::star::uno::WeakReference
< ::com::sun::star::container::XNameAccess
>& _rxContainer
);
452 /** checks whether the component is already initialized, throws a NotInitializedException if not
454 inline void checkInitialized() const
456 if ( !impl_isInitialized() )
457 throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() );
460 /** checks the document is currently in the initialization phase, or already initialized.
461 Throws NotInitializedException if not so.
463 inline void checkNotUninitilized() const
465 if ( impl_isInitialized() || impl_isInitializing() )
469 throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() );
472 /** checks whether the document is currently being initialized, or already initialized,
473 throws a DoubleInitializationException if so
475 inline void checkNotInitialized() const
477 if ( impl_isInitializing() || impl_isInitialized() )
478 throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), getThis() );
482 /** returns whether the model is currently being initialized
484 bool impl_isInitializing() const { return m_eInitState
== Initializing
; }
486 /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
488 bool impl_isInitialized() const { return m_eInitState
== Initialized
; }
490 /// tells the model it is being initialized now
491 void impl_setInitializing() { m_eInitState
= Initializing
; }
493 /// tells the model its initialization is done
494 void impl_setInitialized();
496 /** closes the frames of all connected controllers
498 @param _bDeliverOwnership
499 determines if the ownership should be transfered to the component which
500 possibly vetos the closing
502 @raises ::com::sun::star::util::CloseVetoException
503 if the closing was vetoed by any instance
505 void impl_closeControllerFrames_nolck_throw( sal_Bool _bDeliverOwnership
);
507 /** disposes the frames of all controllers which are still left in m_aControllers.
509 void impl_disposeControllerFrames_nothrow();
511 /** does a reparenting at the given object container to ourself
513 Calls XChild::setParent at the given object, which must be one of our impl's or our
514 object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
516 void impl_reparent_nothrow( const ::com::sun::star::uno::WeakReference
< ::com::sun::star::container::XNameAccess
>& _rxContainer
);
518 /** retrieves the forms or reports contained, creates and initializes it, if necessary
520 @raises DisposedException
521 if the instance is already disposed
522 @raises IllegalArgumentException
523 if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
525 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
526 impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType
);
528 /** resets everything
531 m_pImpl is not <NULLL/>
534 impl_reset_nothrow();
536 /** imports the document from the given resource.
539 impl_import_nolck_throw(
540 const ::comphelper::ComponentContext _rContext
,
541 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxTargetComponent
,
542 const ::comphelper::NamedValueCollection
& _rResource
545 /** creates a storage for the given URL, truncating it if a file with this name already exists
548 if creating the storage failed
551 the newly created storage for the file at the given URL
553 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>
554 impl_createStorageFor_throw(
555 const ::rtl::OUString
& _rURL
558 /** sets our "modified" flag
560 will notify all our respective listeners, if the "modified" state actually changed
563 the (new) flag indicating whether the document is currently modified or not
565 the guard for our instance. At method entry, the guard must hold the lock. At the moment
566 of method leave, the lock will be released.
570 our mutex is not locked
572 void impl_setModified_nothrow( sal_Bool _bModified
, DocumentGuard
& _rGuard
);
574 /** stores the document to the given storage
576 Note that the document is actually not rebased to this storage, it just stores a copy of itself
577 to the given target storage.
579 @param _rxTargetStorage
580 denotes the storage to store the document into
581 @param _rMediaDescriptor
582 contains additional parameters for storing the document
584 a guard which holds the (only) lock to the document, and which will be temporarily
585 released where necessary (e.g. for notifications, or calling into other components)
587 @throws ::com::sun::star::uno::IllegalArgumentException
588 if the given storage is <NULL/>.
590 @throws ::com::sun::star::uno::RuntimeException
591 when any of the used operations throws it
593 @throws ::com::sun::star::io::IOException
594 when any of the used operations throws it, or any other exception occurs which is no
595 RuntimeException and no IOException
597 void impl_storeToStorage_throw(
598 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _rxTargetStorage
,
599 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _rMediaDescriptor
,
600 DocumentGuard
& _rDocGuard
604 /** an extended version of the ModelMethodGuard, which also cares for the initialization state
607 class DocumentGuard
: private ModelMethodGuard
612 // a method which is to initialize the document
616 // a method which is used (externally) during the initialization phase
617 MethodUsedDuringInit
,
618 // a method which does not need initialization - use with care!
622 /** constructs the guard
625 the ODatabaseDocument instance
627 @throws ::com::sun::star::lang::DisposedException
628 If the given component is already disposed
630 @throws ::com::sun::star::frame::DoubleInitializationException
631 if _eType is InitMethod, and the given component is already initialized, or currently being initialized.
633 @throws ::com::sun::star::lang::NotInitializedException
634 if _eType is DefaultMethod, and the given component is not yet initialized; or if _eType
635 is MethodUsedDuringInit, and the component is still uninitialized, and not in the initialization
638 DocumentGuard( const ODatabaseDocument
& _document
, MethodType _eType
= DefaultMethod
)
639 :ModelMethodGuard( _document
)
640 ,m_document( _document
)
644 case InitMethod
: m_document
.checkNotInitialized(); break;
645 case DefaultMethod
: m_document
.checkInitialized(); break;
646 case MethodUsedDuringInit
: m_document
.checkNotUninitilized(); break;
647 case MethodWithoutInit
: break;
657 ModelMethodGuard::clear();
661 ModelMethodGuard::reset();
662 m_document
.checkDisposed();
667 const ODatabaseDocument
& m_document
;
670 //........................................................................
671 } // namespace dbaccess
672 //........................................................................
673 #endif // _DBA_COREDATAACCESS_DATABASEDOCUMENT_HXX_