sw/qa/extras/ooxmlexport/ooxmlexport20.cxx | 2 +- sw/source/filter/ww8/wrtw8nds.cxx | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-)
New commits: commit 5d6d7dc6d8f76808b80d6b12390e760cfcf8705d Author: Justin Luth <[email protected]> AuthorDate: Thu Feb 5 11:39:13 2026 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Feb 9 09:51:21 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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198773 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 884ee09e3000..2b0d35f01da9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport20.cxx @@ -301,7 +301,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 5d6b2227bb89..217a22e81536 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2569,10 +2569,14 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) AttrOutput().SetAnchorIsLinkedToNode( bPostponeWritingText && (FLY_POSTPONED != nStateOfFlyFrame) ); // 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.
