sw/qa/extras/ooxmlexport/ooxmlexport20.cxx | 5 +++++ sw/source/filter/ww8/docxexport.cxx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-)
New commits: commit 282e7089dd063accc05fe97cea41dbeabb3bf2f9 Author: Justin Luth <[email protected]> AuthorDate: Tue Feb 3 13:05:08 2026 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Feb 9 09:40:22 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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198772 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx index cec10a22c424..884ee09e3000 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx @@ -297,6 +297,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 2c699648b450..57e06b2612a4 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -176,10 +176,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() ); - if ( nEnd == nCurrentPos ) + if (nEnd == nCurrentPos && rNode == pMark->GetMarkEnd().GetNode()) aEnds.push_back( pMark->GetName() ); } }
