diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2015-12-22 13:12:23 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2015-12-23 09:38:25 +0000 |
commit | 22328a224df4619218b88205838307f70612207e (patch) | |
tree | 251c9aaf8ab1b1db5cf80af9c8644d6cacd6d897 /dbaccess | |
parent | 2351fd5d489fde281e8d1ef97af747149a29c247 (diff) |
New saving behavior
Changes in this commit:
- AlwaysAllowSave config is gone. Saving is always permitted, unless in
a read only document. Also changed the behavior in dbaccess to match
sfx2.
- The toolbar save button is always enabled, to always give access to
the dropdown. That's the case even in a read only document, except
that it changes to DROPDOWNONLY, and the save as command icon+tooltip.
In table/query designers we still disable the button in read only state.
- When the document is modified, the toolbar button gets a special icon
to indicate that.
TODO:
- Icons for the document modified state are still missing. I added some
fake links to Tango's links.txt in order to test the new behavior.
These links shouldn't stay as-is in a production version!
Change-Id: I56c169bf48b78faaf53c2989ce8624f8297ffb6e
Reviewed-on: https://gerrit.libreoffice.org/20839
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/intercept.cxx | 54 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/intercept.hxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/app/AppController.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/app/AppController.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableController.cxx | 10 |
6 files changed, 7 insertions, 72 deletions
diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx index 09f7ab59fdcd..ef3713e143dd 100644 --- a/dbaccess/source/core/dataaccess/intercept.cxx +++ b/dbaccess/source/core/dataaccess/intercept.cxx @@ -22,7 +22,6 @@ #include "dbastrings.hrc" #include <com/sun/star/embed/EmbedStates.hpp> -#include <com/sun/star/document/XDocumentEventBroadcaster.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <cppuhelper/weak.hxx> @@ -187,10 +186,6 @@ IMPL_LINK_TYPED( OInterceptor, OnDispatch, void*, _pDispatcher, void ) Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch(pHelper->aURL, "_self", 0 ); if ( xDispatch.is() ) { - Reference< css::document::XDocumentEventBroadcaster> xEvtB(m_pContentHolder->getComponent(),UNO_QUERY); - if ( xEvtB.is() ) - xEvtB->removeDocumentEventListener(this); - Reference< XInterface > xKeepContentHolderAlive( *m_pContentHolder ); xDispatch->dispatch( pHelper->aURL,pHelper->aArguments); } @@ -240,7 +235,7 @@ void SAL_CALL OInterceptor::addStatusListener( FeatureStateEvent aStateEvent; aStateEvent.FeatureURL.Complete = m_aInterceptedURL[DISPATCH_SAVE]; aStateEvent.FeatureDescriptor = "Update"; - aStateEvent.IsEnabled = m_pContentHolder != nullptr && m_pContentHolder->isModified(); + aStateEvent.IsEnabled = sal_True; aStateEvent.Requery = sal_False; Control->statusChanged(aStateEvent); @@ -251,9 +246,6 @@ void SAL_CALL OInterceptor::addStatusListener( } m_pStatCL->addInterface(_URL.Complete,Control); - Reference< css::document::XDocumentEventBroadcaster> xEvtB(m_pContentHolder->getComponent(),UNO_QUERY); - if ( xEvtB.is() ) - xEvtB->addDocumentEventListener(this); } else { @@ -395,50 +387,6 @@ void SAL_CALL OInterceptor::setMasterDispatchProvider( m_xMasterDispatchProvider = NewSupplier; } -void SAL_CALL OInterceptor::documentEventOccured( const css::document::DocumentEvent& Event ) throw (css::uno::RuntimeException, std::exception) -{ - osl::ResettableMutexGuard _rGuard(m_aMutex); - if ( m_pStatCL && Event.EventName == "OnModifyChanged" ) - { - OInterfaceContainerHelper* pListener = m_pStatCL->getContainer(m_aInterceptedURL[DISPATCH_SAVE]); - if ( pListener ) - { - FeatureStateEvent aEvt; - aEvt.FeatureURL.Complete = m_aInterceptedURL[DISPATCH_SAVE]; - aEvt.FeatureDescriptor = "Update"; - Reference<XModifiable> xModel(Event.Source,UNO_QUERY); - aEvt.IsEnabled = xModel.is() && xModel->isModified(); - aEvt.Requery = sal_False; - - Sequence< Reference< XInterface > > aListenerSeq = pListener->getElements(); - - const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); - const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); - - _rGuard.clear(); - while( pxInt > pxIntBegin ) - { - try - { - while( pxInt > pxIntBegin ) - { - --pxInt; - static_cast< XStatusListener* >( pxInt->get() )->statusChanged(aEvt); - } - } - catch( RuntimeException& ) - { - } - } - _rGuard.reset(); - } - } -} - -void SAL_CALL OInterceptor::disposing( const css::lang::EventObject& /*Source*/ ) throw (css::uno::RuntimeException, std::exception) -{ -} - } // namespace dbaccess /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/dataaccess/intercept.hxx b/dbaccess/source/core/dataaccess/intercept.hxx index 48c8ae002c32..6d80e4f444eb 100644 --- a/dbaccess/source/core/dataaccess/intercept.hxx +++ b/dbaccess/source/core/dataaccess/intercept.hxx @@ -25,7 +25,6 @@ #include <cppuhelper/interfacecontainer.hxx> #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> #include <com/sun/star/frame/XInterceptorInfo.hpp> -#include <com/sun/star/document/XDocumentEventListener.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include "documentdefinition.hxx" #include <vcl/svapp.hxx> @@ -36,8 +35,7 @@ namespace dbaccess class OInterceptor : public ::cppu::WeakImplHelper< css::frame::XDispatchProviderInterceptor, css::frame::XInterceptorInfo, - css::frame::XDispatch, - css::document::XDocumentEventListener> + css::frame::XDispatch > { DECL_LINK_TYPED( OnDispatch, void*, void ); protected: @@ -122,10 +120,6 @@ public: css::uno::RuntimeException, std::exception ) override; - // XDocumentEventListener - virtual void SAL_CALL documentEventOccured( const css::document::DocumentEvent& Event ) throw (css::uno::RuntimeException, std::exception) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw (css::uno::RuntimeException, std::exception) override; - private: osl::Mutex m_aMutex; diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 01a8f9435612..5d1d893e3775 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -599,7 +599,7 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = true; break; case ID_BROWSER_SAVEDOC: - aReturn.bEnabled = !isDataSourceReadOnly() && m_xDocumentModify.is() && m_xDocumentModify->isModified(); + aReturn.bEnabled = !isDataSourceReadOnly(); break; case ID_BROWSER_SAVEASDOC: aReturn.bEnabled = true; @@ -2659,7 +2659,6 @@ sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > } m_xModel = _rxModel; - m_xDocumentModify = xDocModify; m_xDataSource.set( xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference< XDataSource >(), UNO_QUERY ); // connect to new model diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx index cc7bcf1ac543..ad9cafae96dc 100644 --- a/dbaccess/source/ui/app/AppController.hxx +++ b/dbaccess/source/ui/app/AppController.hxx @@ -99,8 +99,6 @@ namespace dbaui m_xDataSource; css::uno::Reference< css::frame::XModel > m_xModel; - css::uno::Reference< css::util::XModifiable > - m_xDocumentModify; ::cppu::OInterfaceContainerHelper m_aContextMenuInterceptors; diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 52c76f11ab38..cc9b7d8b4c39 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -496,7 +496,7 @@ FeatureState OQueryController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = !editingCommand() && !editingView() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty())); break; case ID_BROWSER_SAVEDOC: - aReturn.bEnabled = impl_isModified() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty())); + aReturn.bEnabled = isEditable() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty())); break; case SID_PRINTDOCDIRECT: break; diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 26e48f5e5b0f..2feca27ed36e 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -190,15 +190,10 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const break; case ID_BROWSER_EDITDOC: aReturn.bChecked = isEditable(); - aReturn.bEnabled = m_bNew || isEditable();// the editable flag is set through this one -> || isAddAllowed() || isDropAllowed() || isAlterAllowed(); + aReturn.bEnabled = true; break; case ID_BROWSER_SAVEDOC: - aReturn.bEnabled = impl_isModified(); - if ( aReturn.bEnabled ) - { - aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(), - ::boost::mem_fn(&OTableRow::isValid)); - } + aReturn.bEnabled = isEditable() && ::std::any_of(m_vRowList.begin(),m_vRowList.end(),::boost::mem_fn(&OTableRow::isValid)); break; case ID_BROWSER_SAVEASDOC: aReturn.bEnabled = isConnected() && isEditable(); @@ -244,6 +239,7 @@ void OTableController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& case ID_BROWSER_EDITDOC: setEditable(!isEditable()); static_cast<OTableDesignView*>(getView())->setReadOnly(!isEditable()); + InvalidateFeature(ID_BROWSER_SAVEDOC); InvalidateFeature(ID_BROWSER_PASTE); InvalidateFeature(SID_BROWSER_CLEAR_QUERY); break; |