diff options
Diffstat (limited to 'dbaccess/source/ui/misc/singledoccontroller.cxx')
-rw-r--r-- | dbaccess/source/ui/misc/singledoccontroller.cxx | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx index 43dadd489884..87ddfa1f197b 100644 --- a/dbaccess/source/ui/misc/singledoccontroller.cxx +++ b/dbaccess/source/ui/misc/singledoccontroller.cxx @@ -94,6 +94,7 @@ namespace dbaui using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::frame::XUntitledNumbers; + using ::com::sun::star::beans::PropertyVetoException; /** === end UNO using === **/ class DataSourceHolder @@ -140,6 +141,9 @@ namespace dbaui OModuleClient m_aModuleClient; ::dbtools::SQLExceptionInfo m_aCurrentError; // contains the current error which can be set through IEnvironment + ::cppu::OInterfaceContainerHelper + m_aModifyListeners; + // <properties> SharedConnection m_xConnection; ::dbtools::DatabaseMetaData m_aSdbMetaData; @@ -154,8 +158,9 @@ namespace dbaui sal_Bool m_bModified; // is the data modified bool m_bNotAttached; - OSingleDocumentControllerImpl() + OSingleDocumentControllerImpl( ::osl::Mutex& i_rMutex ) :m_aDocScriptSupport() + ,m_aModifyListeners( i_rMutex ) ,m_nDocStartNumber(0) ,m_bSuspended( sal_False ) ,m_bEditable(sal_True) @@ -185,7 +190,7 @@ namespace dbaui //-------------------------------------------------------------------- OSingleDocumentController::OSingleDocumentController(const Reference< XMultiServiceFactory >& _rxORB) :OSingleDocumentController_Base( _rxORB ) - ,m_pImpl(new OSingleDocumentControllerImpl()) + ,m_pImpl( new OSingleDocumentControllerImpl( getMutex() ) ) { } @@ -540,15 +545,6 @@ namespace dbaui InvalidateFeature(ID_BROWSER_UNDO); InvalidateFeature(ID_BROWSER_REDO); } - // ----------------------------------------------------------------------------- - void OSingleDocumentController::setModified(sal_Bool _bModified) - { - m_pImpl->m_bModified = _bModified; - InvalidateFeature(ID_BROWSER_SAVEDOC); - - if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) ) - InvalidateFeature(ID_BROWSER_SAVEASDOC); - } // ----------------------------------------------------------------------------- ::rtl::OUString OSingleDocumentController::getDataSourceName() const @@ -591,12 +587,6 @@ namespace dbaui } // ----------------------------------------------------------------------------- - sal_Bool OSingleDocumentController::isModified() const - { - return m_pImpl->m_bModified; - } - - // ----------------------------------------------------------------------------- void OSingleDocumentController::setEditable(sal_Bool _bEditable) { m_pImpl->m_bEditable = _bEditable; @@ -702,6 +692,57 @@ namespace dbaui return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW ); } + // ----------------------------------------------------------------------------- + void SAL_CALL OSingleDocumentController::addModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( getMutex() ); + m_pImpl->m_aModifyListeners.addInterface( i_Listener ); + } + + // ----------------------------------------------------------------------------- + void SAL_CALL OSingleDocumentController::removeModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( getMutex() ); + m_pImpl->m_aModifyListeners.removeInterface( i_Listener ); + } + + // ----------------------------------------------------------------------------- + ::sal_Bool SAL_CALL OSingleDocumentController::isModified( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( getMutex() ); + return impl_isModified(); + } + + // ----------------------------------------------------------------------------- + void SAL_CALL OSingleDocumentController::setModified( ::sal_Bool i_bModified ) throw (PropertyVetoException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( getMutex() ); + + if ( m_pImpl->m_bModified == i_bModified ) + return; + + m_pImpl->m_bModified = i_bModified; + impl_onModifyChanged(); + + EventObject aEvent( *this ); + aGuard.clear(); + m_pImpl->m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent ); + } + + // ----------------------------------------------------------------------------- + sal_Bool OSingleDocumentController::impl_isModified() const + { + return m_pImpl->m_bModified; + } + + // ----------------------------------------------------------------------------- + void OSingleDocumentController::impl_onModifyChanged() + { + InvalidateFeature( ID_BROWSER_SAVEDOC ); + if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) ) + InvalidateFeature( ID_BROWSER_SAVEASDOC ); + } + //........................................................................ } // namespace dbaui //........................................................................ |