From 08de15d3e5700b780266a1e0d7327d15412e48ce Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 11 Oct 2023 11:19:31 +0100 Subject: SwTextFly::GetAnchoredObjList never returns null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icd8a2aa356de24d977a72dc64825a03ed2f5b16d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157822 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/source/core/inc/txtfly.hxx | 8 ++++---- sw/source/core/text/frmform.cxx | 2 +- sw/source/core/text/itrform2.cxx | 2 +- sw/source/core/text/txtfly.cxx | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'sw') diff --git a/sw/source/core/inc/txtfly.hxx b/sw/source/core/inc/txtfly.hxx index e363934a8ba1..9047e127e7d8 100644 --- a/sw/source/core/inc/txtfly.hxx +++ b/sw/source/core/inc/txtfly.hxx @@ -156,7 +156,7 @@ class SwTextFly SwAnchoredObjList& InitAnchoredObjList(); public: - SwAnchoredObjList* GetAnchoredObjList() const; + SwAnchoredObjList& GetAnchoredObjList() const; private: /** @@ -311,11 +311,11 @@ public: SwRect GetFrameArea() const; }; -inline SwAnchoredObjList* SwTextFly::GetAnchoredObjList() const +inline SwAnchoredObjList& SwTextFly::GetAnchoredObjList() const { return mpAnchoredObjList - ? mpAnchoredObjList.get() - : &const_cast(this)->InitAnchoredObjList(); + ? *mpAnchoredObjList + : const_cast(this)->InitAnchoredObjList(); } inline void SwTextFly::SetTopRule() diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 495820336fb3..1e20d7e0e9bc 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -1867,7 +1867,7 @@ void SwTextFrame::FormatImpl(vcl::RenderContext* pRenderContext, SwParaPortion * if (aInf.GetTextFly().IsOn()) { SwRect const aRect(aInf.GetTextFly().GetFrameArea()); - for (SwAnchoredObject *const pObj : *aInf.GetTextFly().GetAnchoredObjList()) + for (SwAnchoredObject *const pObj : aInf.GetTextFly().GetAnchoredObjList()) { if (!aInf.GetTextFly().AnchoredObjToRect(pObj, aRect).IsEmpty()) { diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 6511d0ab45c9..7e4841fdb0c6 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2815,7 +2815,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf ) // Word style: if there is minimal space remaining, then handle that similar to a full line // and put the actual empty paragraph below the fly. SwTwips nLimit = MINLAY; - for (const auto& pObj : *rTextFly.GetAnchoredObjList()) + for (const auto& pObj : rTextFly.GetAnchoredObjList()) { auto pFlyFrame = pObj->DynCastFlyFrame(); if (!pFlyFrame) diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index 43be775725e9..ff5566f537ac 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -493,7 +493,7 @@ void SwTextFly::DrawTextOpaque( SwDrawTextInfo &rInf ) OSL_ENSURE( !m_bTopRule, "DrawTextOpaque: Wrong TopRule" ); // #i68520# - const SwAnchoredObjList::size_type nCount( m_bOn ? GetAnchoredObjList()->size() : 0 ); + const SwAnchoredObjList::size_type nCount( m_bOn ? GetAnchoredObjList().size() : 0 ); if (nCount > 0) { const SdrLayerID nHellId = m_pPage->getRootFrame()->GetCurrShell()->getIDocumentDrawModelAccess().GetHellId(); @@ -578,7 +578,7 @@ void SwTextFly::DrawFlyRect( OutputDevice* pOut, const SwRect &rRect ) SwRegionRects aRegion( rRect ); OSL_ENSURE( !m_bTopRule, "DrawFlyRect: Wrong TopRule" ); // #i68520# - const SwAnchoredObjList::size_type nCount( m_bOn ? GetAnchoredObjList()->size() : 0 ); + const SwAnchoredObjList::size_type nCount( m_bOn ? GetAnchoredObjList().size() : 0 ); if (nCount > 0) { const SdrLayerID nHellId = m_pPage->getRootFrame()->GetCurrShell()->getIDocumentDrawModelAccess().GetHellId(); @@ -1024,7 +1024,7 @@ SwTwips SwTextFly::GetMaxBottom(const SwBreakPortion& rPortion, const SwTextForm // Note that m_pCurrFrame is already swapped at this stage, so it's correct to bypass // SwRectFnSet here. SwTwips nRet = 0; - size_t nCount(m_bOn ? GetAnchoredObjList()->size() : 0); + size_t nCount(m_bOn ? GetAnchoredObjList().size() : 0); // Get the horizontal position of the break portion in absolute twips. The frame area is in // absolute twips, the frame's print area is relative to the frame area. Finally the portion's @@ -1101,7 +1101,7 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const bool bRet = false; // #i68520# - const SwAnchoredObjList::size_type nCount( m_bOn ? GetAnchoredObjList()->size() : 0 ); + const SwAnchoredObjList::size_type nCount( m_bOn ? GetAnchoredObjList().size() : 0 ); if (nCount > 0) { for( SwAnchoredObjList::size_type i = 0; i < nCount; ++i ) @@ -1180,7 +1180,7 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const // #i68520# SwAnchoredObjList::size_type SwTextFly::GetPos( const SwAnchoredObject* pAnchoredObj ) const { - SwAnchoredObjList::size_type nCount = GetAnchoredObjList()->size(); + SwAnchoredObjList::size_type nCount = GetAnchoredObjList().size(); SwAnchoredObjList::size_type nRet = 0; while ( nRet < nCount && pAnchoredObj != (*mpAnchoredObjList)[ nRet ] ) ++nRet; -- cgit