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)