From 2d71dd52b6d91660cda6cb8f9457463439f56e20 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 Jul 2018 09:42:07 +0200 Subject: merge IUndoManager into SfxUndoManager SfxUndoManager is the only implementation of the IUnderManager "interface", and it lives in the same header. Plus this way we can get rid of some covariant parameters, which will make using std::unique_ptr easier. Change-Id: I6661b9876b18da830bead78794d237886cd3c5c9 Reviewed-on: https://gerrit.libreoffice.org/57317 Tested-by: Jenkins Reviewed-by: Noel Grandin --- framework/source/fwe/helper/undomanagerhelper.cxx | 63 +++++++++++------------ 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'framework/source') diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx index 65f350b88a30..656d1f05d26b 100644 --- a/framework/source/fwe/helper/undomanagerhelper.cxx +++ b/framework/source/fwe/helper/undomanagerhelper.cxx @@ -61,7 +61,6 @@ namespace framework using ::com::sun::star::util::InvalidStateException; using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::util::XModifyListener; - using ::svl::IUndoManager; //= UndoActionWrapper @@ -226,7 +225,7 @@ namespace framework { } - IUndoManager& getUndoManager() const + SfxUndoManager& getUndoManager() const { return m_rUndoManagerImplementation.getImplUndoManager(); } @@ -339,7 +338,7 @@ namespace framework const UndoManagerEvent aEvent( buildEvent( i_title ) ); // TODO: this notification method here is used by UndoManagerHelper_Impl, to multiplex the notifications we - // receive from the IUndoManager. Those notifications are sent with a locked SolarMutex, which means + // receive from the SfxUndoManager. Those notifications are sent with a locked SolarMutex, which means // we're doing the multiplexing here with a locked SM, too. Which is Bad (TM). // Fixing this properly would require outsourcing all the notifications into an own thread - which might lead // to problems of its own, since clients might expect synchronous notifications. @@ -420,7 +419,7 @@ namespace framework if ( ++m_nLockCount == 1 ) { - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); rUndoManager.EnableUndo( false ); } // <--- SYNCHRONIZED @@ -436,7 +435,7 @@ namespace framework if ( --m_nLockCount == 0 ) { - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); rUndoManager.EnableUndo( true ); } // <--- SYNCHRONIZED @@ -508,7 +507,7 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); if ( !rUndoManager.IsUndoEnabled() ) // ignore this request if the manager is locked return; @@ -539,7 +538,7 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); if ( !rUndoManager.IsUndoEnabled() ) // ignore this request if the manager is locked return; @@ -555,7 +554,7 @@ namespace framework const bool isHiddenContext = m_aContextVisibilities.top(); m_aContextVisibilities.pop(); - const bool bHadRedoActions = ( rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ) > 0 ); + const bool bHadRedoActions = ( rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel ) > 0 ); { ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); if ( isHiddenContext ) @@ -563,7 +562,7 @@ namespace framework else nContextElements = rUndoManager.LeaveListAction(); } - const bool bHasRedoActions = ( rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ) > 0 ); + const bool bHasRedoActions = ( rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel ) > 0 ); // prepare notification void ( SAL_CALL XUndoManagerListener::*notificationMethod )( const UndoManagerEvent& ) = nullptr; @@ -602,13 +601,13 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); if ( rUndoManager.IsInListAction() ) throw UndoContextNotClosedException( OUString(), getXUndoManager() ); const size_t nElements = i_undo - ? rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) - : rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ); + ? rUndoManager.GetUndoActionCount( SfxUndoManager::TopLevel ) + : rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel ); if ( nElements == 0 ) throw EmptyUndoStackException("stack is empty", getXUndoManager() ); @@ -632,7 +631,7 @@ namespace framework } // note that in opposite to all of the other methods, we do *not* have our mutex locked when calling - // into the IUndoManager implementation. This ensures that an actual XUndoAction::undo/redo is also + // into the SfxUndoManager implementation. This ensures that an actual XUndoAction::undo/redo is also // called without our mutex being locked. // As a consequence, we do not set m_bAPIActionRunning here. Instead, our actionUndone/actionRedone methods // *always* multiplex the event to our XUndoManagerListeners, not only when m_bAPIActionRunning is FALSE (This @@ -645,7 +644,7 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); if ( !rUndoManager.IsUndoEnabled() ) // ignore the request if the manager is locked return; @@ -674,7 +673,7 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); if ( rUndoManager.IsInListAction() ) throw UndoContextNotClosedException( OUString(), getXUndoManager() ); @@ -696,7 +695,7 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); if ( rUndoManager.IsInListAction() ) throw UndoContextNotClosedException( OUString(), getXUndoManager() ); @@ -718,7 +717,7 @@ namespace framework // SYNCHRONIZED ---> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - IUndoManager& rUndoManager = getUndoManager(); + SfxUndoManager& rUndoManager = getUndoManager(); { ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning ); rUndoManager.Reset(); @@ -895,10 +894,10 @@ namespace framework { // SYNCHRONIZED ---> ::osl::MutexGuard aGuard( m_xImpl->getMutex() ); - IUndoManager& rUndoManager = m_xImpl->getUndoManager(); + SfxUndoManager& rUndoManager = m_xImpl->getUndoManager(); if ( rUndoManager.IsInListAction() ) return false; - return rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) > 0; + return rUndoManager.GetUndoActionCount( SfxUndoManager::TopLevel ) > 0; // <--- SYNCHRONIZED } @@ -906,10 +905,10 @@ namespace framework { // SYNCHRONIZED ---> ::osl::MutexGuard aGuard( m_xImpl->getMutex() ); - const IUndoManager& rUndoManager = m_xImpl->getUndoManager(); + const SfxUndoManager& rUndoManager = m_xImpl->getUndoManager(); if ( rUndoManager.IsInListAction() ) return false; - return rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ) > 0; + return rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel ) > 0; // <--- SYNCHRONIZED } @@ -921,10 +920,10 @@ namespace framework // SYNCHRONIZED ---> ::osl::MutexGuard aGuard( i_impl.getMutex() ); - const IUndoManager& rUndoManager = i_impl.getUndoManager(); + const SfxUndoManager& rUndoManager = i_impl.getUndoManager(); const size_t nActionCount = i_undo - ? rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) - : rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ); + ? rUndoManager.GetUndoActionCount( SfxUndoManager::TopLevel ) + : rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel ); if ( nActionCount == 0 ) throw EmptyUndoStackException( i_undo ? OUString( "no action on the undo stack" ) @@ -932,8 +931,8 @@ namespace framework i_impl.getXUndoManager() ); return i_undo - ? rUndoManager.GetUndoActionComment( 0, IUndoManager::TopLevel ) - : rUndoManager.GetRedoActionComment( 0, IUndoManager::TopLevel ); + ? rUndoManager.GetUndoActionComment( 0, SfxUndoManager::TopLevel ) + : rUndoManager.GetRedoActionComment( 0, SfxUndoManager::TopLevel ); // <--- SYNCHRONIZED } @@ -942,17 +941,17 @@ namespace framework // SYNCHRONIZED ---> ::osl::MutexGuard aGuard( i_impl.getMutex() ); - const IUndoManager& rUndoManager = i_impl.getUndoManager(); + const SfxUndoManager& rUndoManager = i_impl.getUndoManager(); const size_t nCount = i_undo - ? rUndoManager.GetUndoActionCount( IUndoManager::TopLevel ) - : rUndoManager.GetRedoActionCount( IUndoManager::TopLevel ); + ? rUndoManager.GetUndoActionCount( SfxUndoManager::TopLevel ) + : rUndoManager.GetRedoActionCount( SfxUndoManager::TopLevel ); Sequence< OUString > aTitles( nCount ); for ( size_t i=0; i ::osl::MutexGuard aGuard( m_xImpl->getMutex() ); - IUndoManager& rUndoManager = m_xImpl->getUndoManager(); + SfxUndoManager& rUndoManager = m_xImpl->getUndoManager(); return !rUndoManager.IsUndoEnabled(); // <--- SYNCHRONIZED } -- cgit