Tag: cws_dev300_odbmacros3 User: fs Date: 2008-07-23 10:03:33+0000 Modified: dba/dbaccess/source/core/dataaccess/ModelImpl.cxx dba/dbaccess/source/core/dataaccess/ModelImpl.hxx dba/dbaccess/source/core/dataaccess/databasedocument.cxx dba/dbaccess/source/core/dataaccess/databasedocument.hxx
Log: #i76128# support for XLoadable File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: ModelImpl.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.cxx?r1=1.25.6.6&r2=1.25.6.7 Delta lines: +57 -9 -------------------- --- ModelImpl.cxx 2008-07-01 07:39:13+0000 1.25.6.6 +++ ModelImpl.cxx 2008-07-23 10:03:31+0000 1.25.6.7 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ModelImpl.cxx,v $ - * $Revision: 1.25.6.6 $ + * $Revision: 1.25.6.7 $ * * This file is part of OpenOffice.org. * @@ -50,6 +50,7 @@ #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp> #include <com/sun/star/script/DocumentDialogLibraryContainer.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <com/sun/star/form/XLoadable.hpp> /** === end UNO includes === **/ #include <comphelper/interaction.hxx> @@ -308,9 +309,11 @@ ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_pDBContext( &_rDBContext ) + ,m_refCount(0) ,m_bHasAnyObjectWithMacros( false ) ,m_bHasMacroStorages( false ) ,m_bModificationLock( false ) + ,m_eInitState( NotInitialized ) ,m_aContext( _rxFactory ) ,m_nLoginTimeout(0) ,m_bReadOnly(sal_False) @@ -320,7 +323,6 @@ ,m_bDocumentReadOnly(sal_False) ,m_bDisposingSubStorages( sal_False ) ,m_pSharedConnectionManager(NULL) - ,m_refCount(0) ,m_nControllerLockCount(0) { // some kind of default @@ -346,9 +348,11 @@ ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_pDBContext( &_rDBContext ) + ,m_refCount(0) ,m_bHasAnyObjectWithMacros( false ) ,m_bHasMacroStorages( false ) ,m_bModificationLock( false ) + ,m_eInitState( NotInitialized ) ,m_aContext( _rxFactory ) ,m_sName(_rRegistrationName) ,m_nLoginTimeout(0) @@ -359,7 +363,6 @@ ,m_bDocumentReadOnly(sal_False) ,m_bDisposingSubStorages( sal_False ) ,m_pSharedConnectionManager(NULL) - ,m_refCount(0) ,m_nControllerLockCount(0) { DBG_CTOR(ODatabaseModelImpl,NULL); @@ -667,6 +670,37 @@ return m_xNumberFormatsSupplier; } // ----------------------------------------------------------------------------- +void ODatabaseModelImpl::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArgs ) +{ + ::comphelper::NamedValueCollection aMediaDescriptor( _rArgs ); + + ::rtl::OUString sDocumentLocation( aMediaDescriptor.getOrDefault( "SalvagedFile", _rURL ) ); + if ( !sDocumentLocation.getLength() ) + // this indicates "the document is being recovered, but _rURL already is the real document URL, + // not the temporary document location" + sDocumentLocation = _rURL; + + if ( aMediaDescriptor.has( "SalvagedFile" ) ) + aMediaDescriptor.remove( "SalvagedFile" ); + + m_aArgs = stripLoadArguments( aMediaDescriptor ); + + switchToURL( sDocumentLocation, _rURL ); +} + +// ----------------------------------------------------------------------------- +Sequence< PropertyValue > ODatabaseModelImpl::stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments ) +{ + OSL_ENSURE( !_rArguments.has( "Model" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (1)!" ); + OSL_ENSURE( !_rArguments.has( "ViewName" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (2)!" ); + + ::comphelper::NamedValueCollection aMutableArgs( _rArguments ); + aMutableArgs.remove( "Model" ); + aMutableArgs.remove( "ViewName" ); + return aMutableArgs.getPropertyValues(); +} + +// ----------------------------------------------------------------------------- void ODatabaseModelImpl::disposeStorages() SAL_THROW(()) { m_bDisposingSubStorages = sal_True; @@ -920,11 +954,11 @@ } // ----------------------------------------------------------------------------- -Reference<XDataSource> ODatabaseModelImpl::getDataSource( bool _bCreateIfNecessary ) +Reference<XDataSource> ODatabaseModelImpl::getOrCreateDataSource() { Reference<XDataSource> xDs = m_xDataSource; - if ( !xDs.is() && _bCreateIfNecessary ) - { // no data source, so we have to create one and register it later on + if ( !xDs.is() ) + { xDs = new ODatabaseSource(this); m_xDataSource = xDs; } @@ -936,7 +970,7 @@ return m_xModel; } // ----------------------------------------------------------------------------- -Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership() +Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership( bool _bInitializeIfNecessary ) { Reference< XModel > xModel( m_xModel ); OSL_PRECOND( !xModel.is(), "ODatabaseModelImpl::createNewModel_deliverOwnership: not to be called if there already is a model!" ); @@ -944,6 +978,20 @@ { xModel = ODatabaseDocument::createDatabaseDocument( this, ODatabaseDocument::FactoryAccess() ); m_xModel = xModel; + + if ( _bInitializeIfNecessary && !isInitialized() ) + { + try + { + Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW ); + xLoad->initNew(); + } + catch( RuntimeException& ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } } return xModel; } File [changed]: ModelImpl.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.hxx?r1=1.24&r2=1.24.4.1 Delta lines: +115 -11 ---------------------- --- ModelImpl.hxx 2008-06-25 12:30:50+0000 1.24 +++ ModelImpl.hxx 2008-07-23 10:03:31+0000 1.24.4.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ModelImpl.hxx,v $ - * $Revision: 1.24 $ + * $Revision: 1.24.4.1 $ * * This file is part of OpenOffice.org. * @@ -48,6 +48,7 @@ #include <com/sun/star/embed/XTransactionListener.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/lang/NotInitializedException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> @@ -66,6 +67,7 @@ #include <com/sun/star/util/XNumberFormatter.hpp> #include <com/sun/star/util/XRefreshable.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> +#include <com/sun/star/frame/DoubleInitializationException.hpp> /** === end UNO includes === **/ #include <comphelper/broadcasthelper.hxx> @@ -81,6 +83,11 @@ #include <memory> +namespace comphelper +{ + class NamedValueCollection; +} + //........................................................................ namespace dbaccess { @@ -151,6 +158,13 @@ E_TABLE = 3 }; + enum InitState + { + NotInitialized, + Initializing, + Initialized + }; + private: ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDataSource > m_xDataSource; @@ -169,9 +183,12 @@ ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener; ODatabaseContext* m_pDBContext; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArgs; /// the URL the document was loaded from ::rtl::OUString m_sDocFileLocation; + oslInterlockedCount m_refCount; + /// do we have any object (forms/reports) which contains macros? bool m_bHasAnyObjectWithMacros; /// does our root storage have macro/script sub storages? @@ -180,6 +197,9 @@ /// true if setting the Modified flag of the document is currently locked bool m_bModificationLock; + /// true if and only if the DatabaseDocument's "initNew" or "load" have been called + InitState m_eInitState; + /** the URL which the document should report as it's URL This might differ from ->m_sDocFileLocation in case the document was loaded @@ -218,12 +238,9 @@ m_xSettings; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableTypeFilter; - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - m_aArgs; OSharedConnectionManager* m_pSharedConnectionManager; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > m_xSharedConnectionManager; - oslInterlockedCount m_refCount; sal_uInt16 m_nControllerLockCount; void reset(); @@ -275,6 +292,15 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& getNumberFormatsSupplier(); + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& + getResource() const { return m_aArgs; } + + void attachResource( + const ::rtl::OUString& _rURL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ); + + static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments ); // other stuff void flushTables(); @@ -313,7 +339,7 @@ /** returns the data source. If it doesn't exist it will be created */ - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getDataSource( bool _bCreateIfNecessary = true ); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getOrCreateDataSource(); /** returns the model, if there already exists one */ @@ -321,12 +347,16 @@ /** returns a new ->ODatabaseDocument + @param _bInitializeIfNecessary + calls XLoadable::initNew on the newly created model, if necessary + @precond No ->ODatabaseDocument exists so far + @seealso getModel_noCreate */ - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > createNewModel_deliverOwnership(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > createNewModel_deliverOwnership( bool _bInitializeIfNecessary ); struct ResetModelAccess { friend class ODatabaseDocument; private: ResetModelAccess() { } }; @@ -457,7 +487,7 @@ const ::rtl::OUString& _rDocumentURL ); - /** returns the macro mode imposed by an external instance, by passing it to attachResource + /** returns the macro mode imposed by an external instance, which passed it to attachResource */ sal_Int16 getImposedMacroExecMode() const { @@ -487,6 +517,20 @@ void unlockModify() { m_bModificationLock = false; } bool isModifyLocked() const { return m_bModificationLock; } + /** returns whether the model is currently being initialized + */ + bool isInitializing() const { return m_eInitState == Initializing; } + + /** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called + */ + bool isInitialized() const { return m_eInitState == Initialized; } + + /// tells the model it is being initialized now + void setInitializing() { m_eInitState = Initializing; } + + /// tells the model its initialization is done + void setInitialized() { m_eInitState = Initialized; } + private: void impl_construct_nothrow(); ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > @@ -532,12 +576,45 @@ return m_pImpl; } + /// checks whether the component is already disposed, throws a DisposedException if so inline void checkDisposed() const { if ( !m_pImpl.is() ) throw ::com::sun::star::lang::DisposedException( ::rtl::OUString::createFromAscii( "Component is already disposed." ), getThis() ); } + /** checks whether the component is already initialized, throws a NotInitializedException if not + + only to be called after checkDisposed! + */ + inline void checkInitialized() const + { + if ( !m_pImpl->isInitialized() ) + throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() ); + } + + // checks the component is currently in the initialization phase, or already initialized + inline void checkNotUninitilized() const + { + if ( m_pImpl->isInitialized() ) + // fine + return; + + if ( !m_pImpl->isInitializing() ) + // we're not initialized, and not in the initializing phase + throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), getThis() ); + } + + /** checks whether the component currently being initialized, throws a DoubleInitializationException if so + + only to be called after checkDisposed! + */ + inline void checkNotInitializing() const + { + if ( m_pImpl->isInitializing() ) + throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), getThis() ); + } + inline void lockModify( GuardAccess ) { m_pImpl->lockModify(); @@ -572,12 +649,22 @@ Just put this guard onto the stack at the beginning of your method. Don't bother yourself with a MutexGuard, checks for being disposed, and the like. */ -class ModelMethodGuard :public ::osl::ResettableMutexGuard +class ModelMethodGuard : public ::osl::ResettableMutexGuard { private: typedef ::osl::ResettableMutexGuard BaseMutexGuard; public: + enum MethodType + { + // a method which is to initialize the document + InitMethod, + // a default method + DefaultMethod, + // a method which is used (externally) during the initialization phase + MethodUsedDuringInit + }; + /** constructs the guard @param _component @@ -585,11 +672,28 @@ @throws ::com::sun::star::lang::DisposedException If the given component is already disposed + + @throws ::com::sun::star::frame::DoubleInitializationException + if _eType is InitMethod, and the given component is already being initialized. The exception + is not thrown if the component already *is* initialized - this is allowed, it will simply + be initialized a second time, perhaps from other resources. + + @throws ::com::sun::star::lang::NotInitializedException + if _eType is DefaultMethod, and the given component is not yet initialized; or if _eType + is MethodUsedDuringInit, and the component is still uninitialized, and not in the initialization + phase currently. */ - ModelMethodGuard( const ModelDependentComponent& _component ) + ModelMethodGuard( const ModelDependentComponent& _component, MethodType _eType = DefaultMethod ) :BaseMutexGuard( _component.getMutex( ModelDependentComponent::GuardAccess() ) ) { _component.checkDisposed(); + + switch ( _eType ) + { + case InitMethod: _component.checkNotInitializing(); break; + case DefaultMethod: _component.checkInitialized(); break; + case MethodUsedDuringInit: _component.checkNotUninitilized(); break; + } } inline void clear() File [changed]: databasedocument.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.40.6.8&r2=1.40.6.9 Delta lines: +71 -83 --------------------- --- databasedocument.cxx 2008-07-22 06:31:37+0000 1.40.6.8 +++ databasedocument.cxx 2008-07-23 10:03:31+0000 1.40.6.9 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: databasedocument.cxx,v $ - * $Revision: 1.40.6.8 $ + * $Revision: 1.40.6.9 $ * * This file is part of OpenOffice.org. * @@ -64,6 +64,7 @@ #include <comphelper/mediadescriptor.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/numberedcollection.hxx> +#include <comphelper/storagehelper.hxx> #include <cppuhelper/exc_hlp.hxx> #include <framework/titlehelper.hxx> #include <tools/debug.hxx> @@ -250,15 +251,6 @@ // ----------------------------------------------------------------------------- namespace { - static void lcl_stripLoadArguments( ::comphelper::NamedValueCollection& _rArguments, Sequence< PropertyValue >& _rArgs ) - { - OSL_ENSURE( !_rArguments.has( "Model" ), "lcl_stripLoadArguments: this is suspicious (1)!" ); - OSL_ENSURE( !_rArguments.has( "ViewName" ), "lcl_stripLoadArguments: this is suspicious (2)!" ); - _rArguments.remove( "Model" ); - _rArguments.remove( "ViewName" ); - _rArguments >>= _rArgs; - } - // ----------------------------------------------------------------------------- static void lcl_extractAndStartStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Reference< XStatusIndicator >& _rxStatusIndicator, Sequence< Any >& _rCallArgs ) @@ -333,7 +325,7 @@ xImporter->setTargetDocument( xComponent ); Reference< XFilter > xFilter( xImporter, UNO_QUERY_THROW ); - xFilter->filter( m_pImpl->m_aArgs ); + xFilter->filter( ODatabaseModelImpl::stripLoadArguments( _rResource ) ); if ( xStatusIndicator.is() ) xStatusIndicator->end(); @@ -350,59 +342,75 @@ } // ----------------------------------------------------------------------------- -// XModel -// ATTENTION: The Application controller attaches the same resource to force a reload. -// TODO: this is a bug. By (API) definition, attachResource is only for notifying the document -// of its resource, *not* for loading it. We should implement an XLoadable, and move all the -// load logic therein. -sal_Bool SAL_CALL ODatabaseDocument::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _aArguments ) throw (RuntimeException) +void SAL_CALL ODatabaseDocument::initNew( ) throw (DoubleInitializationException, IOException, Exception, RuntimeException) { - ModelMethodGuard aGuard( *this ); - OSL_ENSURE(m_pImpl.is(),"Impl is NULL"); + ModelMethodGuard aGuard( *this, ModelMethodGuard::InitMethod ); impl_reset_nothrow(); - ::comphelper::NamedValueCollection aResource( _aArguments ); - lcl_stripLoadArguments( aResource, m_pImpl->m_aArgs ); + m_pImpl->setInitializing(); + + // create a temporary storage + Reference< XStorage > xTempStor( ::comphelper::OStorageHelper::GetTemporaryStorage( + m_pImpl->m_aContext.getLegacyServiceFactory() ) ); + + // store therein + impl_storeToStorage_throw( xTempStor, Sequence< PropertyValue >() ); + + // let the impl know we're now based on this storage + m_pImpl->switchToStorage( xTempStor ); + + m_pImpl->setInitialized(); + + impl_setModified_throw( sal_False, aGuard ); + impl_notifyStorageChange_nolck_nothrow( xTempStor ); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL ODatabaseDocument::load( const Sequence< PropertyValue >& _Arguments ) throw (DoubleInitializationException, IOException, Exception, RuntimeException) +{ + ModelMethodGuard aGuard( *this, ModelMethodGuard::InitMethod ); + + impl_reset_nothrow(); + + ::comphelper::NamedValueCollection aResource( _Arguments ); // now that somebody (perhaps) told us an macro execution mode, remember it as // ImposedMacroExecMode m_pImpl->setImposedMacroExecMode( aResource.getOrDefault( "MacroExecutionMode", m_pImpl->getImposedMacroExecMode() ) ); - ::rtl::OUString sDocumentLocation( aResource.getOrDefault( "SalvagedFile", _rURL ) ); - if ( !sDocumentLocation.getLength() ) - // this indicates "the document is being recovered, but _rURL already is the real document URL, - // not the temporary document location" - sDocumentLocation = _rURL; - m_pImpl->switchToURL( sDocumentLocation, _rURL ); - - bool bSuccess = - ( m_pImpl->getOrCreateRootStorage().is() - && impl_import_throw( aResource ) // TODO: this doesn't belong here, but into an (externally called) XLoadable::load implementation - ); - - if ( !bSuccess ) - { - m_pImpl->revokeDataSource(); - return sal_False; - } + m_pImpl->setInitializing(); + if ( !impl_import_throw( aResource ) ) + impl_reset_nothrow(); + m_pImpl->setInitialized(); impl_setModified_throw( sal_False, aGuard ); +} + +// ----------------------------------------------------------------------------- +// XModel +sal_Bool SAL_CALL ODatabaseDocument::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException) +{ + ModelMethodGuard aGuard( *this ); + m_pImpl->attachResource( _rURL, _rArguments ); return sal_True; } + // ----------------------------------------------------------------------------- ::rtl::OUString SAL_CALL ODatabaseDocument::getURL( ) throw (RuntimeException) { ModelMethodGuard aGuard( *this ); return m_pImpl->getURL(); } + // ----------------------------------------------------------------------------- Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs( ) throw (RuntimeException) { ModelMethodGuard aGuard( *this ); - return m_pImpl->m_aArgs; + return m_pImpl->getResource(); } + // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseDocument::connectController( const Reference< XController >& _xController ) throw (RuntimeException) { @@ -463,6 +471,7 @@ } } } + // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseDocument::lockControllers( ) throw (RuntimeException) { @@ -471,6 +480,7 @@ ++m_pImpl->m_nControllerLockCount; } + // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseDocument::unlockControllers( ) throw (RuntimeException) { @@ -479,6 +489,7 @@ --m_pImpl->m_nControllerLockCount; } + // ----------------------------------------------------------------------------- sal_Bool SAL_CALL ODatabaseDocument::hasControllersLocked( ) throw (RuntimeException) { @@ -487,6 +498,7 @@ return m_pImpl->m_nControllerLockCount != 0; } + // ----------------------------------------------------------------------------- Reference< XController > SAL_CALL ODatabaseDocument::getCurrentController() throw (RuntimeException) { @@ -495,6 +507,7 @@ return m_xCurrentController.is() ? m_xCurrentController : ( m_aControllers.empty() ? Reference< XController >() : *m_aControllers.begin() ); } + // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseDocument::setCurrentController( const Reference< XController >& _xController ) throw (NoSuchElementException, RuntimeException) { @@ -548,7 +561,7 @@ if ( m_pImpl->m_bDocumentReadOnly ) throw IOException(); - impl_storeAs_throw( m_pImpl->getURL(), m_pImpl->m_aArgs, "OnSaveDone", aGuard ); + impl_storeAs_throw( m_pImpl->getURL(), m_pImpl->getResource(), "OnSaveDone", aGuard ); } // ----------------------------------------------------------------------------- @@ -583,17 +596,13 @@ m_pImpl->m_bDocumentReadOnly = sal_False; } - // adjust arguments - ::comphelper::NamedValueCollection aResource( _rArguments ); - lcl_stripLoadArguments( aResource, m_pImpl->m_aArgs ); - Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( m_pImpl->m_aArgs, _rURL ) ); - // store to current storage Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW ); + Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) ); impl_storeToStorage_throw( xCurrentStorage, aMediaDescriptor ); - // success - tell our impl the new URL - m_pImpl->switchToURL( _rURL, _rURL ); + // success - tell our impl + m_pImpl->attachResource( _rURL, aMediaDescriptor ); // create a document event (mutex still locked) document::EventObject aEvent( *this, ::rtl::OUString::createFromAscii( _pAsciiDocumentEventName ) ); @@ -644,9 +653,12 @@ m_pImpl->commitStorages(); // copy own storage to target storage + if ( m_pImpl->isInitialized() ) + { Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW ); if ( xCurrentStorage != _rxTargetStorage ) xCurrentStorage->copyToStorage( _rxTargetStorage ); + } // write into target storage ::comphelper::NamedValueCollection aWriteArgs( _rMediaDescriptor ); @@ -707,7 +719,7 @@ // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseDocument::setModified( sal_Bool _bModified ) throw (PropertyVetoException, RuntimeException) { - ModelMethodGuard aGuard( *this ); + ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit ); impl_setModified_throw( _bModified, aGuard ); } @@ -745,17 +757,6 @@ } // ----------------------------------------------------------------------------- -void SAL_CALL ODatabaseDocument::notifyEvent( const document::EventObject& _rEvent ) throw (RuntimeException) -{ - ModelMethodGuard aGuard( *this ); - // used only to forward external events (e.g. for doc creation) from the frame loader - // to the global event broadcaster and all other interested doc event listener. - document::EventObject aEvent( *this, _rEvent.EventName ); - aGuard.clear(); - impl_notifyEvent_nolck_nothrow( aEvent ); -} - -// ----------------------------------------------------------------------------- Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getPrinter( ) throw (RuntimeException) { DBG_ERROR( "ODatabaseDocument::getPrinter: not supported!" ); @@ -795,9 +796,6 @@ // ----------------------------------------------------------------------------- Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType ) { - ModelMethodGuard aGuard( *this ); - OSL_POSTCOND( m_pImpl.is(), "ODatabaseDocument::impl_getDocumentContainer_throw: Impl is NULL" ); - if ( ( _eType != ODatabaseModelImpl::E_FORM ) && ( _eType != ODatabaseModelImpl::E_REPORT ) ) throw IllegalArgumentException(); @@ -906,11 +904,13 @@ // ----------------------------------------------------------------------------- Reference< XNameAccess > SAL_CALL ODatabaseDocument::getFormDocuments( ) throw (RuntimeException) { + ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit ); return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_FORM ); } // ----------------------------------------------------------------------------- Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) throw (RuntimeException) { + ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit ); return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_REPORT ); } @@ -1070,7 +1070,7 @@ { try { - m_aDocEventListeners.notifyEach( &XEventListener::notifyEvent, _rEvent ); + m_aDocEventListeners.notifyEach( &document::XEventListener::notifyEvent, _rEvent ); } catch(const Exception&) { @@ -1169,7 +1169,7 @@ ODatabaseContext* pContext = reinterpret_cast< ODatabaseContext* >( xDBContextTunnel->getSomething( ODatabaseContext::getUnoTunnelImplementationId() ) ); ::rtl::Reference<ODatabaseModelImpl> pImpl( new ODatabaseModelImpl( aContext.getLegacyServiceFactory(), *pContext ) ); - Reference< XModel > xModel( pImpl->createNewModel_deliverOwnership() ); + Reference< XModel > xModel( pImpl->createNewModel_deliverOwnership( false ) ); return xModel.get(); } @@ -1190,9 +1190,8 @@ // ----------------------------------------------------------------------------- Reference< XDataSource > SAL_CALL ODatabaseDocument::getDataSource() throw (RuntimeException) { - ModelMethodGuard aGuard( *this ); - OSL_ENSURE(m_pImpl.is(),"Impl is NULL"); - return m_pImpl->getDataSource(); + ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit ); + return m_pImpl->getOrCreateDataSource(); } // ----------------------------------------------------------------------------- @@ -1379,8 +1378,6 @@ //============================================================================= Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw() { - ModelMethodGuard aGuard( *this ); - if ( ! m_xTitleHelper.is ()) { Reference< XUntitledNumbers > xDesktop( @@ -1400,8 +1397,6 @@ //============================================================================= uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHelper_throw(const uno::Reference< uno::XInterface >& _xComponent) { - ModelMethodGuard aGuard( *this ); - if ( !m_xModuleManager.is() ) m_xModuleManager.set( m_pImpl->m_aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW ); @@ -1441,7 +1436,6 @@ { // SYNCHRONIZED -> ModelMethodGuard aGuard( *this ); - return impl_getTitleHelper_throw()->getTitle (); } @@ -1452,7 +1446,6 @@ { // SYNCHRONIZED -> ModelMethodGuard aGuard( *this ); - impl_getTitleHelper_throw()->setTitle (sTitle); } @@ -1488,9 +1481,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException ) { - // object already disposed? ModelMethodGuard aGuard( *this ); - return impl_getUntitledHelper_throw(xComponent)->leaseNumber (xComponent); } @@ -1500,9 +1491,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException ) { - // object already disposed? ModelMethodGuard aGuard( *this ); - impl_getUntitledHelper_throw()->releaseNumber (nNumber); } @@ -1512,7 +1501,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException ) { - // object already disposed? ModelMethodGuard aGuard( *this ); impl_getUntitledHelper_throw(xComponent)->releaseNumberForComponent (xComponent); } File [changed]: databasedocument.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.hxx?r1=1.20.2.4&r2=1.20.2.5 Delta lines: +7 -7 ------------------- --- databasedocument.hxx 2008-07-22 06:31:37+0000 1.20.2.4 +++ databasedocument.hxx 2008-07-23 10:03:31+0000 1.20.2.5 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: databasedocument.hxx,v $ - * $Revision: 1.20.2.4 $ + * $Revision: 1.20.2.5 $ * * This file is part of OpenOffice.org. * @@ -46,7 +46,6 @@ #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/view/XPrintable.hpp> #include <com/sun/star/frame/XModuleManager.hpp> -#include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> @@ -57,6 +56,7 @@ #include <com/sun/star/document/XScriptInvocationContext.hpp> #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> +#include <com/sun/star/frame/XLoadable.hpp> /** === end UNO includes === **/ #if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_15) @@ -92,7 +92,6 @@ , ::com::sun::star::util::XModifiable , ::com::sun::star::frame::XStorable , ::com::sun::star::document::XEventBroadcaster - , ::com::sun::star::document::XEventListener , ::com::sun::star::view::XPrintable , ::com::sun::star::util::XCloseable , ::com::sun::star::lang::XServiceInfo @@ -103,6 +102,7 @@ , ::com::sun::star::document::XScriptInvocationContext , ::com::sun::star::script::provider::XScriptProviderSupplier , ::com::sun::star::document::XEventsSupplier + , ::com::sun::star::frame::XLoadable > ODatabaseDocument_OfficeDocument; typedef ::cppu::ImplHelper3< ::com::sun::star::frame::XTitle @@ -287,10 +287,6 @@ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); -// ::com::sun::star::document::XEventListener - virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::view::XPrintable virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter( ) throw (::com::sun::star::uno::RuntimeException) ; 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) ; @@ -339,6 +335,10 @@ // XEventsSupplier virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException); + // XLoadable + 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); + 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); + // XTitle virtual ::rtl::OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setTitle( const ::rtl::OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
