summaryrefslogtreecommitdiff
path: root/sw/inc/index.hxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-30 11:06:52 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-10-30 12:14:31 +0100
commit3f9872185efb1c5cf2362288f440971137df3c58 (patch)
treec7379a542afd9e030e8907e26fb7e2c0fda63658 /sw/inc/index.hxx
parent3707022b9b72f317c50a353c64ff21bdd0ffdb69 (diff)
sw: add API that provides fast access to marks of a text node
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. Change-Id: I7ceeff4dce852b4d72f2a73ae6a2423c7a781e41
Diffstat (limited to 'sw/inc/index.hxx')
-rw-r--r--sw/inc/index.hxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx
index 9f9c600f353d..e3648533d27d 100644
--- a/sw/inc/index.hxx
+++ b/sw/inc/index.hxx
@@ -26,6 +26,12 @@
class SwIndexReg;
struct SwPosition;
+namespace sw {
+namespace mark {
+class IMark;
+}
+}
+
/// Marks a character position inside a document model node.
class SW_DLLPUBLIC SwIndex
{
@@ -38,6 +44,9 @@ private:
SwIndex * m_pNext;
SwIndex * m_pPrev;
+ /// Pointer to a mark that owns this position to allow fast lookup of marks of an SwIndexReg.
+ const sw::mark::IMark* m_pMark;
+
SwIndex& ChgValue( const SwIndex& rIdx, sal_Int32 nNewValue );
void Init(sal_Int32 const nIdx);
void Remove();
@@ -92,6 +101,10 @@ public:
// Returns pointer to IndexArray (for RTTI at SwIndexReg).
const SwIndexReg* GetIdxReg() const { return m_pIndexReg; }
+ const SwIndex* GetNext() const { return m_pNext; }
+
+ const sw::mark::IMark* GetMark() const { return m_pMark; }
+ void SetMark(const sw::mark::IMark* pMark);
};
class SwIndexReg
@@ -119,6 +132,7 @@ public:
TYPEINFO();
void MoveTo( SwIndexReg& rArr );
+ const SwIndex* GetFirstIndex() const { return m_pFirst; }
};
#ifndef DBG_UTIL