diff options
author | Armin Le Grand <alg@apache.org> | 2013-06-23 11:25:32 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-24 16:08:17 +0100 |
commit | 91b8728108193706e142c25903c0dcd4ea8b0b21 (patch) | |
tree | 7a979cf11476fc5dd2bcd39ca3a1efa0ad7b5a1b /svl | |
parent | b139f6fedfcf3cbed0eadeb007e2155b576413d2 (diff) |
Resolves: #i120020# corrected paragraph merge...
corresponding undo and ownership of linked undo actions
(cherry picked from commit e58fe7afee5163833479b76a474416a77d95f075)
Conflicts:
editeng/source/editeng/impedit2.cxx
sc/source/ui/undo/undobase.cxx
sc/source/ui/undo/undodraw.cxx
svl/inc/svl/undo.hxx
Change-Id: I6672990558a496dfc692554437897d013e258f40
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/undo/undo.cxx | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 72929b75b03e..dac5dc3d37dc 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -57,16 +57,9 @@ SfxUndoContext::~SfxUndoContext() //------------------------------------------------------------------------ -sal_Bool SfxUndoAction::IsLinked() +void SfxUndoAction::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction) { - return bLinked; -} - -//------------------------------------------------------------------------ - -void SfxUndoAction::SetLinked( sal_Bool bIsLinked ) -{ - bLinked = bIsLinked; + mpSfxLinkUndoAction = pSfxLinkUndoAction; } //------------------------------------------------------------------------ @@ -74,14 +67,19 @@ void SfxUndoAction::SetLinked( sal_Bool bIsLinked ) SfxUndoAction::~SfxUndoAction() { DBG_DTOR(SfxUndoAction, 0); - DBG_ASSERT( !IsLinked(), "Gelinkte Action geloescht" ); + + if(mpSfxLinkUndoAction) + { + mpSfxLinkUndoAction->LinkedSfxUndoActionDestructed(*this); + mpSfxLinkUndoAction = 0; + } } SfxUndoAction::SfxUndoAction() +: mpSfxLinkUndoAction(0) { DBG_CTOR(SfxUndoAction, 0); - SetLinked( sal_False ); } //------------------------------------------------------------------------ @@ -449,24 +447,18 @@ void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount ) if ( nPos > m_pData->pActUndoArray->nCurUndoAction ) { SfxUndoAction* pAction = m_pData->pActUndoArray->aUndoActions[nPos-1].pAction; - if ( !pAction->IsLinked() ) - { - aGuard.markForDeletion( pAction ); - m_pData->pActUndoArray->aUndoActions.Remove( nPos-1 ); - --nNumToDelete; - } + aGuard.markForDeletion( pAction ); + m_pData->pActUndoArray->aUndoActions.Remove( nPos-1 ); + --nNumToDelete; } if ( nNumToDelete > 0 && m_pData->pActUndoArray->nCurUndoAction > 0 ) { SfxUndoAction* pAction = m_pData->pActUndoArray->aUndoActions[0].pAction; - if ( !pAction->IsLinked() ) - { - aGuard.markForDeletion( pAction ); - m_pData->pActUndoArray->aUndoActions.Remove(0); - --m_pData->pActUndoArray->nCurUndoAction; - --nNumToDelete; - } + aGuard.markForDeletion( pAction ); + m_pData->pActUndoArray->aUndoActions.Remove(0); + --m_pData->pActUndoArray->nCurUndoAction; + --nNumToDelete; } if ( nPos == m_pData->pActUndoArray->aUndoActions.size() ) @@ -638,9 +630,7 @@ bool SfxUndoManager::ImplAddUndoAction_NoNotify( SfxUndoAction *pAction, bool bT // respect max number if( m_pData->pActUndoArray == m_pData->pUndoArray ) { - while( m_pData->pActUndoArray->aUndoActions.size() >= - m_pData->pActUndoArray->nMaxUndoActions && - !m_pData->pActUndoArray->aUndoActions[0].pAction->IsLinked() ) + while(m_pData->pActUndoArray->aUndoActions.size() >= m_pData->pActUndoArray->nMaxUndoActions) { i_guard.markForDeletion( m_pData->pActUndoArray->aUndoActions[0].pAction ); m_pData->pActUndoArray->aUndoActions.Remove(0); @@ -1399,7 +1389,7 @@ SfxLinkUndoAction::SfxLinkUndoAction(::svl::IUndoManager *pManager) { size_t nPos = pManager->GetUndoActionCount()-1; pAction = pUndoManagerImplementation->m_pData->pActUndoArray->aUndoActions[nPos].pAction; - pAction->SetLinked(); + pAction->SetLinkToSfxLinkUndoAction(this); } else pAction = 0; @@ -1464,9 +1454,18 @@ OUString SfxLinkUndoAction::GetRepeatComment(SfxRepeatTarget&r) const SfxLinkUndoAction::~SfxLinkUndoAction() { if( pAction ) - pAction->SetLinked( sal_False ); + pAction->SetLinkToSfxLinkUndoAction(0); } +//------------------------------------------------------------------------ + +void SfxLinkUndoAction::LinkedSfxUndoActionDestructed(const SfxUndoAction& rCandidate) +{ + OSL_ENSURE(0 != pAction, "OOps, we have no linked SfxUndoAction (!)"); + OSL_ENSURE(pAction == &rCandidate, "OOps, the destroyed and linked UndoActions differ (!)"); + (void)rCandidate; + pAction = 0; +} //------------------------------------------------------------------------ |