sw/qa/extras/ooxmlexport/ooxmlexport20.cxx | 5 +++++ sw/source/filter/ww8/docxexport.cxx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-)
New commits: commit 61d5bb3c66192d95e27e4d843d09996814bce2c0 Author: Justin Luth <[email protected]> AuthorDate: Tue Feb 3 13:05:08 2026 -0500 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Feb 10 14:45:30 2026 +0100 tdf#170588 docx export: stop duplicating bookmark starts Bookmarks can span multiple nodes. Since we weren't checking the node we were often adding the bookmark start multiple times, once for the start node and again for the end node. This is guaranteed to happen for any bookmark starting at position zero, and possible for the other positions. An extra end bookmark doesn't matter, because it isn't written if it doesn't find the name in the starts. A similar fix was needed for comments in bug 170457. make CppunitTest_sw_ooxmlexport20 CPPUNIT_TEST_NAME=testFdo77129 Change-Id: I595595a2b48aabf861179ade1b3097fc31e2a12e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198620 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins (cherry picked from commit fe67e1899b3d3322b4e6721349af51a0c0416383) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198997 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx index f77f9aa65a4e..c39ae316a796 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx @@ -311,6 +311,11 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo77129) // Data was lost from this paragraph. assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[1]/w:t", u"Abstract"); + + // tdf#170588: stop duplicating bookmarkStarts + // Counts of bookmark Starts and Ends really ought to be identical... + assertXPath(pXmlDoc, "//w:bookmarkEnd", 4); + assertXPath(pXmlDoc, "//w:bookmarkStart", 5); } // Test the same testdoc used for testFdo77129. diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 63a084c6a44a..d06f58e228f3 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -177,10 +177,10 @@ void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos const sal_Int32 nStart = pMark->GetMarkStart().GetContentIndex(); const sal_Int32 nEnd = pMark->GetMarkEnd().GetContentIndex(); - if ( nStart == nCurrentPos ) + if (nStart == nCurrentPos && rNode == pMark->GetMarkStart().GetNode()) aStarts.push_back( pMark->GetName().toString() ); - if ( nEnd == nCurrentPos ) + if (nEnd == nCurrentPos && rNode == pMark->GetMarkEnd().GetNode()) aEnds.push_back( pMark->GetName().toString() ); } }
