sw/qa/extras/ooxmlexport/data/redline-range-comment.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 17 +++++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 13 +++++++++++ 3 files changed, 30 insertions(+)
New commits: commit a72506da82d2e0334e23a8c3c1cd07282fdd7ca3 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jan 29 08:37:37 2026 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Jan 29 14:28:07 2026 +0100 cool#13988 DOCX export: fix missing delete flag on deleted comments with ranges Load the bugdoc, see that the comment is marked as deleted (is anchored inside a delete redline), save, reload, the comment is no longer deleted. This is because we write redline start/end around DOCX "runs", and the comment reference dummy character is one such dummy run. So unless explicit redline markup is written, comments (their comment reference) is not inside a redline. Fix this by checking if we'll write comment references (part of comment end) in DocxAttributeOutput::EndRun(). If we're inside a delete, write the delete redline markup around the comment reference, too. Doing the same for inserts would make sense, but then first we would need to tweak Writer's UI to insert new comments outside redlines, otherwise UITest_writer_tests7's tdf90401.tdf90401.test_tdf142902_remove_personal_info_in_DOCX would break. Change-Id: I8d6db05c8a9fd1d5e1e619843967e3f21fb43e59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198353 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/redline-range-comment.docx b/sw/qa/extras/ooxmlexport/data/redline-range-comment.docx new file mode 100644 index 000000000000..1110971401f5 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/redline-range-comment.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index b009516be1d3..f021484152bf 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -293,6 +293,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf167082) CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), aStyleName); } +CPPUNIT_TEST_FIXTURE(Test, testRangeCommentInDeleteDocxExport) +{ + // Given a document with a comment that is inside a delete redline: + createSwDoc("redline-range-comment.docx"); + + // When exporting that to DOCX: + save(TestFilter::DOCX); + + // Then make sure that the comment reference is inside the delete redline: + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. the comment anchor was outside the redline. + CPPUNIT_ASSERT_EQUAL(1, countXPathNodes(pXmlDoc, "//w:del/w:r/w:commentReference")); +} + CPPUNIT_TEST_FIXTURE(Test, testFloatingTableAnchorPosExport) { // Given a document with two floating tables after each other: diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ef1cb159c7fa..362bca82f87c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2000,7 +2000,20 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In DoWriteBookmarksStart(m_rBookmarksStart, m_pMoveRedlineData); DoWriteBookmarksEnd(m_rBookmarksEnd, false, false); // Write non-moverange bookmarks DoWritePermissionsStart(); + + // Surround annotation references with redline start/end markup if we're inside a delete. + bool bHasAnnotationMarkReferencesInDel = !m_rAnnotationMarksEnd.empty() && m_pRedlineData + && m_pRedlineData->GetType() == RedlineType::Delete; + if (bHasAnnotationMarkReferencesInDel) + { + StartRedline(m_pRedlineData, bLastRun); + } DoWriteAnnotationMarks(); + if (bHasAnnotationMarkReferencesInDel) + { + EndRedline(m_pRedlineData, bLastRun); + } + // if there is some redlining in the document, output it bool bSkipRedline = false; if (nLen == 1)
