sw: add API that provides fast access to marks of a text node

Desktop / LibreOffice - Miklos Vajna [collabora.co.uk] - 30 October 2014 06:14 UTC

sw::mark::MarkManager already provides two methods to provide not so slow mark access:

- some marks (bookmarks, annotation marks) have their own container, so it's possible to iterate over only those types, not all of them- the containers are sorted by the start position of the marks, so it's easy to ignore marks that are after the current text node

However, it's not possible to ignore marks ending before the current text node. This is a problem, as e.g. during ODF export, we have to iterate over every bookmark for each paragraph, so the operation is not linear.

On the other hand, the start and end position of bookmarks are stored using SwPosition, and the SwIndex of the SwPosition is already registered in the SwIndexReg of the SwTxtNode, so the text node sort of already knows what bookmarks start/end at the current paragraph, it just doesn't known which position belongs to what mark (if it belongs to a mark).

Fix the problem by adding a pointer to SwIndex that can optionally point back to the mark that owns it. Also, in the sw::mark::MarkBase methods (which are the only ones allowed to touch those positions) always set that pointer. With this, it's possible to get the bookmarks of a node (list of bookmarks which start or end in the current node) in a much faster way for text nodes.

3f98721 sw: add API that provides fast access to marks of a text node
sw/inc/index.hxx | 14 ++++++++++++++
sw/source/core/bastyp/index.cxx | 8 ++++++++
sw/source/core/crsr/bookmrk.cxx | 3 +++
3 files changed, 25 insertions(+)

Upstream: cgit.freedesktop.org


  • Share