diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-11-26 12:30:18 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-11-26 12:30:18 +0100 |
commit | fee72f4b56b6e4a4b6711bc749e9a4b9475f2425 (patch) | |
tree | ee48e65f8d50541dde9002cfeb26f369490019fc | |
parent | 620269ac01acf975855176ab7cff22b3153bea6f (diff) |
undoapi: +RemoveOldestUndoActions
-rw-r--r-- | svl/inc/svl/undo.hxx | 4 | ||||
-rw-r--r-- | svl/source/undo/undo.cxx | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/svl/inc/svl/undo.hxx b/svl/inc/svl/undo.hxx index 1c6ab5570c14..fb1ae16a01d8 100644 --- a/svl/inc/svl/undo.hxx +++ b/svl/inc/svl/undo.hxx @@ -378,6 +378,10 @@ public: */ bool HasTopUndoActionMark( UndoStackMark const i_mark ); + /** removes the oldest Undo actions from the stack + */ + void RemoveOldestUndoActions( USHORT const i_count ); + private: USHORT ImplLeaveListAction( const bool i_merge, ::svl::undo::impl::UndoManagerGuard& i_guard ); bool ImplAddUndoAction_NoNotify( SfxUndoAction* pAction, BOOL bTryMerge, ::svl::undo::impl::UndoManagerGuard& i_guard ); diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 38cb88cf346d..13588b234a62 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -607,8 +607,7 @@ bool SfxUndoManager::ImplAddUndoAction_NoNotify( SfxUndoAction *pAction, BOOL bT } // append new action - SfxUndoAction* pMakeCompilerHappy = pAction; - m_pData->pActUndoArray->aUndoActions.Insert( pMakeCompilerHappy, m_pData->pActUndoArray->nCurUndoAction++ ); + m_pData->pActUndoArray->aUndoActions.Insert( pAction, m_pData->pActUndoArray->nCurUndoAction++ ); return true; } @@ -1137,6 +1136,30 @@ bool SfxUndoManager::HasTopUndoActionMark( UndoStackMark const i_mark ) //------------------------------------------------------------------------ +void SfxUndoManager::RemoveOldestUndoActions( USHORT const i_count ) +{ + UndoManagerGuard aGuard( *m_pData ); + + size_t nActionsToRemove = i_count; + while ( nActionsToRemove ) + { + SfxUndoAction* pActionToRemove = m_pData->pUndoArray->aUndoActions[0].pAction; + + if ( IsInListAction() && ( m_pData->pUndoArray->nCurUndoAction == 1 ) ) + { + OSL_ENSURE( false, "SfxUndoManager::RemoveOldestUndoActions: cannot remove a not-yet-closed list action!" ); + return; + } + + aGuard.markForDeletion( pActionToRemove ); + m_pData->pUndoArray->aUndoActions.Remove( 0 ); + --m_pData->pUndoArray->nCurUndoAction; + --nActionsToRemove; + } +} + +//------------------------------------------------------------------------ + USHORT SfxListUndoAction::GetId() const { return nId; |