Tag: cws_dev300_odbmacros3 User: fs Date: 2008-07-29 07:10:57+0000 Modified: dba/dbaccess/source/core/dataaccess/databasedocument.cxx dba/dbaccess/source/core/dataaccess/databasedocument.hxx
Log: #i76128# more event notifying File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: databasedocument.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.40.6.12&r2=1.40.6.13 Delta lines: +60 -29 --------------------- --- databasedocument.cxx 2008-07-28 06:25:00+0000 1.40.6.12 +++ databasedocument.cxx 2008-07-29 07:10:54+0000 1.40.6.13 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: databasedocument.cxx,v $ - * $Revision: 1.40.6.12 $ + * $Revision: 1.40.6.13 $ * * This file is part of OpenOffice.org. * @@ -132,7 +132,7 @@ // notify the respective events if ( bLoadFinished ) - m_rEventNotifier.notifyDocumentEventAsync( "OnLoad" ); + m_rEventNotifier.notifyDocumentEventAsync( m_bIsNewDocument ? "OnNew" : "OnLoad" ); if ( bViewCreated ) m_rEventNotifier.notifyDocumentEventAsync( "OnViewCreated" ); } @@ -385,6 +385,8 @@ m_pImpl->setInitialized(); + m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" ); + impl_setModified_nothrow( sal_False, aGuard ); // <- SYNCHRONIZED @@ -486,11 +488,6 @@ if ( m_aControllers.empty() ) { - // reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource - // object still exists), and somebody subsequently re-opens the document, we want to have - // the security warning, again. - m_pImpl->resetMacroExecutionMode(); - // if this was the last view, close the document as a whole // #i51157# / 2006-03-16 / [EMAIL PROTECTED] try @@ -608,6 +605,9 @@ try { + ModifyLock aLock( *this ); + // ignore all changes of our "modified" state during storing + sal_Bool bLocationChanged = ( _rURL != m_pImpl->getLocation() ); if ( bLocationChanged ) { @@ -657,8 +657,10 @@ // reset our "modified" flag, and clear the guard impl_setModified_nothrow( sal_False, _rGuard ); + // <- SYNCHRONIZED // notify storage listeners + if ( xNewRootStorage.is() ) impl_notifyStorageChange_nolck_nothrow( xNewRootStorage ); } @@ -693,12 +695,29 @@ try { impl_storeAs_throw( _rURL, _rArguments, SAVE_AS, aGuard ); + // <- SYNCHRONIZED + + // impl_storeAs_throw cleared the lock on our mutex, but the below lines need this lock + // SYNCHRONIZED -> + aGuard.reset(); + + // our title might have changed, potentially at least + // Sadly, we cannot check this: Calling getTitle here and now would not deliver + // an up-to-date result, as the call is delegated to our TitleHelper instance, which itself + // updates its title only if it gets the OnSaveAsDone event (which was sent asynchronously + // by impl_storeAs_throw). So, we simply notify always, and also asynchronously + m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" ); + + // tell our view monitor that the document has been loaded - this way it will fire the proper + // even (OnLoad instead of OnCreate) later on + m_aViewMonitor.onLoadedDocument(); } catch( const Exception& ) { impl_reset_nothrow(); throw; } + aGuard.clear(); // <- SYNCHRONIZED if ( bImplicitInitialization ) @@ -793,19 +812,22 @@ // ----------------------------------------------------------------------------- void ODatabaseDocument::impl_setModified_nothrow( sal_Bool _bModified, ModelMethodGuard& _rGuard ) { - if ( m_pImpl->m_bModified == _bModified ) - return; - - if ( m_pImpl->isModifyLocked() ) - return; + // SYNCHRONIZED -> + bool bModifiedChanged = ( m_pImpl->m_bModified != _bModified ) && ( !m_pImpl->isModifyLocked() ); + if ( bModifiedChanged ) + { m_pImpl->m_bModified = _bModified; - m_aEventNotifier.notifyDocumentEventAsync( "OnModifyChanged" ); - + } _rGuard.clear(); + // <- SYNCHRONIZED + + if ( bModifiedChanged ) + { lang::EventObject aEvent( *this ); m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent ); + } } // ----------------------------------------------------------------------------- @@ -1171,6 +1193,15 @@ clearObjectContainer( m_xForms ); clearObjectContainer( m_xReports ); + // reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource + // object still exists), and somebody subsequently re-opens the document, we want to have + // the security warning, again. + m_pImpl->resetMacroExecutionMode(); + + // similar argueing for our ViewMonitor + m_aViewMonitor.reset(); + + // tell our Impl to forget us m_pImpl->modelIsDisposing( ODatabaseModelImpl::ResetModelAccess() ); // now, at the latest, the controller array should be empty. Controllers are @@ -1493,8 +1524,8 @@ throw (uno::RuntimeException) { // SYNCHRONIZED -> - ModelMethodGuard aGuard( *this ); - return impl_getTitleHelper_throw()->getTitle (); + ModelMethodGuard aGuard( *this, ModelMethodGuard::MethodUsedDuringInit ); + return impl_getTitleHelper_throw()->getTitle(); } //============================================================================= @@ -1504,7 +1535,9 @@ { // SYNCHRONIZED -> ModelMethodGuard aGuard( *this ); - impl_getTitleHelper_throw()->setTitle (sTitle); + impl_getTitleHelper_throw()->setTitle( sTitle ); + m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" ); + // <- SYNCHRONIZED } //============================================================================= @@ -1515,9 +1548,8 @@ // SYNCHRONIZED -> ModelMethodGuard aGuard( *this ); - uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY); - if (xBroadcaster.is ()) - xBroadcaster->addTitleChangeListener (xListener); + uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW ); + xBroadcaster->addTitleChangeListener( xListener ); } //============================================================================= @@ -1528,9 +1560,8 @@ // SYNCHRONIZED -> ModelMethodGuard aGuard( *this ); - uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY); - if (xBroadcaster.is ()) - xBroadcaster->removeTitleChangeListener (xListener); + uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW ); + xBroadcaster->removeTitleChangeListener( xListener ); } //============================================================================= File [changed]: databasedocument.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.hxx?r1=1.20.2.7&r2=1.20.2.8 Delta lines: +27 -3 -------------------- --- databasedocument.hxx 2008-07-28 06:25:00+0000 1.20.2.7 +++ databasedocument.hxx 2008-07-29 07:10:54+0000 1.20.2.8 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: databasedocument.hxx,v $ - * $Revision: 1.20.2.7 $ + * $Revision: 1.20.2.8 $ * * This file is part of OpenOffice.org. * @@ -71,6 +71,7 @@ #include <rtl/ref.hxx> #include <boost/shared_ptr.hpp> +#include <boost/noncopyable.hpp> namespace comphelper { class NamedValueCollection; @@ -92,17 +93,25 @@ /** helper class monitoring the views of a document, and firing appropriate events when views are attached / detached */ -class ViewMonitor +class ViewMonitor : public boost::noncopyable { public: ViewMonitor( DocumentEventNotifier& _rEventNotifier ) :m_rEventNotifier( _rEventNotifier ) + ,m_bIsNewDocument( true ) ,m_bEverHadController( false ) ,m_bLastIsFirstEverController( false ) ,m_xLastConnectedController() { } + void reset() + { + m_bEverHadController = false; + m_bLastIsFirstEverController = false; + m_xLastConnectedController.clear(); + } + /** to be called when a view (aka controller) has been connected to the document @return <TRUE/> if and only if this was the first-ever controller connected to the document @@ -117,8 +126,11 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController ); + void onLoadedDocument() { m_bIsNewDocument = false; } + private: DocumentEventNotifier& m_rEventNotifier; + bool m_bIsNewDocument; bool m_bEverHadController; bool m_bLastIsFirstEverController; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > @@ -472,7 +484,19 @@ const ::rtl::OUString& _rURL ) const; - /** clears the guard before notifying. + /** sets our "modified" flag + + will notify all our respective listeners, if the "modified" state actually changed + + @param _bModified + the (new) flag indicating whether the document is currently modified or not + @param _rGuard + the guard for our instance. At method entry, the guard must hold the lock. At the moment + of method leave, the lock will be released. + @precond + our mutex is locked + @postcond + our mutex is not locked */ void impl_setModified_nothrow( sal_Bool _bModified, ModelMethodGuard& _rGuard ); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
