diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-11-07 16:14:21 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-11-14 13:26:20 +0100 |
commit | e64428fa982838bd40d068ac65943fcf3c1ed76f (patch) | |
tree | 00fc5f2a2cf9cd48f9ddba2625ead4ff9bd765cb | |
parent | 7b47afeed36c6b9089ac484e2331377d36251d0f (diff) |
do not iterate over all bookmarks in SwTxtNode::Update()
3f9872185e introduced new API for fast finding of marks to a specific text node,
so use that (code itself based on cb46aaf2d7).
This makes mailmerge faster (since it can create a huge document, and especially
with the change to use UNO bookmarks to mark starts of MM documents inside
the larger single document there can be a large number of marks).
Conflicts:
sw/source/core/txtnode/ndtxt.cxx
Change-Id: I30ec69acf423e9a62fae5f5492ed8744cb727a56
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 5c2326cad3d0..983c1eb71f6b 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1035,17 +1035,23 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, } } - const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppMark = - pMarkAccess->getMarksBegin(); - ppMark != pMarkAccess->getMarksEnd(); - ++ppMark) - { + // A text node already knows its marks via its SwIndexes. + std::set<const sw::mark::IMark*> aSeenMarks; + const SwIndex* next; + for (const SwIndex* pIndex = GetFirstIndex(); pIndex; pIndex = next ) + { + next = pIndex->GetNext(); + const sw::mark::IMark* pMark = pIndex->GetMark(); + if (!pMark) + continue; + // Only handle bookmarks once, if they start and end at this node as well. + if (aSeenMarks.find(pMark) != aSeenMarks.end()) + continue; + aSeenMarks.insert(pMark); // Bookmarks must never grow to either side, when // editing (directly) to the left or right (#i29942#)! // And a bookmark with same start and end must remain // to the left of the inserted text (used in XML import). - const ::sw::mark::IMark* const pMark = ppMark->get(); const SwPosition* pEnd = &pMark->GetMarkEnd(); SwIndex & rIdx = const_cast<SwIndex&>(pEnd->nContent); if( this == &pEnd->nNode.GetNode() && |