sw/qa/core/doc/doc.cxx | 5 +++++ sw/source/core/doc/DocumentRedlineManager.cxx | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-)
New commits: commit fc90f2766f8053ad3436d869d3f17fec98d1be36 Author: Miklos Vajna <[email protected]> AuthorDate: Fri Jun 6 08:40:51 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Jun 6 09:24:42 2025 +0200 tdf#166319 sw interdependent redlines: combine on reject of del-then-fmt's fmt The bugdoc has <del>AA<format>BB</format>CC</del> in it, rejecting the redline under the cursor when it's inside BB resulted in rejecting BB, but not AA or CC. The problem is that the delete-then-format wasn't combined with the surrounding delete redlines. Fix the problem by extending the reverse combine code in sw::DocumentRedlineManager::RejectRedlineRange() to recognize delete-then-format when it recognized insert-then-format already. Also rename CanReverseCombineTypesForAccept() to communicate this is now used for reject purposes, too. Change-Id: I7832af605d09ce9a29dd10d68c1915e7f7becfbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186215 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 30811a5f241a..b1566847e5e0 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -929,6 +929,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testDelThenFormat) CPPUNIT_ASSERT(pRedline); CPPUNIT_ASSERT_EQUAL(RedlineType::Format, pRedline->GetType()); CPPUNIT_ASSERT(!pRedline->GetRedlineData().Next()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 3 + // i.e. the surrounding delete redlines were not combined on reject. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rRedlines.size()); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 35ae1306ca74..17558d7999df 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1193,10 +1193,10 @@ bool CanCombineTypesForAcceptReject(SwRedlineData& rInnerData, SwRangeRedline& r return true; } -/// Decides if it's OK to combine this rInnerData having 2 types with an -/// outer rOuterRedline for accept purposes. E.g. format-on-delete and -/// delete can be combined if accepting a delete. -bool CanReverseCombineTypesForAccept(SwRangeRedline& rOuterRedline, SwRedlineData& rInnerData) +/// Decides if it's OK to combine this rInnerData having 2 types with an outer rOuterRedline for +/// accept or reject purposes. E.g. format-on-delete and delete can be combined if accepting a +/// delete. +bool CanReverseCombineTypesForAcceptReject(SwRangeRedline& rOuterRedline, SwRedlineData& rInnerData) { switch (rOuterRedline.GetType()) { @@ -3386,7 +3386,7 @@ bool DocumentRedlineManager::AcceptRedlineRange(SwRedlineTable::size_type nPosOr } nRdlIdx++; //we will decrease it in the loop anyway. } - else if (CanReverseCombineTypesForAccept(*pTmp, aOrigData)) + else if (CanReverseCombineTypesForAcceptReject(*pTmp, aOrigData)) { // The aOrigData has 2 types and for these types we want the underlying type to be // combined with the type of the surrounding redlines, so accept pTmp, too. @@ -3734,9 +3734,7 @@ bool DocumentRedlineManager::RejectRedlineRange(SwRedlineTable::size_type nPosOr } nRdlIdx++; //we will decrease it in the loop anyway. } - else if (pTmp->GetType() == RedlineType::Insert - && aOrigData.GetType() == RedlineType::Format && aOrigData.Next() - && aOrigData.Next()->GetType() == RedlineType::Insert) + else if (CanReverseCombineTypesForAcceptReject(*pTmp, aOrigData)) { // The aOrigData has 2 types and for these types we want the underlying type to be // combined with the type of the surrounding redlines, so reject pTmp, too.
