summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-03-15 20:54:02 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-07-06 20:29:12 +0100
commit511845e09c1f3404c99d5ce0075024994fdba020 (patch)
tree564fb3301d82909c72ef6e40fec550c1b601599e /framework
parentfc68fb4bb4198e7fca395309e721030247d869aa (diff)
fs34b: #i117039# restore old behavior of SfxUndoManager::EnableUndo
don't count the calls, but maintain a simple flag. Consequently, let sw's UndoManager simply delegate now, and change the UndoManagerHelper to maintain a lock counter itself. Conflicts: framework/source/fwe/helper/undomanagerhelper.cxx
Diffstat (limited to 'framework')
-rw-r--r--framework/source/fwe/helper/undomanagerhelper.cxx52
1 files changed, 38 insertions, 14 deletions
diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx
index 926e783b8d7f..86260a98c7ce 100644
--- a/framework/source/fwe/helper/undomanagerhelper.cxx
+++ b/framework/source/fwe/helper/undomanagerhelper.cxx
@@ -218,6 +218,7 @@ namespace framework
bool m_disposed;
bool m_bAPIActionRunning;
bool m_bProcessingEvents;
+ sal_Int32 m_nLockCount;
::cppu::OInterfaceContainerHelper m_aUndoListeners;
::cppu::OInterfaceContainerHelper m_aModifyListeners;
IUndoManagerImplementation& m_rUndoManagerImplementation;
@@ -239,6 +240,7 @@ namespace framework
,m_disposed( false )
,m_bAPIActionRunning( false )
,m_bProcessingEvents( false )
+ ,m_nLockCount( 0 )
,m_aUndoListeners( m_aMutex )
,m_aModifyListeners( m_aMutex )
,m_rUndoManagerImplementation( i_undoManagerImpl )
@@ -288,6 +290,9 @@ namespace framework
void clearRedo( IMutexGuard& i_instanceLock );
void reset( IMutexGuard& i_instanceLock );
+ void lock();
+ void unlock();
+
void addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener )
{
m_aUndoListeners.addInterface( i_listener );
@@ -478,6 +483,37 @@ namespace framework
}
//------------------------------------------------------------------------------------------------------------------
+ void UndoManagerHelper_Impl::lock()
+ {
+ // SYNCHRONIZED --->
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( ++m_nLockCount == 1 )
+ {
+ IUndoManager& rUndoManager = getUndoManager();
+ rUndoManager.EnableUndo( false );
+ }
+ // <--- SYNCHRONIZED
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UndoManagerHelper_Impl::unlock()
+ {
+ // SYNCHRONIZED --->
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( m_nLockCount == 0 )
+ throw NotLockedException( "Undo manager is not locked", getXUndoManager() );
+
+ if ( --m_nLockCount == 0 )
+ {
+ IUndoManager& rUndoManager = getUndoManager();
+ rUndoManager.EnableUndo( true );
+ }
+ // <--- SYNCHRONIZED
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void UndoManagerHelper_Impl::impl_processRequest( ::boost::function0< void > const& i_request, IMutexGuard& i_instanceLock )
{
// create the request, and add it to our queue
@@ -1098,25 +1134,13 @@ namespace framework
//------------------------------------------------------------------------------------------------------------------
void UndoManagerHelper::lock()
{
- // SYNCHRONIZED --->
- ::osl::MutexGuard aGuard( m_pImpl->getMutex() );
-
- IUndoManager& rUndoManager = m_pImpl->getUndoManager();
- rUndoManager.EnableUndo( false );
- // <--- SYNCHRONIZED
+ m_pImpl->lock();
}
//------------------------------------------------------------------------------------------------------------------
void UndoManagerHelper::unlock()
{
- // SYNCHRONIZED --->
- ::osl::MutexGuard aGuard( m_pImpl->getMutex() );
-
- IUndoManager& rUndoManager = m_pImpl->getUndoManager();
- if ( rUndoManager.IsUndoEnabled() )
- throw NotLockedException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Undo manager is not locked" )), m_pImpl->getXUndoManager() );
- rUndoManager.EnableUndo( true );
- // <--- SYNCHRONIZED
+ m_pImpl->unlock();
}
//------------------------------------------------------------------------------------------------------------------