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 /svl/source/undo | |
parent | 620269ac01acf975855176ab7cff22b3153bea6f (diff) |
undoapi: +RemoveOldestUndoActions
Diffstat (limited to 'svl/source/undo')
-rw-r--r-- | svl/source/undo/undo.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
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; |