summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-08-05 11:59:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-08-07 12:05:53 +0200
commited172f76005d6e7b861b51199b5d897254b0c76b (patch)
treea5e58a9d6a6ca24a7dd8ce6aca740a7d75c98c35
parent49bca657d7d66ce75a49d2912d1fc86b3e89bcc4 (diff)
simplify IMark hierarchy (11)
The only thing using findFirstBookmarkNotStartsBefore is code that is only interested in Bookmark's, so change the name and return type, and use the m_vBookmarks vector, which is much more efficient. Change-Id: I7f7e6f98b9b7851756c06e57f1cd18cee98713d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171565 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/inc/IDocumentMarkAccess.hxx4
-rw-r--r--sw/source/core/doc/docbm.cxx10
-rw-r--r--sw/source/core/inc/MarkManager.hxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx12
-rw-r--r--sw/source/filter/writer/writer.cxx6
5 files changed, 15 insertions, 19 deletions
diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 60b2928067a1..8d20ee09a845 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -231,12 +231,12 @@ class IDocumentMarkAccess
*/
virtual const_iterator findMark(const OUString& rMark) const =0;
- /** Find the first Mark that does not start before.
+ /** Find the first Bookmark that does not start before.
@returns
an iterator pointing to the mark, or pointing to getAllMarksEnd() if nothing was found.
*/
- virtual const_iterator findFirstMarkNotStartsBefore(const SwPosition& rPos) const =0;
+ virtual std::vector<sw::mark::Bookmark*>::const_iterator findFirstBookmarkNotStartsBefore(const SwPosition& rPos) const =0;
// interface Bookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 6a82a22df15e..d5483ff4f3b2 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1341,14 +1341,14 @@ namespace sw::mark
return lcl_FindMarkByName<sw::mark::Bookmark>(rName, m_vBookmarks.begin(), m_vBookmarks.end());
}
- // find the first Mark that does not start before
- IDocumentMarkAccess::const_iterator MarkManager::findFirstMarkNotStartsBefore(const SwPosition& rPos) const
+ // find the first Bookmark that does not start before
+ std::vector<sw::mark::Bookmark*>::const_iterator MarkManager::findFirstBookmarkNotStartsBefore(const SwPosition& rPos) const
{
return std::lower_bound(
- m_vAllMarks.begin(),
- m_vAllMarks.end(),
+ m_vBookmarks.begin(),
+ m_vBookmarks.end(),
rPos,
- CompareIMarkStartsBefore<MarkBase>());
+ CompareIMarkStartsBefore<Bookmark>());
}
IDocumentMarkAccess::const_iterator MarkManager::getAllMarksBegin() const
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index 593caeac9984..21dfcfd8eeeb 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -82,7 +82,7 @@ namespace sw::mark {
virtual const_iterator getAllMarksEnd() const override;
virtual sal_Int32 getAllMarksCount() const override;
virtual const_iterator findMark(const OUString& rName) const override;
- virtual const_iterator findFirstMarkNotStartsBefore(const SwPosition& rPos) const override;
+ virtual std::vector<sw::mark::Bookmark*>::const_iterator findFirstBookmarkNotStartsBefore(const SwPosition& rPos) const override;
// bookmarks
virtual bool isBookmarkDeleted(SwPaM const& rPaM, bool isReplace) const override;
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index cc2935540361..3b7e2f887886 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -1270,31 +1270,27 @@ void SwHTMLWriter::OutAnchor( const OUString& rName )
void SwHTMLWriter::OutBookmarks()
{
// fetch current bookmark
- const ::sw::mark::MarkBase* pBookmark = nullptr;
IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess();
- if(m_nBkmkTabPos != -1)
- pBookmark = pMarkAccess->getAllMarksBegin()[m_nBkmkTabPos];
// Output all bookmarks in this paragraph. The content position
// for the moment isn't considered!
SwNodeOffset nNode = m_pCurrentPam->GetPoint()->GetNodeIndex();
while (m_nBkmkTabPos != -1)
{
+ const ::sw::mark::Bookmark* pBookmark = pMarkAccess->getBookmarksBegin()[m_nBkmkTabPos];
assert(pBookmark);
if (pBookmark->GetMarkPos().GetNodeIndex() != nNode)
break;
// The area of bookmarks is first ignored, because it's not read.
// first the SWG specific data:
- if ( dynamic_cast< const ::sw::mark::Bookmark* >(pBookmark) && !pBookmark->GetName().isEmpty() )
- {
+ if ( !pBookmark->GetName().isEmpty() )
OutAnchor( pBookmark->GetName() );
- }
- if( ++m_nBkmkTabPos >= pMarkAccess->getAllMarksCount() )
+ if( ++m_nBkmkTabPos >= pMarkAccess->getBookmarksCount() )
m_nBkmkTabPos = -1;
else
- pBookmark = pMarkAccess->getAllMarksBegin()[m_nBkmkTabPos];
+ pBookmark = pMarkAccess->getBookmarksBegin()[m_nBkmkTabPos];
}
decltype(m_aOutlineMarkPoss)::size_type nPos;
diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx
index 101ca7bcac47..9febf054e0d7 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 auto ppBkmk = pMarkAccess->findFirstMarkNotStartsBefore(rPos);
- if(ppBkmk != pMarkAccess->getAllMarksEnd())
- return ppBkmk - pMarkAccess->getAllMarksBegin();
+ const auto ppBkmk = pMarkAccess->findFirstBookmarkNotStartsBefore(rPos);
+ if(ppBkmk != pMarkAccess->getBookmarksEnd())
+ return ppBkmk - pMarkAccess->getBookmarksBegin();
return -1;
}