diff options
author | Rosemary Sebastian <rosemary.seb8@gmail.com> | 2017-07-17 16:31:36 +0530 |
---|---|---|
committer | Rosemary Sebastian <rosemary.seb8@gmail.com> | 2017-08-30 20:18:02 +0530 |
commit | 67263a70cb0e9cc581c316ef50e7703fc0c24c1d (patch) | |
tree | 3eeb4da4fa04842f8451af056b8d025b5b0204ae /sw/source/core/undo/undel.cxx | |
parent | bd37233020266a5892d6ec7022688e3dfb9cef75 (diff) |
tdf#109151: Enable grouping of undo actions for delete redlines
Change-Id: I74183e5df58d8d0c5e892182f545a5ff17eb7936
Diffstat (limited to 'sw/source/core/undo/undel.cxx')
-rw-r--r-- | sw/source/core/undo/undel.cxx | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 6787c6a3125b..9e82c2541e88 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -95,7 +95,8 @@ static void lcl_MakeAutoFrames( const SwFrameFormats& rSpzArr, sal_uLong nMovedI SwUndoDelete::SwUndoDelete( SwPaM& rPam, bool bFullPara, - bool bCalledByTableCpy ) + bool bCalledByTableCpy, + bool bRedlineDelete ) : SwUndo(SwUndoId::DELETE, rPam.GetDoc()), SwUndRng( rPam ), m_pMvStt( nullptr ), @@ -115,7 +116,8 @@ SwUndoDelete::SwUndoDelete( m_bDelFullPara( bFullPara ), m_bResetPgDesc( false ), m_bResetPgBrk( false ), - m_bFromTableCopy( bCalledByTableCpy ) + m_bFromTableCopy( bCalledByTableCpy ), + m_bRedlineDelete( bRedlineDelete ) { bCacheComment = false; @@ -213,7 +215,8 @@ SwUndoDelete::SwUndoDelete( if( !pSttTextNd && !pEndTextNd ) --rPam.GetPoint()->nNode; - rPam.DeleteMark(); // the SPoint is in the selection + if( !m_bRedlineDelete ) // Make sure that it's not a redline since calling DeleteMark() will result in an empty redline + rPam.DeleteMark(); // the SPoint is in the selection if( !pEndTextNd ) nEndContent = 0; @@ -384,7 +387,8 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) m_pSttStr.reset( new OUString( pSttTextNd->GetText().copy(nSttContent, nLen)) ); - pSttTextNd->EraseText( pStt->nContent, nLen ); + if( !m_bRedlineDelete ) + pSttTextNd->EraseText( pStt->nContent, nLen ); if( pSttTextNd->GetpSwpHints() ) pSttTextNd->GetpSwpHints()->DeRegister(); @@ -420,7 +424,8 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // UNDO history) m_pEndStr.reset( new OUString( pEndTextNd->GetText().copy( 0, pEnd->nContent.GetIndex() )) ); - pEndTextNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); + if( !m_bRedlineDelete ) + pEndTextNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTextNd->GetpSwpHints() ) pEndTextNd->GetpSwpHints()->DeRegister(); @@ -509,7 +514,9 @@ bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) nUChrPos++; } (*m_pSttStr) = m_pSttStr->replaceAt( nUChrPos, 0, OUString(cDelChar) ); - pDelTextNd->EraseText( pStt->nContent, 1 ); + + if( !m_bRedlineDelete ) + pDelTextNd->EraseText( pStt->nContent, 1 ); m_bGroup = true; return true; @@ -760,6 +767,13 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) { SwDoc& rDoc = rContext.GetDoc(); + if(m_bRedlineDelete) + { + SwPaM & rPam = AddUndoRedoPaM(rContext); + rDoc.getIDocumentRedlineAccess().DeleteRedline(rPam, true, USHRT_MAX); + return; + } + sal_uLong nCalcStt = nSttNode - m_nNdDiff; if( m_nSectDiff && m_bBackSp ) @@ -970,6 +984,19 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext) SwPaM & rPam = AddUndoRedoPaM(rContext); SwDoc& rDoc = *rPam.GetDoc(); + if(m_bRedlineDelete) + { + RedlineFlags eOld = rDoc.getIDocumentRedlineAccess().GetRedlineFlags(); + rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern(( eOld & ~RedlineFlags::Ignore) | RedlineFlags::On ); + if (rPam.GetPoint() != rPam.GetMark()) + { + rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(nsRedlineType_t::REDLINE_DELETE, rPam), false ); + } + SetPaM(rPam, true); + rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld ); + return; + } + if( m_pRedlSaveData ) { const bool bSuccess = FillSaveData(rPam, *m_pRedlSaveData); |