sw/qa/extras/ooxmlexport/ooxmlexport26.cxx | 15 +++++++++++++++ sw/source/filter/ww8/docxexport.cxx | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-)
New commits: commit f59f90465e0187f15217c909ada3fabf811a571d Author: Justin Luth <[email protected]> AuthorDate: Fri Jan 23 11:12:52 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Mon Jan 26 17:57:03 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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198158 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 7a0b872ebcc1..63a084c6a44a 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() ); } }
