sw/README.md | 4 ++-- sw/qa/core/doc/doc.cxx | 11 +++++------ sw/source/core/doc/DocumentRedlineManager.cxx | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-)
New commits: commit 425b4ba6552d8f712fa44ef1a280c94e28bcf51e Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed May 28 08:18:36 2025 +0200 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed May 28 09:25:01 2025 +0200 tdf#166319 sw interdependent redlines: combine on reject of ins-then-fmt's fmt The bugdoc has <ins>AA<format>BB</format>CC</ins> in it, rejecting the BB part resulted in <ins>AA</ins><ins>CC</ins>, while the expected result would be to reject AA and CC together with BB. The problem is that the insert-then-format wasn't combined with surrounding insert redlines. Fix the problem similar to what commit f31293c9fcbc47e43367857085e135f09ed378b8 (tdf#166319 sw interdependent redlines: combine on accept of ins-then-fmt's fmt, 2025-05-25) did for accept a similar redline: extend sw::DocumentRedlineManager::RejectRedlineRange() to also reject the surrounding redlines. With this, clicking reject at the center of this AABBCC redline chain makes all of that disappear from the text, as expected. Change-Id: I330e4a96c6c1464db4844b0e99481aad72e95d5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185942 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/README.md b/sw/README.md index 58a6cc9e1bdb..1c6dd8c9a22b 100644 --- a/sw/README.md +++ b/sw/README.md @@ -32,8 +32,8 @@ comments show that Writer core dates back until at least November There is a good overview documentation of basic architecture of Writer core in the OOo wiki: -- <https://wiki.openoffice.org/wiki/Writer/Core_And_Layout> -- <https://wiki.openoffice.org/wiki/Writer/Text_Formatting> +- <https://web.archive.org/web/20240703103909/https://wiki.openoffice.org/wiki/Writer/Core_And_Layout> +- <https://web.archive.org/web/20240703234819/https://wiki.openoffice.org/wiki/Writer/Text_Formatting> Writer specific WhichIds are defined in `sw/inc/hintids.hxx`. diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 55607e565f9b..0d4f635b3d00 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -837,12 +837,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testInsThenFormat) CPPUNIT_ASSERT_LESS(rRedlines.size(), nRedline); pWrtShell->RejectRedline(nRedline); - // Then make sure the format-on-insert is rejected, i.e. BBB is not in the text anymore: - // Without the accompanying fix in place, this test would have failed with: - // - Expected: AAACCC - // - Actual : AAABBBCCC - // i.e. only the format part of BBB was rejected, it wasn't removed from the document. - CPPUNIT_ASSERT_EQUAL(u"AAACCC"_ustr, pTextNode->GetText()); + // Then make sure the format-on-insert is rejected, i.e. neither the format-on-insert BBB, nor + // the surrounding AAA and CCC inserts are in the text anymore: + // Without the accompanying fix in place, this test would have failed, the text was AAABBBCCC, + // just the format of BBB was dropped. + CPPUNIT_ASSERT(pTextNode->GetText().isEmpty()); } CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testDelThenFormat) diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index b9a9f7677115..5778b02299e2 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -3676,6 +3676,23 @@ 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) + { + // 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. + if (m_rDoc.GetIDocumentUndoRedo().DoesUndo()) + { + std::unique_ptr<SwUndoRedline> pUndoRdl + = std::make_unique<SwUndoRejectRedline>(*pTmp); + m_rDoc.GetIDocumentUndoRedo().AppendUndo(std::move(pUndoRdl)); + } + nPamEndtNI = pTmp->Start()->GetNodeIndex(); + nPamEndCI = pTmp->Start()->GetContentIndex(); + bRet |= lcl_RejectRedline(maRedlineTable, nRdlIdx, bCallDelete); + nRdlIdx++; + } } while (nRdlIdx > 0); return bRet;