tdf#160700: Avoid both bookmark-start and bookmark-end at the same index
commit58e79c4394783033f61e1309214d9060e2f0adf2
authorMike Kaganski <mike.kaganski@collabora.com>
Thu, 18 Apr 2024 19:34:28 +0000 (19 00:34 +0500)
committerMike Kaganski <mike.kaganski@collabora.com>
Fri, 19 Apr 2024 03:23:38 +0000 (19 05:23 +0200)
tree3e6cf8917a1557e885d272f5d299f2c7f863993a
parentedef46e82e7e54a27004f9ee6e99108390736d12
tdf#160700: Avoid both bookmark-start and bookmark-end at the same index

There is a special handling of CrossRefBookmark, which has no end position
in the document model, but must span the whole paragraph, and end position
is generated explicitly.

Since commit 1d7ce421480d9170316533de03feb8d04eb5c767 (tdf#159438: when
there's no frame, close previous bookmark first, 2024-01-30), end marks
of an index are sorted before start marks of the same index, with the
expectation that start / end marks represent non-empty span. Dun in case
of empty paragraphs with a CrossRefBookmark, both start and end mark were
emitted into the same index, and the new sorting resulted in the wrong
order of the elements.

Fix this by checking if the start index is less than node end, and don't
handle CrossRefBookmark specially, if the check is negative. This writes
a single text:bookmark, instead of a text:bookmark-start, followed by a
text:bookmark-end.

Change-Id: I533c4f7814edddc3cf24b1213490f251d60b2273
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166266
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
sw/qa/extras/odfexport/data/tdf160700.odt [new file with mode: 0644]
sw/qa/extras/odfexport/odfexport2.cxx
sw/source/core/unocore/unoportenum.cxx