sw/qa/core/doc/doc.cxx | 5 +++++ sw/source/core/doc/DocumentRedlineManager.cxx | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-)
New commits: commit 82b24dd9748c6c0a2990e70bda0960ae26415390 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Jun 6 08:40:51 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Jun 6 12:05:55 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/+/186216 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index d4396bc24e32..4efd50044228 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 1658504e1fd0..64d3b108aaa2 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1192,10 +1192,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()) { @@ -3385,7 +3385,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. @@ -3733,9 +3733,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.