diff options
-rw-r--r-- | sw/inc/IDocumentMarkAccess.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/inc/MarkManager.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/writer/writer.cxx | 6 |
4 files changed, 21 insertions, 3 deletions
diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index d63b58f606c4..bc8f2e1c03d6 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -279,6 +279,13 @@ class IDocumentMarkAccess */ virtual const_iterator_t findMark(const OUString& rMark) const =0; + /** Find the first Mark that does not start before. + + @returns + an iterator pointing to the mark, or pointing to getAllMarksEnd() if nothing was found. + */ + virtual const_iterator_t findFirstMarkNotStartsBefore(const SwPosition& rPos) const =0; + // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK ) /** check if the selection would delete a BOOKMARK */ diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 00681135b468..730da32625d4 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1410,6 +1410,16 @@ namespace sw::mark return IDocumentMarkAccess::iterator(ret); } + // find the first Mark that does not start before + IDocumentMarkAccess::const_iterator_t MarkManager::findFirstMarkNotStartsBefore(const SwPosition& rPos) const + { + return std::lower_bound( + m_vAllMarks.begin(), + m_vAllMarks.end(), + rPos, + CompareIMarkStartsBefore()); + } + IDocumentMarkAccess::const_iterator_t MarkManager::getAllMarksBegin() const { return m_vAllMarks.begin(); } diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx index ef0e79d74c11..dd7eb9f6f18b 100644 --- a/sw/source/core/inc/MarkManager.hxx +++ b/sw/source/core/inc/MarkManager.hxx @@ -81,6 +81,7 @@ namespace sw::mark { virtual const_iterator_t getAllMarksEnd() const override; virtual sal_Int32 getAllMarksCount() const override; virtual const_iterator_t findMark(const OUString& rName) const override; + virtual const_iterator_t findFirstMarkNotStartsBefore(const SwPosition& rPos) const override; // bookmarks virtual bool isBookmarkDeleted(SwPaM const& rPaM, bool isReplace) const override; diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index a90482bfb31a..e21e81e5239c 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -157,9 +157,9 @@ bool Writer::CopyNextPam( SwPaM ** ppPam ) sal_Int32 Writer::FindPos_Bkmk(const SwPosition& rPos) const { const IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess(); - const IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findFirstBookmarkStartsAfter(rPos); - if(ppBkmk != pMarkAccess->getBookmarksEnd()) - return ppBkmk - pMarkAccess->getBookmarksBegin(); + const IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findFirstMarkNotStartsBefore(rPos); + if(ppBkmk != pMarkAccess->getAllMarksEnd()) + return ppBkmk - pMarkAccess->getAllMarksBegin(); return -1; } |