diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-11-30 21:17:55 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-11-30 21:17:55 +0100 |
commit | cb36292ec49efcc8cbb1ce1010e3665394de144c (patch) | |
tree | bbd7263126ee975f25381c4f9d47bcd3f665a295 /svl | |
parent | undoapi: introduced an (optional) SfxUndoContext for SfxUndoAction::Undo/Redo (diff) | |
download | core-cb36292ec49efcc8cbb1ce1010e3665394de144c.tar.gz core-cb36292ec49efcc8cbb1ce1010e3665394de144c.zip |
undoapi: Undo/Redo: do not take ownership of a (derivee-provided) SfxUndoContext, since it acts as out parameter, too. Instead, introduce a Undo/Redo which takes the context as parameter
Diffstat (limited to 'svl')
-rw-r--r-- | svl/inc/svl/undo.hxx | 18 | ||||
-rw-r--r-- | svl/source/undo/undo.cxx | 45 |
2 files changed, 37 insertions, 26 deletions
diff --git a/svl/inc/svl/undo.hxx b/svl/inc/svl/undo.hxx index b1bec6332f61..5664f28f296b 100644 --- a/svl/inc/svl/undo.hxx +++ b/svl/inc/svl/undo.hxx @@ -35,7 +35,6 @@ #include <boost/scoped_ptr.hpp> #include <vector> -#include <memory> //==================================================================== @@ -396,18 +395,8 @@ public: void RemoveOldestUndoActions( USHORT const i_count ); protected: - /** retrieve the context for a to-be-executed Undo or Redo operation - - This method is called immediately before an SfxUndoAction is undo or redone. If a derived class provides a non-<NULL/> - context here, it is passed to SfxUndoAction's UndoWithContext resp. RedoWithContext. If no context is provided, - the SfxUndoAction's normal Undo/Redo is called. - - The method is called with the UndoManager's mutex locked. - - The default implementation of the method returns a <NULL/> context. - */ - virtual ::std::auto_ptr< SfxUndoContext > - GetUndoContext(); + BOOL UndoWithContext( SfxUndoContext& i_context ); + BOOL RedoWithContext( SfxUndoContext& i_context ); private: USHORT ImplLeaveListAction( const bool i_merge, ::svl::undo::impl::UndoManagerGuard& i_guard ); @@ -420,6 +409,9 @@ private: bool ImplIsInListAction_Lock() const; void ImplEnableUndo_Lock( bool const i_enable ); + BOOL ImplUndo( SfxUndoContext* i_contextOrNull ); + BOOL ImplRedo( SfxUndoContext* i_contextOrNull ); + friend class ::svl::undo::impl::LockGuard; }; diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 480fb2e8026a..129ad5ea9a69 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -729,6 +729,20 @@ bool SfxUndoManager::IsDoing() const BOOL SfxUndoManager::Undo() { + return ImplUndo( NULL ); +} + +//------------------------------------------------------------------------ + +BOOL SfxUndoManager::UndoWithContext( SfxUndoContext& i_context ) +{ + return ImplUndo( &i_context ); +} + +//------------------------------------------------------------------------ + +BOOL SfxUndoManager::ImplUndo( SfxUndoContext* i_contextOrNull ) +{ UndoManagerGuard aGuard( *m_pData ); OSL_ENSURE( !IsDoing(), "SfxUndoManager::Undo: *nested* Undo/Redo actions? How this?" ); @@ -751,12 +765,11 @@ BOOL SfxUndoManager::Undo() const String sActionComment = pAction->GetComment(); try { - ::std::auto_ptr< SfxUndoContext > pUndoContext( GetUndoContext() ); // clear the guard/mutex before calling into the SfxUndoAction - this can be an extension-implemented UNO component // nowadays ... aGuard.clear(); - if ( pUndoContext.get() != NULL ) - pAction->UndoWithContext( *pUndoContext ); + if ( i_contextOrNull != NULL ) + pAction->UndoWithContext( *i_contextOrNull ); else pAction->Undo(); aGuard.reset(); @@ -816,6 +829,20 @@ XubString SfxUndoManager::GetRedoActionComment( USHORT nNo, bool const i_current BOOL SfxUndoManager::Redo() { + return ImplRedo( NULL ); +} + +//------------------------------------------------------------------------ + +BOOL SfxUndoManager::RedoWithContext( SfxUndoContext& i_context ) +{ + return ImplRedo( &i_context ); +} + +//------------------------------------------------------------------------ + +BOOL SfxUndoManager::ImplRedo( SfxUndoContext* i_contextOrNull ) +{ UndoManagerGuard aGuard( *m_pData ); OSL_ENSURE( !IsDoing(), "SfxUndoManager::Redo: *nested* Undo/Redo actions? How this?" ); @@ -838,12 +865,11 @@ BOOL SfxUndoManager::Redo() const String sActionComment = pAction->GetComment(); try { - ::std::auto_ptr< SfxUndoContext > pUndoContext( GetUndoContext() ); // clear the guard/mutex before calling into the SfxUndoAction - this can be a extension-implemented UNO component // nowadays ... aGuard.clear(); - if ( pUndoContext.get() != NULL ) - pAction->RedoWithContext( *pUndoContext ); + if ( i_contextOrNull != NULL ) + pAction->RedoWithContext( *i_contextOrNull ); else pAction->Redo(); aGuard.reset(); @@ -1189,13 +1215,6 @@ void SfxUndoManager::RemoveOldestUndoActions( USHORT const i_count ) //------------------------------------------------------------------------ -::std::auto_ptr< SfxUndoContext > SfxUndoManager::GetUndoContext() -{ - return ::std::auto_ptr< SfxUndoContext >(); -} - -//------------------------------------------------------------------------ - USHORT SfxListUndoAction::GetId() const { return nId; |