diff options
-rw-r--r-- | sc/source/core/tool/chgtrack.cxx | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 8373605e1ab3..48e4f7f63f66 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -3163,65 +3163,64 @@ void ScChangeTrack::Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMe // Deletes are in right order ScChangeAction* pAct = IsLastAction(j) ? pLast : GetAction(j); - if ( pAct ) + if (!pAct) + continue; + + if ( pAct->IsDeleteType() ) { - if ( pAct->IsDeleteType() ) + if (j == nEndAction || (pAct != pLast && ((ScChangeActionDel*)pAct)->IsTopDelete())) { - if ( j == nEndAction || (pAct != pLast && - ((ScChangeActionDel*)pAct)->IsTopDelete()) ) - { - SetInDeleteTop( true ); - SetInDeleteRange( ((ScChangeActionDel*)pAct)-> - GetOverAllRange().MakeRange() ); - } + SetInDeleteTop( true ); + SetInDeleteRange( ((ScChangeActionDel*)pAct)->GetOverAllRange().MakeRange() ); } - UpdateReference( pAct, true ); - SetInDeleteTop( false ); - Remove( pAct ); - if ( IsInPasteCut() ) - aPasteCutMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) ); - else - { - if ( j == nStartAction && pAct->GetType() == SC_CAT_MOVE ) + } + UpdateReference( pAct, true ); + SetInDeleteTop( false ); + Remove( pAct ); + if ( IsInPasteCut() ) + { + aPasteCutMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) ); + continue; + } + + if ( j == nStartAction && pAct->GetType() == SC_CAT_MOVE ) + { + ScChangeActionMove* pMove = (ScChangeActionMove*) pAct; + sal_uLong nStart = pMove->GetStartLastCut(); + sal_uLong nEnd = pMove->GetEndLastCut(); + if ( nStart && nStart <= nEnd ) + { // Recover LastCut + //! Break Links before Cut Append + pMove->RemoveAllLinks(); + StartBlockModify( SC_CTM_APPEND, nStart ); + for ( sal_uLong nCut = nStart; nCut <= nEnd; nCut++ ) { - ScChangeActionMove* pMove = (ScChangeActionMove*) pAct; - sal_uLong nStart = pMove->GetStartLastCut(); - sal_uLong nEnd = pMove->GetEndLastCut(); - if ( nStart && nStart <= nEnd ) - { // Recover LastCut - //! Break Links before Cut Append - pMove->RemoveAllLinks(); - StartBlockModify( SC_CTM_APPEND, nStart ); - for ( sal_uLong nCut = nStart; nCut <= nEnd; nCut++ ) - { - ScChangeActionMap::iterator itCut = aPasteCutMap.find( nCut ); + ScChangeActionMap::iterator itCut = aPasteCutMap.find( nCut ); - if ( itCut != aPasteCutMap.end() ) - { - OSL_ENSURE( aMap.find( nCut ) == aMap.end(), "ScChangeTrack::Undo: nCut dup" ); - Append( itCut->second, nCut ); - aPasteCutMap.erase( itCut ); - } - else - { - OSL_FAIL( "ScChangeTrack::Undo: nCut not found" ); - } - } - EndBlockModify( nEnd ); - ResetLastCut(); - nStartLastCut = nStart; - nEndLastCut = nEnd; - pLastCutMove = pMove; - SetLastCutMoveRange( - pMove->GetFromRange().MakeRange(), pDoc ); + if ( itCut != aPasteCutMap.end() ) + { + OSL_ENSURE( aMap.find( nCut ) == aMap.end(), "ScChangeTrack::Undo: nCut dup" ); + Append( itCut->second, nCut ); + aPasteCutMap.erase( itCut ); } else - delete pMove; + { + OSL_FAIL( "ScChangeTrack::Undo: nCut not found" ); + } } - else - delete pAct; + EndBlockModify( nEnd ); + ResetLastCut(); + nStartLastCut = nStart; + nEndLastCut = nEnd; + pLastCutMove = pMove; + SetLastCutMoveRange( + pMove->GetFromRange().MakeRange(), pDoc ); } + else + delete pMove; } + else + delete pAct; } EndBlockModify( nEndAction ); } |