diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2019-08-29 15:17:58 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2019-08-30 10:45:20 +0200 |
commit | 2d5598d0c33930626fc47cf6387a4add25af84fc (patch) | |
tree | 2074812516bd67058f072c7a31be317f127f0ff4 | |
parent | d051dd8dab68b4dd109e1f5f89f6b96fdc6152fc (diff) |
SwAutoFormat::HasObjects() could be faster
Change-Id: I928401382ca986fb75de3689b9ef5e08474e2b85
Reviewed-on: https://gerrit.libreoffice.org/78278
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index c2fbfef86d82..40c4eec825aa 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -139,7 +139,7 @@ class SwAutoFormat void SetColl( sal_uInt16 nId, bool bHdLineOrText = false ); void GoNextPara(); - bool HasObjects(const SwTextFrame &); + static bool HasObjects(const SwTextFrame &); // TextNode methods const SwTextFrame * GetNextNode(bool isCheckEnd = true) const; @@ -349,20 +349,18 @@ bool SwAutoFormat::HasObjects(const SwTextFrame & rFrame) { // Is there something bound to the paragraph in the paragraph // like Frames, DrawObjects, ... - bool bRet = false; - const SwFrameFormats& rFormats = *m_pDoc->GetSpzFrameFormats(); - for( auto pFrameFormat : rFormats ) + SwNodeIndex node(*rFrame.GetTextNodeFirst()); + do { - const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor(); - if ((RndStdIds::FLY_AT_PAGE != rAnchor.GetAnchorId()) && - rAnchor.GetContentAnchor() && - sw::FrameContainsNode(rFrame, rAnchor.GetContentAnchor()->nNode.GetIndex())) + if (node.GetNode().GetAnchoredFlys() != nullptr) { - bRet = true; - break; + assert(!node.GetNode().GetAnchoredFlys()->empty()); + return true; } + ++node; } - return bRet; + while (sw::FrameContainsNode(rFrame, node.GetIndex())); + return false; } const SwTextFrame* SwAutoFormat::GetNextNode(bool const isCheckEnd) const |