sw/qa/extras/ooxmlexport/ooxmlexport26.cxx | 15 +++++++++++++++ sw/source/filter/ww8/docxexport.cxx | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-)
New commits: commit a0b87fade865d684e71b297efa6aea438f6dc235 Author: Justin Luth <[email protected]> AuthorDate: Fri Jan 23 11:12:52 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Fri Jan 23 22:38:42 2026 +0100 tdf#170457 docx export: only export comment start/end for this node Without this patch, LO was creating documents that not only had the comment indicators in the wrong position, but was also being (correctly) reported as corrupt by MS Word. make CppunitTest_sw_ooxmlexport26 CPPUNIT_TEST_NAME=testwDateValueFormat Change-Id: I237742274d5d57bb491e25116d90d42c231faced Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198018 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx index ee0014db29fd..055a49636e68 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx @@ -42,6 +42,21 @@ CPPUNIT_TEST_FIXTURE(Test, testwDateValueFormat) // - Actual : 44 // - validation error in OOXML export: Errors: 44 saveAndReload(TestFilter::DOCX); + + // tdf#170457: round-tripped document was indicated as corrupt by MS Word + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + xmlDocUniquePtr pXmlComments = parseExport(u"word/comments.xml"_ustr); + + int nComments = countXPathNodes(pXmlComments, "//w:comment"); + + int nCommentReferences = countXPathNodes(pXmlDoc, "//w:commentReference"); + // Each comment is referenced - the counts must match + CPPUNIT_ASSERT_EQUAL(nComments, nCommentReferences); + CPPUNIT_ASSERT_EQUAL(int(22), nCommentReferences); + + int nCommentStarts = countXPathNodes(pXmlDoc, "//w:commentRangeStart"); + int nCommentEnds = countXPathNodes(pXmlDoc, "//w:commentRangeEnd"); + CPPUNIT_ASSERT_EQUAL(nCommentStarts, nCommentEnds); } CPPUNIT_TEST_FIXTURE(Test, testTdf124491) diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index d1b255f3b6b3..525ea612e1a8 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -215,10 +215,10 @@ void DocxExport::AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 n const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex(); const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex(); - if ( nStart == nCurrentPos ) + if (nStart == nCurrentPos && rAttrs.GetNode() == pMark->GetMarkStart().GetNode()) aStarts.push_back( pMark->GetName() ); - if ( nEnd == nCurrentPos ) + if (nEnd == nCurrentPos && rAttrs.GetNode() == pMark->GetMarkEnd().GetNode()) aEnds.push_back( pMark->GetName() ); } }
