sw/qa/extras/ooxmlexport/ooxmlexport20.cxx | 2 +- sw/source/filter/ww8/wrtw8nds.cxx | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-)
New commits: commit fb273cf50f9fca0d0d561a6011299502f55f464e Author: Justin Luth <[email protected]> AuthorDate: Tue Feb 3 15:46:17 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Thu Feb 5 16:30:30 2026 +0100 tdf#170588 docx export: stop duplicating bookmark in empty w:r The comment says // Append bookmarks in this range after flys, // exclusive of final position of this range but it did nothing to exclude a final position of zero. When nNextAttr == nEnd, then AppendBookmark is run It is guarantined to run once at the end, and thus it is safe to eliminate it here. Probably worth noting that normally by definition nCurrentPos is exclusive of final position. The only time nCurrentPos == nEnd is when nEnd == 0 (since it loops while nCurrentPos < nEnd), so it seemed the clearest to say '0 != nEnd' instead of 'nCurrentPos == nEnd'. Change-Id: I5da3bc2a17c98faa7a73604e8a640ed456f25dd5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198628 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 37a6ac80147f..5396ae185977 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx @@ -315,7 +315,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo77129) // 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); + assertXPath(pXmlDoc, "//w:bookmarkStart", 4); } // Test the same testdoc used for testFdo77129. diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index ce32d66427f0..2c2ae163c486 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2530,10 +2530,14 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) // Append bookmarks in this range after flys, exclusive of final // position of this range - AppendBookmarks( rNode, nCurrentPos, nNextAttr - nCurrentPos, pRedlineData ); - // Sadly only possible for main or glossary document parts: ECMA-376 Part 1 sect. 11.3.2 - if ( m_nTextTyp == TXT_MAINTEXT ) - AppendAnnotationMarks(aAttrIter, nCurrentPos, nNextAttr - nCurrentPos); + if (0 != nEnd) // start == final position is written when nNextAttr == nEnd + { + AppendBookmarks(rNode, nCurrentPos, nNextAttr - nCurrentPos, pRedlineData); + // Sadly, comments are only possible + // for main or glossary document parts: ECMA-376 Part 1 sect. 11.3.2 + if (m_nTextTyp == TXT_MAINTEXT) + AppendAnnotationMarks(aAttrIter, nCurrentPos, nNextAttr - nCurrentPos); + } // At the moment smarttags are only written for paragraphs, at the // beginning of the paragraph.
