From 632cc0507353c8a85e7438d6ef082bafb2a2137a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 22 Jul 2020 13:24:15 +0200 Subject: sw: fix AppendRedline() creating empty redlines for Outside This happens on tdf#133967 bugdoc with the Delete/Delete case first, in line 1445 - the start positions are equal, so the new redline is empty => DocumentRedlineManager.cxx:92: redline table corrupted: empty redline Similar bugs exist for Delete/Insert case in line 1725 and Format/? case in line 1892, the latter even checks a nonsensical condition *pEnd != *pRStt that is always true for Outside case. It's like that since inital CVS import. Change-Id: I7ade25380a5a43b14e87db37da8fc84267e89dd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99389 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/source/core/doc/DocumentRedlineManager.cxx | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 6bce5c1d9364..c0e1aa6add8c 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1445,7 +1445,15 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall { // Overlaps the current one completely, // split the new one - if( *pEnd != *pREnd ) + if (*pEnd == *pREnd) + { + pNewRedl->SetEnd(*pRStt, pEnd); + } + else if (*pStt == *pRStt) + { + pNewRedl->SetStart(*pREnd, pStt); + } + else { SwRangeRedline* pNew = new SwRangeRedline( *pNewRedl ); pNew->SetStart( *pREnd ); @@ -1454,8 +1462,6 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall n = 0; // re-initialize bDec = true; } - else - pNewRedl->SetEnd( *pRStt, pEnd ); } break; @@ -1724,7 +1730,13 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall { pRedl->PushData( *pNewRedl ); if( *pEnd == *pREnd ) + { pNewRedl->SetEnd( *pRStt, pEnd ); + } + else if (*pStt == *pRStt) + { + pNewRedl->SetStart(*pREnd, pStt); + } else { pNew = new SwRangeRedline( *pNewRedl ); @@ -1891,20 +1903,23 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall case SwComparePosition::Outside: // Overlaps the current one completely, // split or shorten the new one - if( *pEnd != *pREnd ) + if (*pEnd == *pREnd) { - if( *pEnd != *pRStt ) - { - SwRangeRedline* pNew = new SwRangeRedline( *pNewRedl ); - pNew->SetStart( *pREnd ); - pNewRedl->SetEnd( *pRStt, pEnd ); - AppendRedline( pNew, bCallDelete ); - n = 0; // re-initialize - bDec = true; - } + pNewRedl->SetEnd(*pRStt, pEnd); + } + else if (*pStt == *pRStt) + { + pNewRedl->SetStart(*pREnd, pStt); } else + { + SwRangeRedline* pNew = new SwRangeRedline( *pNewRedl ); + pNew->SetStart( *pREnd ); pNewRedl->SetEnd( *pRStt, pEnd ); + AppendRedline( pNew, bCallDelete ); + n = 0; // re-initialize + bDec = true; + } break; default: break; -- cgit