sw/qa/extras/ooxmlexport/ooxmlexport20.cxx |    5 +++++
 sw/source/filter/ww8/docxexport.cxx        |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit fe67e1899b3d3322b4e6721349af51a0c0416383
Author:     Justin Luth <[email protected]>
AuthorDate: Tue Feb 3 13:05:08 2026 -0500
Commit:     Justin Luth <[email protected]>
CommitDate: Thu Feb 5 14:59:48 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

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx
index 03537a938993..37a6ac80147f 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 525ea612e1a8..9a6a9e159898 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() );
         }
     }

Reply via email to