summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-12 15:41:15 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-12 15:41:15 +0100
commitb3a06bad053a7e763139783e5a0885d7df6bb54d (patch)
treeb15decdeed482e1a6f4d5b9bb3482822aacd5e12 /sfx2
parentfeb71c2bb3b4d05ad82a62fb56bbd52944d766b4 (diff)
undoapi: delegate UndoManagerHelper's (modifying) API calls into a dedicated thread, serializing them this way
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/sfxbasemodel.hxx7
-rwxr-xr-xsfx2/qa/complex/sfx2/UndoManager.java3
-rwxr-xr-xsfx2/source/doc/docundomanager.cxx121
3 files changed, 89 insertions, 42 deletions
diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx
index 4367810e1675..2ba73f4034fc 100644
--- a/sfx2/inc/sfx2/sfxbasemodel.hxx
+++ b/sfx2/inc/sfx2/sfxbasemodel.hxx
@@ -1616,13 +1616,18 @@ public:
{
}
+ void reset()
+ {
+ m_aGuard.reset();
+ }
+
void clear()
{
m_aGuard.clear();
}
private:
- ::vos::OClearableGuard m_aGuard;
+ ::osl::ResettableGuard< ::vos::IMutex > m_aGuard;
};
#undef css
diff --git a/sfx2/qa/complex/sfx2/UndoManager.java b/sfx2/qa/complex/sfx2/UndoManager.java
index 421111e88f4e..c86ceef5a1ac 100755
--- a/sfx2/qa/complex/sfx2/UndoManager.java
+++ b/sfx2/qa/complex/sfx2/UndoManager.java
@@ -456,6 +456,7 @@ public class UndoManager
public void leftHiddenContext( UndoManagerEvent i_event )
{
assertFalse( "|leftHiddenContext| called after document was disposed", m_isDisposed );
+ assertEquals( "|leftHiddenContext| is not expected to notify an action title", 0, i_event.UndoActionTitle.length() );
m_activeUndoContexts.pop();
assertEquals( "different opinions on the context nesting level (after leaving)",
@@ -467,6 +468,7 @@ public class UndoManager
public void cancelledContext( UndoManagerEvent i_event )
{
assertFalse( "|cancelledContext| called after document was disposed", m_isDisposed );
+ assertEquals( "|cancelledContext| is not expected to notify an action title", 0, i_event.UndoActionTitle.length() );
m_activeUndoContexts.pop();
assertEquals( "different opinions on the context nesting level (after cancelling)",
@@ -590,6 +592,7 @@ public class UndoManager
// close the document, ensure the Undo manager listener gets notified
m_currentDocument.close();
+ m_currentDocument = null;
assertTrue( "document is closed, but the UndoManagerListener has not been notified of the disposal", m_undoListener.isDisposed() );
}
diff --git a/sfx2/source/doc/docundomanager.cxx b/sfx2/source/doc/docundomanager.cxx
index 39534bf9f90c..6fbe1996d85d 100755
--- a/sfx2/source/doc/docundomanager.cxx
+++ b/sfx2/source/doc/docundomanager.cxx
@@ -44,6 +44,7 @@
#include <tools/diagnose_ex.h>
#include <framework/undomanagerhelper.hxx>
+#include <boost/noncopyable.hpp>
#include <stack>
//......................................................................................................................
@@ -103,7 +104,6 @@ namespace sfx2
SfxObjectShell* getObjectShell() { return rAntiImpl.getBaseModel().GetObjectShell(); }
// IUndoManagerImplementation
- virtual ::osl::Mutex& getMutex();
virtual ::svl::IUndoManager& getImplUndoManager();
virtual Reference< XUndoManager > getThis();
@@ -131,12 +131,6 @@ namespace sfx2
};
//------------------------------------------------------------------------------------------------------------------
- ::osl::Mutex& DocumentUndoManager_Impl::getMutex()
- {
- return rAntiImpl.getMutex();
- }
-
- //------------------------------------------------------------------------------------------------------------------
::svl::IUndoManager& DocumentUndoManager_Impl::getImplUndoManager()
{
ENSURE_OR_THROW( pUndoManager != NULL, "DocumentUndoManager_Impl::getImplUndoManager: no access to the doc's UndoManager implementation!" );
@@ -193,23 +187,65 @@ namespace sfx2
}
//==================================================================================================================
- //= SfxModelGuardFacade
+ //= SolarMutexFacade
+ //==================================================================================================================
+ /** a facade for the SolarMutex, implementing ::framework::IMutex (as opposed to ::vos::IMutex)
+ */
+ class SolarMutexFacade : public ::framework::IMutex
+ {
+ public:
+ SolarMutexFacade()
+ {
+ }
+
+ virtual void acquire()
+ {
+ Application::GetSolarMutex().acquire();
+ }
+
+ virtual void release()
+ {
+ Application::GetSolarMutex().release();
+ }
+ };
+
+ //==================================================================================================================
+ //= UndoManagerGuard
//==================================================================================================================
- class SfxModelGuardFacade : public ::framework::IClearableInstanceLock
+ class UndoManagerGuard :public ::framework::IMutexGuard
+ ,public ::boost::noncopyable
{
public:
- SfxModelGuardFacade( SfxModelGuard& i_guard )
- :m_guard( i_guard )
+ UndoManagerGuard( DocumentUndoManager& i_undoManager )
+ :m_guard( i_undoManager )
+ ,m_solarMutexFacade()
+ {
+ }
+
+ ~UndoManagerGuard()
{
}
+ virtual void reset()
+ {
+ m_guard.reset();
+ }
+
virtual void clear()
{
m_guard.clear();
}
+ virtual ::framework::IMutex& getGuardedMutex()
+ {
+ // note that this means that we *know* that SfxModelGuard also locks the SolarMutex (nothing more, nothing less).
+ // If this ever changes, we need to adjust this code here, too.
+ return m_solarMutexFacade;
+ }
+
private:
- SfxModelGuard& m_guard;
+ SfxModelGuard m_guard;
+ SolarMutexFacade m_solarMutexFacade;
};
//==================================================================================================================
@@ -248,16 +284,19 @@ namespace sfx2
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DocumentUndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.enterUndoContext( i_title, SfxModelGuardFacade( aGuard ) );
+ // SYNCHRONIZED --->
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.enterUndoContext( i_title, aGuard );
+ // <--- SYNCHRONIZED
+ m_pImpl->invalidateXDo_nolck();
}
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DocumentUndoManager::enterHiddenUndoContext( ) throw (EmptyUndoStackException, RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.enterHiddenUndoContext( SfxModelGuardFacade( aGuard ) );
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.enterHiddenUndoContext( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -266,8 +305,8 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::leaveUndoContext( ) throw (InvalidStateException, RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.leaveUndoContext( SfxModelGuardFacade( aGuard ) );
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.leaveUndoContext( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -276,8 +315,8 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (RuntimeException, IllegalArgumentException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.addUndoAction( i_action, SfxModelGuardFacade( aGuard ) );
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.addUndoAction( i_action, aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -286,9 +325,9 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::undo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
m_pImpl->enterViewStandardMode();
- m_pImpl->aUndoHelper.undo( SfxModelGuardFacade( aGuard ) );
+ m_pImpl->aUndoHelper.undo( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -297,9 +336,9 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::redo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
m_pImpl->enterViewStandardMode();
- m_pImpl->aUndoHelper.redo( SfxModelGuardFacade( aGuard ) );
+ m_pImpl->aUndoHelper.redo( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -307,42 +346,42 @@ namespace sfx2
//------------------------------------------------------------------------------------------------------------------
::sal_Bool SAL_CALL DocumentUndoManager::isUndoPossible( ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.isUndoPossible();
}
//------------------------------------------------------------------------------------------------------------------
::sal_Bool SAL_CALL DocumentUndoManager::isRedoPossible( ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.isRedoPossible();
}
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString SAL_CALL DocumentUndoManager::getCurrentUndoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.getCurrentUndoActionTitle();
}
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString SAL_CALL DocumentUndoManager::getCurrentRedoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.getCurrentRedoActionTitle();
}
//------------------------------------------------------------------------------------------------------------------
Sequence< ::rtl::OUString > SAL_CALL DocumentUndoManager::getAllUndoActionTitles( ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.getAllUndoActionTitles();
}
//------------------------------------------------------------------------------------------------------------------
Sequence< ::rtl::OUString > SAL_CALL DocumentUndoManager::getAllRedoActionTitles( ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.getAllRedoActionTitles();
}
@@ -350,8 +389,8 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::clear( ) throw (UndoContextNotClosedException, RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.clear( SfxModelGuardFacade( aGuard ) );
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.clear( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -360,8 +399,8 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::clearRedo( ) throw (UndoContextNotClosedException, RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.clearRedo( SfxModelGuardFacade( aGuard ) );
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.clearRedo( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -370,8 +409,8 @@ namespace sfx2
void SAL_CALL DocumentUndoManager::reset() throw (RuntimeException)
{
// SYNCHRONIZED --->
- SfxModelGuard aGuard( *this );
- m_pImpl->aUndoHelper.reset( SfxModelGuardFacade( aGuard ) );
+ UndoManagerGuard aGuard( *this );
+ m_pImpl->aUndoHelper.reset( aGuard );
// <--- SYNCHRONIZED
m_pImpl->invalidateXDo_nolck();
}
@@ -379,35 +418,35 @@ namespace sfx2
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DocumentUndoManager::lock( ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
m_pImpl->aUndoHelper.lock();
}
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DocumentUndoManager::unlock( ) throw (RuntimeException, NotLockedException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
m_pImpl->aUndoHelper.unlock();
}
//------------------------------------------------------------------------------------------------------------------
::sal_Bool SAL_CALL DocumentUndoManager::isLocked( ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.isLocked();
}
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DocumentUndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.addUndoManagerListener( i_listener );
}
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DocumentUndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
{
- SfxModelGuard aGuard( *this );
+ UndoManagerGuard aGuard( *this );
return m_pImpl->aUndoHelper.removeUndoManagerListener( i_listener );
}