summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-11-29 18:36:52 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-12-26 18:26:32 +0100
commit6b09bec95747d3bd9871bab3f49142a2fca2d368 (patch)
treed634d74baec1919e1e37ebc094c051ab26e28d5f
parent1c2df42580f381ccfdd1863bc1da4c81314533aa (diff)
sw: use SAL_RET_MAYBENULL in Lower()
to catch issues like tdf#163325 Change-Id: I2d2e3e66bd376884d029aaf227b93aabe4ca5794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177555 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/source/core/access/accframebase.cxx7
-rw-r--r--sw/source/core/access/accnotextframe.cxx5
-rw-r--r--sw/source/core/crsr/crsrsh.cxx14
-rw-r--r--sw/source/core/crsr/pam.cxx12
-rw-r--r--sw/source/core/docnode/node2lay.cxx22
-rw-r--r--sw/source/core/draw/dflyobj.cxx11
-rw-r--r--sw/source/core/draw/dpage.cxx4
-rw-r--r--sw/source/core/draw/dview.cxx8
-rw-r--r--sw/source/core/frmedt/fefly1.cxx20
-rw-r--r--sw/source/core/frmedt/feflyole.cxx5
-rw-r--r--sw/source/core/frmedt/fetab.cxx23
-rw-r--r--sw/source/core/frmedt/tblsel.cxx15
-rw-r--r--sw/source/core/inc/layfrm.hxx4
-rw-r--r--sw/source/core/layout/atrfrm.cxx7
-rw-r--r--sw/source/core/layout/colfrm.cxx16
-rw-r--r--sw/source/core/layout/findfrm.cxx30
-rw-r--r--sw/source/core/layout/fly.cxx72
-rw-r--r--sw/source/core/layout/flylay.cxx13
-rw-r--r--sw/source/core/layout/frmtool.cxx10
-rw-r--r--sw/source/core/layout/ftnfrm.cxx74
-rw-r--r--sw/source/core/layout/layact.cxx6
-rw-r--r--sw/source/core/layout/laycache.cxx3
-rw-r--r--sw/source/core/layout/layouter.cxx10
-rw-r--r--sw/source/core/layout/pagechg.cxx31
-rw-r--r--sw/source/core/layout/paintfrm.cxx25
-rw-r--r--sw/source/core/layout/sectfrm.cxx95
-rw-r--r--sw/source/core/layout/ssfrm.cxx3
-rw-r--r--sw/source/core/layout/tabfrm.cxx117
-rw-r--r--sw/source/core/layout/trvlfrm.cxx34
-rw-r--r--sw/source/core/layout/wsfrm.cxx29
-rw-r--r--sw/source/core/text/frmform.cxx28
-rw-r--r--sw/source/core/text/inftxt.cxx15
-rw-r--r--sw/source/core/text/txtfly.cxx11
-rw-r--r--sw/source/core/text/txtftn.cxx3
-rw-r--r--sw/source/core/text/widorp.cxx3
-rw-r--r--sw/source/core/view/viewimp.cxx2
-rw-r--r--sw/source/core/view/viewsh.cxx7
37 files changed, 475 insertions, 319 deletions
diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx
index fc94259b5bfd..22f433e59003 100644
--- a/sw/source/core/access/accframebase.cxx
+++ b/sw/source/core/access/accframebase.cxx
@@ -90,12 +90,13 @@ void SwAccessibleFrameBase::GetStates( sal_Int64& rStateSet )
SwNodeType SwAccessibleFrameBase::GetNodeType( const SwFlyFrame *pFlyFrame )
{
SwNodeType nType = SwNodeType::Text;
- if( pFlyFrame->Lower() )
+ const SwFrame* pLower = pFlyFrame->Lower();
+ if( pLower )
{
- if( pFlyFrame->Lower()->IsNoTextFrame() )
+ if( pLower->IsNoTextFrame() )
{
const SwNoTextFrame *const pContentFrame =
- static_cast<const SwNoTextFrame *>(pFlyFrame->Lower());
+ static_cast<const SwNoTextFrame *>(pLower);
nType = pContentFrame->GetNode()->GetNodeType();
}
}
diff --git a/sw/source/core/access/accnotextframe.cxx b/sw/source/core/access/accnotextframe.cxx
index 0191da39aa18..6283c87080af 100644
--- a/sw/source/core/access/accnotextframe.cxx
+++ b/sw/source/core/access/accnotextframe.cxx
@@ -40,10 +40,11 @@ const SwNoTextNode *SwAccessibleNoTextFrame::GetNoTextNode() const
{
const SwNoTextNode *pNd = nullptr;
const SwFlyFrame *pFlyFrame = static_cast< const SwFlyFrame *>( GetFrame() );
- if( pFlyFrame->Lower() && pFlyFrame->Lower()->IsNoTextFrame() )
+ const SwFrame *pLower = pFlyFrame->Lower();
+ if( pLower && pLower->IsNoTextFrame() )
{
const SwNoTextFrame *pContentFrame =
- static_cast<const SwNoTextFrame *>(pFlyFrame->Lower());
+ static_cast<const SwNoTextFrame *>(pLower);
const SwContentNode* pSwContentNode = pContentFrame->GetNode();
if(pSwContentNode != nullptr)
{
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 67935972349a..14c144a0e5d5 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3747,14 +3747,14 @@ bool SwCursorShell::IsCursorReadonly() const
GetViewOptions()->IsFormView() /* Formula view */ )
{
SwFrame *pFrame = GetCurrFrame( false );
- const SwFlyFrame* pFly;
- const SwSection* pSection;
+ const SwFlyFrame* pFly = pFrame ? pFrame->FindFlyFrame() : nullptr;
+ const SwFrame* pLower = nullptr;
+ if( pFly && pFly->GetFormat()->GetEditInReadonly().GetValue())
+ pLower = pFly->Lower();
- if( pFrame && pFrame->IsInFly() &&
- (pFly = pFrame->FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
- pFly->Lower() &&
- !pFly->Lower()->IsNoTextFrame() &&
- !GetDrawView()->GetMarkedObjectList().GetMarkCount() )
+ const SwSection* pSection;
+ if (pLower && !pLower->IsNoTextFrame() &&
+ !GetDrawView()->GetMarkedObjectList().GetMarkCount())
{
return false;
}
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index be32e6d47676..710744b4b8ae 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -722,13 +722,13 @@ static const SwFrame* lcl_FindEditInReadonlyFrame( const SwFrame& rFrame )
{
const SwFrame* pRet = nullptr;
- const SwFlyFrame* pFly;
- const SwSectionFrame* pSectionFrame;
+ const SwFlyFrame* pFly = rFrame.FindFlyFrame();
+ const SwFrame* pLower = nullptr;
+ if(pFly && pFly->GetFormat()->GetEditInReadonly().GetValue())
+ pLower = pFly->Lower();
- if( rFrame.IsInFly() &&
- (pFly = rFrame.FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
- pFly->Lower() &&
- !pFly->Lower()->IsNoTextFrame() )
+ const SwSectionFrame* pSectionFrame;
+ if (pLower && !pLower->IsNoTextFrame())
{
pRet = pFly;
}
diff --git a/sw/source/core/docnode/node2lay.cxx b/sw/source/core/docnode/node2lay.cxx
index 312ce2dff440..6f96fd50e854 100644
--- a/sw/source/core/docnode/node2lay.cxx
+++ b/sw/source/core/docnode/node2lay.cxx
@@ -349,16 +349,15 @@ SwLayoutFrame* SwNode2LayImpl::UpperFrame( SwFrame* &rpFrame, const SwNode &rNod
// #i22922# - consider columned sections
// 'Go down' the section frame as long as the layout frame
// is found, which would contain content.
- while ( pFrame->IsLayoutFrame() &&
- static_cast<SwLayoutFrame*>(pFrame)->Lower() &&
- !static_cast<SwLayoutFrame*>(pFrame)->Lower()->IsFlowFrame() &&
- static_cast<SwLayoutFrame*>(pFrame)->Lower()->IsLayoutFrame() )
+ SwFrame* pLower = static_cast<SwLayoutFrame*>(pFrame)->Lower();
+ while ( pFrame->IsLayoutFrame() && pLower &&
+ !pLower->IsFlowFrame() && pLower->IsLayoutFrame() )
{
- pFrame = static_cast<SwLayoutFrame*>(pFrame)->Lower();
+ pFrame = pLower;
+ pLower = static_cast<SwLayoutFrame*>(pFrame)->Lower();
}
assert(pFrame->IsLayoutFrame());
- rpFrame = mbMaster ? nullptr
- : static_cast<SwLayoutFrame*>(pFrame)->Lower();
+ rpFrame = mbMaster ? nullptr : pLower;
assert((!rpFrame || rpFrame->IsFlowFrame()) &&
"<SwNode2LayImpl::UpperFrame(..)> - expected sibling isn't a flow frame." );
return static_cast<SwLayoutFrame*>(pFrame);
@@ -372,11 +371,12 @@ SwLayoutFrame* SwNode2LayImpl::UpperFrame( SwFrame* &rpFrame, const SwNode &rNod
rpFrame = nullptr;
// 'Go down' the section frame as long as the layout frame
// is found, which would contain content.
- while ( pUpper->Lower() &&
- !pUpper->Lower()->IsFlowFrame() &&
- pUpper->Lower()->IsLayoutFrame() )
+ SwFrame* pLower = pUpper->Lower();
+ while ( pLower && !pLower->IsFlowFrame() &&
+ pLower->IsLayoutFrame() )
{
- pUpper = static_cast<SwLayoutFrame*>(pUpper->Lower());
+ pUpper = static_cast<SwLayoutFrame*>(pLower);
+ pLower = pUpper->Lower();
}
return pUpper;
}
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 9b6ffb4b2939..d650b135d247 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -370,10 +370,11 @@ bool SwVirtFlyDrawObj::ContainsSwGrfNode() const
{
// RotGrfFlyFrame: Check if this is a SwGrfNode
const SwFlyFrame* pFlyFrame(GetFlyFrame());
+ const SwFrame* pLower = pFlyFrame ? pFlyFrame->Lower() : nullptr;
- if(nullptr != pFlyFrame && pFlyFrame->Lower() && pFlyFrame->Lower()->IsNoTextFrame())
+ if(pLower && pLower->IsNoTextFrame())
{
- const SwNoTextFrame *const pNTF(static_cast<const SwNoTextFrame*>(pFlyFrame->Lower()));
+ const SwNoTextFrame *const pNTF(static_cast<const SwNoTextFrame*>(pLower));
const SwGrfNode *const pGrfNd(pNTF->GetNode()->GetGrfNode());
@@ -1054,7 +1055,8 @@ void SwVirtFlyDrawObj::NbcResize(const Point& rRef, const Fraction& xFact, const
if( aSz != GetFlyFrame()->getFrameArea().SSize() )
{
//The width of the columns should not be too narrow
- if ( GetFlyFrame()->Lower() && GetFlyFrame()->Lower()->IsColumnFrame() )
+ SwFrame* pLower = GetFlyFrame()->Lower();
+ if ( pLower && pLower->IsColumnFrame() )
{
SwBorderAttrAccess aAccess( SwFrame::GetCache(), GetFlyFrame() );
const SwBorderAttrs &rAttrs = *aAccess.Get();
@@ -1286,7 +1288,8 @@ SdrObject* SwVirtFlyDrawObj::CheckMacroHit( const SdrObjMacroHitRec& rRec ) cons
if( rURL.GetMap() || !rURL.GetURL().isEmpty() )
{
SwRect aRect;
- if ( m_pFlyFrame->Lower() && m_pFlyFrame->Lower()->IsNoTextFrame() )
+ SwFrame* pLower = m_pFlyFrame->Lower();
+ if ( pLower && pLower->IsNoTextFrame() )
{
aRect = m_pFlyFrame->getFramePrintArea();
aRect += m_pFlyFrame->getFrameArea().Pos();
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index b082de341037..c7ef072eb127 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -123,11 +123,11 @@ const SdrPageGridFrameList* SwDPage::GetGridFrameList(
//The drawing demands all pages which overlap with the rest.
const SwRect aRect( *pRect );
const SwFrame *pPg = pSh->GetLayout()->Lower();
- do
+ while (pPg)
{ if ( pPg->getFrameArea().Overlaps( aRect ) )
::InsertGridFrame( const_cast<SwDPage*>(this)->m_pGridLst.get(), pPg );
pPg = pPg->GetNext();
- } while ( pPg );
+ }
}
else
{
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 6e688df3eacd..c13daea7e47a 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -153,7 +153,8 @@ static SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, s
if(pSwVirtFlyDrawObj)
{
- if(pSwVirtFlyDrawObj->GetFlyFrame()->Lower() && pSwVirtFlyDrawObj->GetFlyFrame()->Lower()->IsNoTextFrame())
+ SwFrame* pLower = pSwVirtFlyDrawObj->GetFlyFrame()->Lower();
+ if(pLower && pLower->IsNoTextFrame())
{
// the old method used IsNoTextFrame (should be for SW's own OLE and
// graphic's) to accept hit only based on outer bounds; nothing to do
@@ -867,9 +868,10 @@ void SwDrawView::CheckPossibilities()
if ( pFly )
{
pFrame = pFly->GetAnchorFrame();
- if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
+ const SwFrame* pLower = pFly->Lower();
+ if ( pLower && pLower->IsNoTextFrame() )
{
- const SwNoTextFrame *const pNTF(static_cast<const SwNoTextFrame*>(pFly->Lower()));
+ const SwNoTextFrame *const pNTF(static_cast<const SwNoTextFrame*>(pLower));
const SwOLENode *const pOLENd = pNTF->GetNode()->GetOLENode();
const SwGrfNode *const pGrfNd = pNTF->GetNode()->GetGrfNode();
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 4bed45e88f74..f8e68a65a001 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -1500,8 +1500,9 @@ Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference <
aResult = pFly->ChgSize( aSz );
// if the object changes, the contour is outside the object
- assert(pFly->Lower()->IsNoTextFrame());
- SwNoTextNode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetNoTextNode();
+ SwFrame* pLower = pFly->Lower();
+ assert(pLower && pLower->IsNoTextFrame());
+ SwNoTextNode *pNd = static_cast<SwNoTextFrame*>(pLower)->GetNode()->GetNoTextNode();
assert(pNd);
pNd->SetContour( nullptr );
ClrContourCache();
@@ -1598,9 +1599,10 @@ uno::Reference < embed::XEmbeddedObject > SwFEShell::GetOleRef() const
{
uno::Reference < embed::XEmbeddedObject > xObj;
SwFlyFrame * pFly = GetSelectedFlyFrame();
- if (pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame())
+ SwFrame* pLower = pFly ? pFly->Lower() : nullptr;
+ if (pLower && pLower->IsNoTextFrame())
{
- SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
+ SwOLENode *pNd = static_cast<SwNoTextFrame*>(pLower)->GetNode()->GetOLENode();
if (pNd)
xObj = pNd->GetOLEObj().GetOleRef();
}
@@ -1699,9 +1701,10 @@ const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
if (pFlyObj)
{
SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
- if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
+ SwFrame* pLower = pFly->Lower();
+ if ( pLower && pLower->IsNoTextFrame() )
{
- SwGrfNode *const pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode();
+ SwGrfNode *const pNd = static_cast<SwNoTextFrame*>(pLower)->GetNode()->GetGrfNode();
if ( pNd )
{
if ( pNd->IsGrfLink() )
@@ -1809,9 +1812,10 @@ ObjCntType SwFEShell::GetObjCntType( const SdrObject& rObj )
else if (const SwVirtFlyDrawObj *pFlyObj = dynamic_cast<const SwVirtFlyDrawObj*>(pInvestigatedObj))
{
const SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
- if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
+ const SwFrame* pLower = pFly->Lower();
+ if ( pLower && pLower->IsNoTextFrame() )
{
- if (static_cast<const SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode())
+ if (static_cast<const SwNoTextFrame*>(pLower)->GetNode()->GetGrfNode())
eType = OBJCNT_GRF;
else
eType = OBJCNT_OLE;
diff --git a/sw/source/core/frmedt/feflyole.cxx b/sw/source/core/frmedt/feflyole.cxx
index 59d5595725d8..d0f9a8680fc5 100644
--- a/sw/source/core/frmedt/feflyole.cxx
+++ b/sw/source/core/frmedt/feflyole.cxx
@@ -38,9 +38,10 @@ using namespace com::sun::star;
SwFlyFrame *SwFEShell::FindFlyFrame( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
{
SwFlyFrame *pFly = GetSelectedFlyFrame();
- if ( pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
+ SwFrame* pLower = pFly ? pFly->Lower() : nullptr;
+ if ( pLower && pLower->IsNoTextFrame() )
{
- SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
+ SwOLENode *pNd = static_cast<SwNoTextFrame*>(pLower)->GetNode()->GetOLENode();
if ( !pNd || pNd->GetOLEObj().GetOleRef() != xObj )
pFly = nullptr;
}
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 2c1be479eb90..8981a6ac3edd 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -1316,8 +1316,11 @@ bool SwFEShell::CheckHeadline( bool bRepeat ) const
}
else
{
- bRet = static_cast<SwLayoutFrame*>(pTab->Lower())->IsAnLower( pFrame ) ||
- pTab->IsInHeadline( *pFrame );
+ if (SwFrame* pLower = pTab->Lower())
+ {
+ bRet = static_cast<SwLayoutFrame*>(pLower)->IsAnLower( pFrame ) ||
+ pTab->IsInHeadline( *pFrame );
+ }
}
}
}
@@ -2034,8 +2037,12 @@ bool SwFEShell::SelTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDr
if( pFrame )
{
- while( pFrame && pFrame->Lower() && pFrame->Lower()->IsRowFrame() )
- pFrame = static_cast<const SwCellFrame*>( static_cast<const SwLayoutFrame*>( pFrame->Lower() )->Lower() );
+ const SwFrame* pLower = pFrame->Lower();
+ while( pLower && pLower->IsRowFrame() )
+ {
+ pFrame = static_cast<const SwCellFrame*>( static_cast<const SwLayoutFrame*>( pLower )->Lower() );
+ pLower = pFrame ? pFrame->Lower() : nullptr;
+ }
if( pFrame && pFrame->GetTabBox()->GetSttNd() &&
pFrame->GetTabBox()->GetSttNd()->IsInProtectSect() )
pFrame = nullptr;
@@ -2150,8 +2157,12 @@ SwTab SwFEShell::WhichMouseTabCol( const Point &rPt ) const
if( pFrame )
{
- while( pFrame && pFrame->Lower() && pFrame->Lower()->IsRowFrame() )
- pFrame = static_cast<const SwCellFrame*>(static_cast<const SwLayoutFrame*>(pFrame->Lower())->Lower());
+ const SwFrame* pLower = pFrame->Lower();
+ while( pLower && pLower->IsRowFrame() )
+ {
+ pFrame = static_cast<const SwCellFrame*>(static_cast<const SwLayoutFrame*>(pLower)->Lower());
+ pLower = pFrame ? pFrame->Lower() : nullptr;
+ }
if( pFrame && ((pFrame->GetTabBox()->GetSttNd() &&
pFrame->GetTabBox()->GetSttNd()->IsInProtectSect()) || (pFrame->GetTabBox()->getRowSpan() < 0)))
pFrame = nullptr;
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 5f35840addf2..8a1d324dbb8c 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -365,7 +365,8 @@ void GetTableSel( const SwLayoutFrame* pStart, const SwLayoutFrame* pEnd,
if ( pCell->GetNext() )
{
pCell = static_cast<const SwLayoutFrame*>(pCell->GetNext());
- if ( pCell->Lower() && pCell->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pCell->Lower();
+ if ( pLower && pLower->IsRowFrame() )
pCell = pCell->FirstCell();
}
else
@@ -830,7 +831,8 @@ bool GetAutoSumSel( const SwCursorShell& rShell, SwCellFrames& rBoxes )
if( pCell->GetNext() )
{
pCell = static_cast<const SwLayoutFrame*>(pCell->GetNext());
- if ( pCell->Lower() && pCell->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pCell->Lower();
+ if ( pLower && pLower->IsRowFrame() )
pCell = pCell->FirstCell();
}
else
@@ -1921,7 +1923,8 @@ void MakeSelUnions( SwSelUnions& rUnions, const SwLayoutFrame *pStart,
if ( pFirst->GetNext() )
{
pFirst = static_cast<const SwLayoutFrame*>(pFirst->GetNext());
- if ( pFirst->Lower() && pFirst->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pFirst->Lower();
+ if ( pLower && pLower->IsRowFrame() )
pFirst = pFirst->FirstCell();
}
else
@@ -2027,7 +2030,8 @@ bool CheckSplitCells( const SwCursor& rCursor, sal_uInt16 nDiv,
if ( pCell->GetNext() )
{
pCell = static_cast<const SwLayoutFrame*>(pCell->GetNext());
- if ( pCell->Lower() && pCell->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pCell->Lower();
+ if ( pLower && pLower->IsRowFrame() )
pCell = pCell->FirstCell();
}
else
@@ -2543,7 +2547,8 @@ void FndBox_::MakeNewFrames( SwTable &rTable, const sal_uInt16 nNumber,
lcl_UpdateRepeatedHeadlines( *pTable, true );
}
- OSL_ENSURE( static_cast<SwRowFrame*>(pTable->Lower())->GetTabLine() ==
+ SwFrame* pLower = pTable->Lower();
+ OSL_ENSURE( pLower && static_cast<SwRowFrame*>(pLower)->GetTabLine() ==
rTable.GetTabLines()[0], "MakeNewFrames: Table corruption!" );
}
}
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 3a48ae163915..bf24ab7e928b 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -98,8 +98,8 @@ public:
SwLayoutFrame( SwFrameFormat*, SwFrame* );
virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, PaintFrameMode mode = PAINT_ALL ) const override;
- const SwFrame *Lower() const { return m_pLower; }
- SwFrame *Lower() { return m_pLower; }
+ SAL_RET_MAYBENULL const SwFrame *Lower() const { return m_pLower; }
+ SAL_RET_MAYBENULL SwFrame *Lower() { return m_pLower; }
bool ContainsDeleteForbiddenLayFrame() const;
SW_DLLPUBLIC const SwContentFrame *ContainsContent() const;
inline SwContentFrame *ContainsContent();
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 0caff1dd2bb9..d79273d075e5 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3695,9 +3695,10 @@ IMapObject* SwFrameFormat::GetIMapObject( const Point& rPoint,
const SwFrame *pRef;
const SwNoTextNode *pNd = nullptr;
Size aOrigSz;
- if( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
+ const SwFrame* pLower = pFly->Lower();
+ if( pLower && pLower->IsNoTextFrame() )
{
- pRef = pFly->Lower();
+ pRef = pLower;
pNd = static_cast<const SwNoTextFrame*>(pRef)->GetNode()->GetNoTextNode();
aOrigSz = pNd->GetTwipSize();
}
@@ -3786,7 +3787,7 @@ bool IsFlyFrameFormatInHeader(const SwFrameFormat& rFormat)
}
SwPageFrame* pPageFrame = pFlyFrame->FindPageFrameOfAnchor();
SwFrame* pHeader = pPageFrame->Lower();
- if (pHeader->GetType() == SwFrameType::Header)
+ if (pHeader && pHeader->GetType() == SwFrameType::Header)
{
const SwFrame* pFrame = pFlyFrame->GetAnchorFrame();
while (pFrame)
diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx
index 18133b91332d..9ef13eee2162 100644
--- a/sw/source/core/layout/colfrm.cxx
+++ b/sw/source/core/layout/colfrm.cxx
@@ -83,10 +83,11 @@ void SwColumnFrame::dumpAsXml(xmlTextWriterPtr writer) const
static void lcl_RemoveColumns( SwLayoutFrame &rCont, sal_uInt16 nCnt )
{
- OSL_ENSURE( rCont.Lower() && rCont.Lower()->IsColumnFrame(),
+ SwFrame* pLower = rCont.Lower();
+ assert( pLower && pLower->IsColumnFrame() &&
"no columns to remove." );
- SwColumnFrame *pColumn = static_cast<SwColumnFrame*>(rCont.Lower());
+ SwColumnFrame *pColumn = static_cast<SwColumnFrame*>(pLower);
sw_RemoveFootnotes( pColumn, true, true );
while ( pColumn->GetNext() )
{
@@ -106,6 +107,7 @@ static void lcl_RemoveColumns( SwLayoutFrame &rCont, sal_uInt16 nCnt )
static SwLayoutFrame * lcl_FindColumns( SwLayoutFrame *pLay, sal_uInt16 nCount )
{
SwFrame *pCol = pLay->Lower();
+
if ( pLay->IsPageFrame() )
pCol = static_cast<SwPageFrame*>(pLay)->FindBodyCont()->Lower();
@@ -302,11 +304,11 @@ void SwLayoutFrame::ChgColumns( const SwFormatCol &rOld, const SwFormatCol &rNew
//actions during setup.
if ( pSave )
{
- OSL_ENSURE( Lower() && Lower()->IsLayoutFrame() &&
- static_cast<SwLayoutFrame*>(Lower())->Lower() &&
- static_cast<SwLayoutFrame*>(Lower())->Lower()->IsLayoutFrame(),
- "no column body." ); // ColumnFrames contain BodyFrames
- ::RestoreContent( pSave, static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(Lower())->Lower()), nullptr );
+ SwFrame* pLower = Lower();
+ assert(pLower && pLower->IsLayoutFrame());
+ SwFrame* pLowerLower = static_cast<SwLayoutFrame*>(pLower)->Lower();
+ assert(pLowerLower && pLowerLower->IsLayoutFrame() && "no column body."); // ColumnFrames contain BodyFrames
+ ::RestoreContent( pSave, static_cast<SwLayoutFrame*>(pLowerLower), nullptr );
}
}
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index 5f0cc8a0f256..f7a3bbd36d9d 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -104,9 +104,13 @@ const SwContentFrame *SwLayoutFrame::ContainsContent() const
const SwLayoutFrame *pLayLeaf = this;
do
{
+ const SwFrame* pLower = pLayLeaf->Lower();
while ( (!pLayLeaf->IsSctFrame() || pLayLeaf == this ) &&
- pLayLeaf->Lower() && pLayLeaf->Lower()->IsLayoutFrame() )
- pLayLeaf = static_cast<const SwLayoutFrame*>(pLayLeaf->Lower());
+ pLower && pLower->IsLayoutFrame() )
+ {
+ pLayLeaf = static_cast<const SwLayoutFrame*>(pLower);
+ pLower = pLayLeaf->Lower();
+ }
if( pLayLeaf->IsSctFrame() && pLayLeaf != this )
{
@@ -124,8 +128,8 @@ const SwContentFrame *SwLayoutFrame::ContainsContent() const
return static_cast<const SwContentFrame*>(pLayLeaf->GetNext());
}
}
- else if ( pLayLeaf->Lower() )
- return static_cast<const SwContentFrame*>(pLayLeaf->Lower());
+ else if ( pLower )
+ return static_cast<const SwContentFrame*>(pLower);
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
if( !IsAnLower( pLayLeaf) )
@@ -162,10 +166,14 @@ const SwFrame *SwLayoutFrame::ContainsAny( const bool _bInvestigateFootnoteForSe
const bool bNoFootnote = IsSctFrame() && !_bInvestigateFootnoteForSections;
do
{
+ const SwFrame* pLower = pLayLeaf->Lower();
while ( ( (!pLayLeaf->IsSctFrame() && !pLayLeaf->IsTabFrame())
|| pLayLeaf == this ) &&
- pLayLeaf->Lower() && pLayLeaf->Lower()->IsLayoutFrame() )
- pLayLeaf = static_cast<const SwLayoutFrame*>(pLayLeaf->Lower());
+ pLower && pLower->IsLayoutFrame() )
+ {
+ pLayLeaf = static_cast<const SwLayoutFrame*>(pLower);
+ pLower = pLayLeaf->Lower();
+ }
if( ( pLayLeaf->IsTabFrame() || pLayLeaf->IsSctFrame() )
&& pLayLeaf != this )
@@ -174,8 +182,8 @@ const SwFrame *SwLayoutFrame::ContainsAny( const bool _bInvestigateFootnoteForSe
// maintained on SaveContent and RestoreContent
return pLayLeaf;
}
- else if ( pLayLeaf->Lower() )
- return static_cast<const SwContentFrame*>(pLayLeaf->Lower());
+ else if ( pLower )
+ return static_cast<const SwContentFrame*>(pLower);
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
if( bNoFootnote && pLayLeaf && pLayLeaf->IsInFootnote() )
@@ -1694,6 +1702,7 @@ static SwCellFrame* lcl_FindCorrespondingCellFrame( const SwRowFrame& rOrigRow,
SwCellFrame* pRet = nullptr;
const SwCellFrame* pCell = static_cast<const SwCellFrame*>(rOrigRow.Lower());
SwCellFrame* pCorrCell = const_cast<SwCellFrame*>(static_cast<const SwCellFrame*>(rCorrRow.Lower()));
+ assert(pCell && pCorrCell && "lcl_FindCorrespondingCellFrame does not work");
while ( pCell != &rOrigCell && !pCell->IsAnLower( &rOrigCell ) )
{
@@ -1706,10 +1715,11 @@ static SwCellFrame* lcl_FindCorrespondingCellFrame( const SwRowFrame& rOrigRow,
if ( pCell != &rOrigCell )
{
// rOrigCell must be a lower of pCell. We need to recurse into the rows:
- assert(pCell->Lower() && pCell->Lower()->IsRowFrame() &&
+ const SwFrame* pLower = pCell->Lower();
+ assert(pLower && pLower->IsRowFrame() &&
"lcl_FindCorrespondingCellFrame does not work");
- const SwRowFrame* pRow = static_cast<const SwRowFrame*>(pCell->Lower());
+ const SwRowFrame* pRow = static_cast<const SwRowFrame*>(pLower);
while ( !pRow->IsAnLower( &rOrigCell ) )
pRow = static_cast<const SwRowFrame*>(pRow->GetNext());
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index a9a3ab1e07ca..0b5bf0210533 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -290,7 +290,8 @@ void SwFlyFrame::InsertCnt()
GetFormat()->GetDoc(), nIndex );
// NoText always have a fixed height.
- if ( Lower() && Lower()->IsNoTextFrame() )
+ SwFrame* pLower = Lower();
+ if ( pLower && pLower->IsNoTextFrame() )
{
mbFixSize = true;
m_bMinHeight = false;
@@ -612,7 +613,8 @@ void SwFlyFrame::UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow )
OSL_ENSURE( rContent.GetContentIdx(), ":-( No content prepared." );
SwNodeOffset nIndex = rContent.GetContentIdx()->GetIndex();
// Lower() means SwColumnFrame: this one contains another SwBodyFrame
- ::InsertCnt_( pFollow->Lower() ? const_cast<SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pFollow->Lower())->Lower()))
+ SwFrame* pLower = pFollow->Lower();
+ ::InsertCnt_( pLower ? const_cast<SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pLower)->Lower()))
: static_cast<SwLayoutFrame*>(pFollow),
pFollow->GetFormat()->GetDoc(), ++nIndex );
@@ -759,9 +761,9 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize &rFrameSize )
}
// If the Fly contains columns, we already need to set the Fly
// and the Columns to the required value or else we run into problems.
- if ( Lower() )
+ if (SwFrame* pLower = Lower())
{
- if ( Lower()->IsColumnFrame() )
+ if ( pLower->IsColumnFrame() )
{
const SwRect aOld( GetObjRectWithSpaces() );
const Size aOldSz( getFramePrintArea().SSize() );
@@ -787,7 +789,7 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize &rFrameSize )
setFrameAreaPositionValid(false);
bRet = true;
}
- else if ( Lower()->IsNoTextFrame() )
+ else if ( pLower->IsNoTextFrame() )
{
mbFixSize = true;
m_bMinHeight = false;
@@ -844,7 +846,9 @@ void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
SetNotifyBack();
if(eInvFlags & SwFlyFrameInvFlags::SetCompletePaint)
SetCompletePaint();
- if((eInvFlags & SwFlyFrameInvFlags::ClearContourCache) && Lower() && Lower()->IsNoTextFrame())
+
+ SwFrame* pLower = Lower();
+ if((eInvFlags & SwFlyFrameInvFlags::ClearContourCache) && pLower && pLower->IsNoTextFrame())
ClrContourCache( GetVirtDrawObj() );
SwRootFrame *pRoot;
if(eInvFlags & SwFlyFrameInvFlags::InvalidateBrowseWidth && nullptr != (pRoot = getRootFrame()))
@@ -921,10 +925,11 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
rInvFlags |= SwFlyFrameInvFlags::InvalidatePos | SwFlyFrameInvFlags::SetNotifyBack;
// Delete contour in the Node if necessary
- if ( Lower() && Lower()->IsNoTextFrame() &&
+ SwFrame* pLower = Lower();
+ if ( pLower && pLower->IsNoTextFrame() &&
!GetFormat()->GetSurround().IsContour() )
{
- SwNoTextNode *pNd = static_cast<SwNoTextNode*>(static_cast<SwNoTextFrame*>(Lower())->GetNode());
+ SwNoTextNode *pNd = static_cast<SwNoTextNode*>(static_cast<SwNoTextFrame*>(pLower)->GetNode());
if ( pNd->HasContour() )
pNd->SetContour( nullptr );
}
@@ -1063,17 +1068,17 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
nId = rIDDMA.GetHeavenId();
GetVirtDrawObj()->SetLayer( nId );
- if ( Lower() )
+ if ( SwFrame* pLower = Lower() )
{
// Delete contour in the Node if necessary
- if( Lower()->IsNoTextFrame() &&
+ if( pLower->IsNoTextFrame() &&
!GetFormat()->GetSurround().IsContour() )
{
- SwNoTextNode *pNd = static_cast<SwNoTextNode*>(static_cast<SwNoTextFrame*>(Lower())->GetNode());
+ SwNoTextNode *pNd = static_cast<SwNoTextNode*>(static_cast<SwNoTextFrame*>(pLower)->GetNode());
if ( pNd->HasContour() )
pNd->SetContour( nullptr );
}
- else if( !Lower()->IsColumnFrame() )
+ else if( !pLower->IsColumnFrame() )
{
SwFrame* pFrame = GetLastLower();
if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsUndersized() )
@@ -1163,9 +1168,11 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
break;
case RES_URL:
+ {
// The interface changes the frame size when interacting with text frames,
// the Map, however, needs to be relative to FrameSize().
- if ( (!Lower() || !Lower()->IsNoTextFrame()) && pNew && pOld &&
+ SwFrame* pLower = Lower();
+ if ( (!pLower || !pLower->IsNoTextFrame()) && pNew && pOld &&
static_cast<const SwFormatURL*>(pNew)->GetMap() && static_cast<const SwFormatURL*>(pOld)->GetMap() )
{
const SwFormatFrameSize &rSz = GetFormat()->GetFrameSize();
@@ -1182,8 +1189,9 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
pFormat->UnlockModify();
}
}
- // No invalidation necessary
- break;
+ }
+ // No invalidation necessary
+ break;
case RES_CHAIN:
if (pNew)
@@ -1255,8 +1263,9 @@ void SwFlyFrame::Invalidate_( SwPageFrame const *pPage )
{
// Very bad case: If the Fly is bound within another Fly which
// contains columns, the Format should be from that one.
+ SwFrame* pLower = pFrame->Lower();
if ( !pFrame->IsLocked() && !pFrame->IsColLocked() &&
- pFrame->Lower() && pFrame->Lower()->IsColumnFrame() )
+ pLower && pLower->IsColumnFrame() )
pFrame->InvalidateSize();
}
@@ -1419,7 +1428,8 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA
}
// Check column width and set it if needed
- if ( Lower() && Lower()->IsColumnFrame() )
+ SwFrame* pLower = Lower();
+ if ( pLower && pLower->IsColumnFrame() )
AdjustColumns( nullptr, false );
setFrameAreaSizeValid(true);
@@ -2346,7 +2356,8 @@ SwTwips SwFlyFrame::Grow_(SwTwips nDist, SwResizeLimitReason& reason, bool bTst)
SwTwips SwFlyFrame::Shrink_( SwTwips nDist, bool bTst )
{
- if( Lower() && !IsColLocked() && !HasFixSize() )
+ SwFrame* pLower = Lower();
+ if( pLower && !IsColLocked() && !HasFixSize() )
{
SwRectFnSet aRectFnSet(this);
SwTwips nHeight = aRectFnSet.GetHeight(getFrameArea());
@@ -2365,7 +2376,7 @@ SwTwips SwFlyFrame::Shrink_( SwTwips nDist, bool bTst )
if ( nVal <= 0 )
return 0;
- if ( Lower()->IsColumnFrame() )
+ if ( pLower->IsColumnFrame() )
{ // If it's a Column Frame, the Format takes control of the
// resizing (due to the adjustment).
if ( !bTst )
@@ -3053,11 +3064,21 @@ static SwTwips lcl_CalcAutoWidth( const SwLayoutFrame& rFrame )
// or 1 paragraph wider than its parent area.
if (rFrame.GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA))
{
- const SwFrame* pFrameRect = rFrame.IsFlyFrame() ? static_cast<const SwFlyFrame*>(&rFrame)->GetAnchorFrame() : rFrame.Lower()->FindPageFrame();
- SwTwips nParentWidth = rFrame.IsVertical() ? pFrameRect->getFramePrintArea().Height() : pFrameRect->getFramePrintArea().Width();
- if (nParagraphCount > 1 || nRet > nParentWidth)
+ const SwFrame* pFrameRect = nullptr;
+ if (rFrame.IsFlyFrame())
+ pFrameRect = static_cast<const SwFlyFrame*>(&rFrame)->GetAnchorFrame();
+ else
+ {
+ if (const SwFrame* pLower = rFrame.Lower())
+ pFrameRect = pLower->FindPageFrame();
+ }
+ if (pFrameRect)
{
- return nParentWidth;
+ SwTwips nParentWidth = rFrame.IsVertical() ? pFrameRect->getFramePrintArea().Height() : pFrameRect->getFramePrintArea().Width();
+ if (nParagraphCount > 1 || nRet > nParentWidth)
+ {
+ return nParentWidth;
+ }
}
}
@@ -3071,13 +3092,14 @@ bool SwFlyFrame::GetContour( tools::PolyPolygon& rContour,
{
vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
bool bRet = false;
- const bool bIsCandidate(Lower() && Lower()->IsNoTextFrame());
+ const SwFrame* pLower = Lower();
+ const bool bIsCandidate(pLower && pLower->IsNoTextFrame());
if(bIsCandidate)
{
if(GetFormat()->GetSurround().IsContour())
{
- SwNoTextNode *pNd = const_cast<SwNoTextNode*>(static_cast<const SwNoTextNode*>(static_cast<const SwNoTextFrame*>(Lower())->GetNode()));
+ SwNoTextNode *pNd = const_cast<SwNoTextNode*>(static_cast<const SwNoTextNode*>(static_cast<const SwNoTextFrame*>(pLower)->GetNode()));
// #i13147# - determine <GraphicObject> instead of <Graphic>
// in order to avoid load of graphic, if <SwNoTextNode> contains a graphic
// node and method is called for paint.
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 42ea0332f6eb..581f32c15c54 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -661,7 +661,8 @@ void SwFlyFreeFrame::CheckClip( const SwFormatFrameSize &rSz )
aFrm.Width ( std::max( tools::Long(MINLAY), aFrameRect.Width() ) );
}
- if ( Lower() && Lower()->IsColumnFrame() )
+ SwFrame* pLower = Lower();
+ if ( pLower && pLower->IsColumnFrame() )
{
ColLock(); //lock grow/shrink
const Size aTmpOldSize( getFramePrintArea().SSize() );
@@ -673,14 +674,14 @@ void SwFlyFreeFrame::CheckClip( const SwFormatFrameSize &rSz )
}
ChgLowersProp( aTmpOldSize );
- SwFrame *pLow = Lower();
do
{
- pLow->Calc(getRootFrame()->GetCurrShell()->GetOut());
+ pLower->Calc(getRootFrame()->GetCurrShell()->GetOut());
// also calculate the (Column)BodyFrame
- static_cast<SwLayoutFrame*>(pLow)->Lower()->Calc(getRootFrame()->GetCurrShell()->GetOut());
- pLow = pLow->GetNext();
- } while ( pLow );
+ if (SwFrame* pLowerLower = static_cast<SwLayoutFrame*>(pLower)->Lower())
+ pLowerLower->Calc(getRootFrame()->GetCurrShell()->GetOut());
+ pLower = pLower->GetNext();
+ } while ( pLower );
::CalcContent( this );
ColUnlock();
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 2f1963f456fa..8205ee2680a9 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -427,7 +427,8 @@ void SwFrameNotify::ImplDestroy()
// #i61999#
// no invalidation of columned Writer fly frames, because automatic
// width doesn't make sense for such Writer fly frames.
- if ( !pFly->Lower() || pFly->Lower()->IsColumnFrame() )
+ SwFrame* pLower = pFly->Lower();
+ if ( !pLower || pLower->IsColumnFrame() )
return;
const SwFormatFrameSize &rFrameSz = pFly->GetFormat()->GetFrameSize();
@@ -617,9 +618,11 @@ void SwLayNotify::ImplDestroy()
else if( pLay->IsSctFrame() )
pLay->InvalidateNextPos();
}
+
+ SwFrame* pLower = pLay->Lower();
if ( !IsLowersComplete() &&
!(pLay->GetType()&(SwFrameType::Fly|SwFrameType::Section) &&
- pLay->Lower() && pLay->Lower()->IsColumnFrame()) &&
+ pLower && pLower->IsColumnFrame()) &&
(bPos || bNotify) &&
!(pLay->GetType() & (SwFrameType::Row|SwFrameType::Tab|SwFrameType::FtnCont|SwFrameType::Page|SwFrameType::Root)))
{
@@ -3548,7 +3551,8 @@ void Notify_Background( const SdrObject* pObj,
}
if( pFly->IsFlyLayFrame() )
{
- if( pFly->Lower() && pFly->Lower()->IsColumnFrame() &&
+ SwFrame* pLower = pFly->Lower();
+ if( pLower && pLower->IsColumnFrame() &&
pFly->getFrameArea().Bottom() >= rRect.Top() &&
pFly->getFrameArea().Top() <= rRect.Bottom() &&
pFly->getFrameArea().Right() >= rRect.Left() &&
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 4e35abc9d43d..5bb3e3f4623b 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -128,9 +128,10 @@ static bool lcl_NextFootnoteBoss( SwFootnoteBossFrame* &rpBoss, SwPageFrame* &rp
SwSectionFrame* pSct = rpBoss->FindSctFrame()->GetFollow();
if( pSct )
{
- OSL_ENSURE( pSct->Lower() && pSct->Lower()->IsColumnFrame(),
+ SwFrame* pLower = pSct->Lower();
+ OSL_ENSURE( pLower && pLower->IsColumnFrame(),
"Where's the column?" );
- rpBoss = static_cast<SwColumnFrame*>(pSct->Lower());
+ rpBoss = static_cast<SwColumnFrame*>(pLower);
SwPageFrame* pOld = rpPage;
rpPage = pSct->FindPageFrame();
return pOld != rpPage;
@@ -148,8 +149,9 @@ static bool lcl_NextFootnoteBoss( SwFootnoteBossFrame* &rpBoss, SwPageFrame* &rp
if( rpPage )
{
SwLayoutFrame* pBody = rpPage->FindBodyCont();
- if( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame() )
- rpBoss = static_cast<SwFootnoteBossFrame*>(pBody->Lower()); // first column
+ SwFrame* pLower = pBody ? pBody->Lower() : nullptr;
+ if (pLower && pLower->IsColumnFrame() )
+ rpBoss = static_cast<SwFootnoteBossFrame*>(pLower); // first column
}
return true;
}
@@ -801,8 +803,9 @@ SwLayoutFrame *SwFrame::GetNextFootnoteLeaf( MakePageType eMakePage )
{
// If this page has columns, then go to the first one
SwLayoutFrame* pLay = pBoss->FindBodyCont();
- if( pLay && pLay->Lower() && pLay->Lower()->IsColumnFrame() )
- pBoss = static_cast<SwFootnoteBossFrame*>(pLay->Lower());
+ SwFrame* pLower = pLay ? pLay->Lower() : nullptr;
+ if( pLower && pLower->IsColumnFrame() )
+ pBoss = static_cast<SwFootnoteBossFrame*>(pLower);
}
// found column/page - add myself
SwFootnoteContFrame *pCont = pBoss->FindFootnoteCont();
@@ -898,7 +901,8 @@ SwLayoutFrame *SwFrame::GetPrevFootnoteLeaf( MakePageType eMakeFootnote )
// We have the previous page, we might need to find the last column of it
if( pBody )
{
- if ( pBody->Lower() && pBody->Lower()->IsColumnFrame() )
+ SwFrame* pLower = pBody->Lower();
+ if ( pLower && pLower->IsColumnFrame() )
{
pNxtBoss = static_cast<SwFootnoteBossFrame*>(pBody->GetLastLower());
}
@@ -1026,17 +1030,19 @@ void sw_RemoveFootnotes( SwFootnoteBossFrame* pBoss, bool bPageOnly, bool bEndNo
// foot/endnotes. If the last lower frame of the bodyframe is
// a multicolumned sectionframe, it may contain footnotes, too.
SwLayoutFrame* pBody = pBoss->FindBodyCont();
- if( pBody && pBody->Lower() )
+ if( pBody )
{
SwFrame* pLow = pBody->Lower();
while (pLow)
{
if( pLow->IsSctFrame() && ( !pLow->GetNext() ||
- static_cast<SwSectionFrame*>(pLow)->IsAnyNoteAtEnd() ) &&
- static_cast<SwSectionFrame*>(pLow)->Lower() &&
- static_cast<SwSectionFrame*>(pLow)->Lower()->IsColumnFrame() )
- sw_RemoveFootnotes( static_cast<SwColumnFrame*>(static_cast<SwSectionFrame*>(pLow)->Lower()),
- bPageOnly, bEndNotes );
+ static_cast<SwSectionFrame*>(pLow)->IsAnyNoteAtEnd() ) )
+ {
+ SwFrame* pLowerLower = static_cast<SwSectionFrame*>(pLow)->Lower();
+ if (pLowerLower && pLowerLower->IsColumnFrame() )
+ sw_RemoveFootnotes( static_cast<SwColumnFrame*>(pLowerLower),
+ bPageOnly, bEndNotes );
+ }
pLow = pLow->GetNext();
}
}
@@ -1051,12 +1057,13 @@ void SwRootFrame::RemoveFootnotes( SwPageFrame *pPage, bool bPageOnly, bool bEnd
if ( !pPage )
pPage = static_cast<SwPageFrame*>(Lower());
- do
+ while (pPage)
{ // On columned pages we have to clean up in all columns
SwFootnoteBossFrame* pBoss;
SwLayoutFrame* pBody = pPage->FindBodyCont();
- if( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame() )
- pBoss = static_cast<SwFootnoteBossFrame*>(pBody->Lower()); // the first column
+ SwFrame* pLower = pBody ? pBody->Lower() : nullptr;
+ if( pLower && pLower->IsColumnFrame() )
+ pBoss = static_cast<SwFootnoteBossFrame*>(pLower); // the first column
else
pBoss = pPage; // no columns
sw_RemoveFootnotes( pBoss, bPageOnly, bEndNotes );
@@ -1075,8 +1082,8 @@ void SwRootFrame::RemoveFootnotes( SwPageFrame *pPage, bool bPageOnly, bool bEnd
}
else
break;
+ }
- } while ( pPage );
}
/// Change the page template of the footnote pages
@@ -1586,11 +1593,12 @@ static SwPageFrame* lcl_GetApproximateFootnotePage(const bool bEnd, const SwPage
while (pNxt && (bEnd ? pNxt->IsEndNotePage() : pNxt->IsFootnotePage() && !pNxt->IsEndNotePage()))
{
const SwFootnoteContFrame *pCont = pNxt->FindFootnoteCont();
- if (pCont && pCont->Lower())
+ const SwFrame* pLower = pCont ? pCont->Lower() : nullptr;
+ if (pLower)
{
- OSL_ENSURE( pCont->Lower()->IsFootnoteFrame(), "no footnote in the container" );
+ OSL_ENSURE( pLower->IsFootnoteFrame(), "no footnote in the container" );
if (nStPos > ::lcl_FindFootnotePos(pDoc,
- static_cast<const SwFootnoteFrame*>(pCont->Lower())->GetAttr()))
+ static_cast<const SwFootnoteFrame*>(pLower)->GetAttr()))
{
pPage = pNxt;
pNxt = static_cast<const SwPageFrame*>(pPage->GetNext());
@@ -1934,7 +1942,8 @@ void SwFootnoteBossFrame::CollectFootnotes( const SwContentFrame* _pRef,
return;
SwLayoutFrame* pBody = pPg->FindBodyCont();
- if( pBody->Lower() && pBody->Lower()->IsColumnFrame() )
+ const SwFrame* pLower = pBody->Lower();
+ if( pLower && pLower->IsColumnFrame() )
{
// multiple columns on one page => search last column
_pOld = static_cast<SwFootnoteBossFrame*>(pBody->GetLastLower());
@@ -2682,10 +2691,11 @@ SwTwips SwFootnoteBossFrame::GetVarSpace() const
// the bottom of the last contentfrm
if( pSect->IsEndnAtEnd() ) // endnotes allowed?
{
- OSL_ENSURE( !Lower() || !Lower()->GetNext() || Lower()->GetNext()->
+ const SwFrame* pLower = Lower();
+ OSL_ENSURE( !pLower || !pLower->GetNext() || pLower->GetNext()->
IsFootnoteContFrame(), "FootnoteContainer expected" );
- const SwFootnoteContFrame* pCont = Lower() ?
- static_cast<const SwFootnoteContFrame*>(Lower()->GetNext()) : nullptr;
+ const SwFootnoteContFrame* pCont = pLower ?
+ static_cast<const SwFootnoteContFrame*>(pLower->GetNext()) : nullptr;
if( pCont )
{
const SwFootnoteFrame* pFootnote = static_cast<const SwFootnoteFrame*>(pCont->Lower());
@@ -2693,7 +2703,7 @@ SwTwips SwFootnoteBossFrame::GetVarSpace() const
{
if( pFootnote->GetAttr()->GetFootnote().IsEndNote() )
{ // endnote found
- const SwFrame* pFrame = static_cast<const SwLayoutFrame*>(Lower())->Lower();
+ const SwFrame* pFrame = static_cast<const SwLayoutFrame*>(pLower)->Lower();
if( pFrame )
{
while( pFrame->GetNext() )
@@ -2774,9 +2784,10 @@ SwNeighbourAdjust SwFootnoteBossFrame::NeighbourhoodAdjustment_() const
void SwPageFrame::SetColMaxFootnoteHeight()
{
SwLayoutFrame *pBody = FindBodyCont();
- if( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame() )
+ SwFrame* pLower = pBody ? pBody->Lower() : nullptr;
+ if( pLower && pLower->IsColumnFrame() )
{
- SwColumnFrame* pCol = static_cast<SwColumnFrame*>(pBody->Lower());
+ SwColumnFrame* pCol = static_cast<SwColumnFrame*>(pLower);
do
{
pCol->SetMaxFootnoteHeight( GetMaxFootnoteHeight() );
@@ -2959,13 +2970,14 @@ bool SwContentFrame::MoveFootnoteCntFwd( bool bMakePage, SwFootnoteBossFrame *pO
// area inside of a footnote (or only footnote in an area)?
if( pSect->IsInFootnote() )
{
- if( pTmpFootnote->Lower() && pTmpFootnote->Lower()->IsSctFrame() &&
- pSect->GetFollow() == static_cast<SwSectionFrame*>(pTmpFootnote->Lower()) )
- pNewUp = static_cast<SwSectionFrame*>(pTmpFootnote->Lower());
+ SwFrame* pLower = pTmpFootnote->Lower();
+ if( pLower && pLower->IsSctFrame() &&
+ pSect->GetFollow() == static_cast<SwSectionFrame*>(pLower) )
+ pNewUp = static_cast<SwSectionFrame*>(pLower);
else
{
pNewUp = new SwSectionFrame( *pSect, false );
- pNewUp->InsertBefore( pTmpFootnote, pTmpFootnote->Lower() );
+ pNewUp->InsertBefore( pTmpFootnote, pLower );
static_cast<SwSectionFrame*>(pNewUp)->Init();
{
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 98de8dc1370d..6483745afd50 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -160,9 +160,9 @@ bool SwLayAction::PaintWithoutFlys( const SwRect &rRect, const SwContentFrame *p
// Fly frame without a lower have to be subtracted from paint region.
// For checking, if fly frame contains transparent graphic or
// has surrounded contour, assure that fly frame has a lower
- if ( pFly->Lower() &&
- pFly->Lower()->IsNoTextFrame() &&
- ( static_cast<SwNoTextFrame*>(pFly->Lower())->IsTransparent() ||
+ SwFrame* pLower = pFly->Lower();
+ if ( pLower && pLower->IsNoTextFrame() &&
+ ( static_cast<SwNoTextFrame*>(pLower)->IsTransparent() ||
pFly->GetFormat()->GetSurround().IsContour() )
)
{
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx
index 75ccf1ac4686..3306f303ee33 100644
--- a/sw/source/core/layout/laycache.cxx
+++ b/sw/source/core/layout/laycache.cxx
@@ -937,7 +937,8 @@ bool SwLayHelper::CheckInsert( SwNodeOffset nNodeIndex )
}
mrpLay = pSct;
- if ( mrpLay->Lower() && mrpLay->Lower()->IsLayoutFrame() )
+ SwFrame* pLower = mrpLay->Lower();
+ if ( pLower && pLower->IsLayoutFrame() )
mrpLay = mrpLay->GetNextLayoutLeaf();
}
}
diff --git a/sw/source/core/layout/layouter.cxx b/sw/source/core/layout/layouter.cxx
index 5bed8fcba2b5..29c333ef5fb8 100644
--- a/sw/source/core/layout/layouter.cxx
+++ b/sw/source/core/layout/layouter.cxx
@@ -93,8 +93,11 @@ void SwEndnoter::CollectEndnote( SwFootnoteFrame* pFootnote )
}
else
{
- OSL_ENSURE( pNxt->Lower() && pNxt->Lower()->IsSctFrame(),
+#ifdef DBG_UTIL
+ SwFrame* pLower = pNxt->Lower();
+ OSL_ENSURE( pLower && pLower->IsSctFrame(),
"Endnote without content?" );
+#endif
pNxt->Cut();
SwFrame::DestroyFrame(pNxt);
}
@@ -129,11 +132,12 @@ void SwEndnoter::InsertEndnotes()
m_pSect = nullptr;
return;
}
- OSL_ENSURE( m_pSect->Lower() && m_pSect->Lower()->IsFootnoteBossFrame(),
+ SwFrame* pLower = m_pSect->Lower();
+ OSL_ENSURE( pLower && pLower->IsFootnoteBossFrame(),
"InsertEndnotes: Where's my column?" );
SwFrame* pRef = m_pSect->FindLastContent( SwFindMode::MyLast );
SwFootnoteBossFrame *pBoss = pRef ? pRef->FindFootnoteBossFrame()
- : static_cast<SwFootnoteBossFrame*>(m_pSect->Lower());
+ : static_cast<SwFootnoteBossFrame*>(pLower);
pBoss->MoveFootnotes_( *m_pEndArr );
m_pEndArr.reset();
m_pSect = nullptr;
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index ab18682e528d..e577d7da5477 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -88,7 +88,7 @@ void SwBodyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
SwTwips nHeight = GetUpper()->getFramePrintArea().Height();
SwTwips nWidth = GetUpper()->getFramePrintArea().Width();
const SwFrame *pFrame = GetUpper()->Lower();
- do
+ while (pFrame)
{
if ( pFrame != this )
{
@@ -98,7 +98,7 @@ void SwBodyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
nHeight -= pFrame->getFrameArea().Height();
}
pFrame = pFrame->GetNext();
- } while ( pFrame );
+ }
if ( nHeight < 0 )
{
@@ -1044,11 +1044,16 @@ bool IsPageFrameEmpty(SwPageFrame const& rPage)
}
// optimization: check first if essential objects exist.
- const SwLayoutFrame* pBody = nullptr;
- if ( bExistEssentialObjs ||
- rPage.FindFootnoteCont() ||
- (nullptr != (pBody = rPage.FindBodyCont()) &&
- ( pBody->ContainsContent() ||
+ if (bExistEssentialObjs)
+ return false;
+ else if (rPage.FindFootnoteCont())
+ return false;
+ else
+ {
+ if (const SwLayoutFrame* pBody = rPage.FindBodyCont())
+ {
+ const SwFrame* pLower = pBody->Lower();
+ if ( pBody->ContainsContent() ||
// check for section frames that are being formatted on the stack
rPage.ContainsDeleteForbiddenLayFrame() ||
// #i47580#
@@ -1057,14 +1062,12 @@ bool IsPageFrameEmpty(SwPageFrame const& rPage)
// instead of ContainsContent() to cover the empty-table-case,
// but I'm not fully sure, since ContainsAny() also returns
// SectionFrames. Therefore I prefer to do it the safe way:
- ( pBody->Lower() && pBody->Lower()->IsTabFrame() ) ) ) )
- {
- return false;
- }
- else
- {
- return true;
+ ( pLower && pLower->IsTabFrame() ) )
+ return false;
+ }
}
+
+ return true;
}
} // namespace sw
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index a24963e7afca..d8b2a541dbf7 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1450,17 +1450,19 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
//contained in the hell layer.
const IDocumentDrawModelAccess& rIDDMA = pFly->GetFormat()->getIDocumentDrawModelAccess();
bool bHell = pSdrObj->GetLayer() == rIDDMA.GetHellId();
- if ( (bStopOnHell && bHell) ||
- /// Change internal order of condition
- /// first check "!bHell", then "..->Lower()" and "..->IsNoTextFrame()"
- /// have not to be performed, if frame is in "Hell"
- ( !bHell && pFly->Lower() && pFly->Lower()->IsNoTextFrame() &&
- (static_cast<SwNoTextFrame const*>(pFly->Lower())->IsTransparent() ||
- static_cast<SwNoTextFrame const*>(pFly->Lower())->HasAnimation() ||
+ if (bStopOnHell && bHell)
+ continue;
+
+ /// Change internal order of condition
+ /// first check "!bHell", then "..->Lower()" and "..->IsNoTextFrame()"
+ /// have not to be performed, if frame is in "Hell"
+ const SwFrame* pLower = pFly->Lower();
+ if (!bHell && pLower && pLower->IsNoTextFrame() &&
+ (static_cast<SwNoTextFrame const*>(pLower)->IsTransparent() ||
+ static_cast<SwNoTextFrame const*>(pLower)->HasAnimation() ||
pFly->GetFormat()->GetSurround().IsContour()
)
)
- )
continue;
// Own if-statements for transparent background/shadow of fly frames
@@ -4008,7 +4010,7 @@ void SwPageFrame::PaintDecorators( ) const
if ( gProp.pSGlobalShell->IsShowHeaderFooterSeparator( FrameControlType::Header ) )
{
const SwFrame* pHeaderFrame = Lower();
- if ( !pHeaderFrame->IsHeaderFrame() )
+ if ( pHeaderFrame && !pHeaderFrame->IsHeaderFrame() )
pHeaderFrame = nullptr;
tools::Long nHeaderYOff = aBodyRect.Top();
@@ -7069,8 +7071,9 @@ void SwLayoutFrame::RefreshLaySubsidiary( const SwPageFrame *pPage,
{
if ( pFly->IsFlyInContentFrame() && pFly->getFrameArea().Overlaps( rRect ) )
{
- if ( !pFly->Lower() || !pFly->Lower()->IsNoTextFrame() ||
- !static_cast<const SwNoTextFrame*>(pFly->Lower())->HasAnimation())
+ SwFrame* pLower = pFly->Lower();
+ if ( !pLower || !pLower->IsNoTextFrame() ||
+ !static_cast<const SwNoTextFrame*>(pLower)->HasAnimation())
pFly->RefreshLaySubsidiary( pPage, rRect );
}
}
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index bbadb01b5a02..32341794cbae 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -570,8 +570,12 @@ SwSectionFrame* SwSectionFrame::SplitSect( SwFrame* pFrameStartAfter, SwFrame* p
{
SwLayoutFrame* pLay = pNew;
// Search for last layout frame, e.g. for columned sections.
- while( pLay->Lower() && pLay->Lower()->IsLayoutFrame() )
- pLay = static_cast<SwLayoutFrame*>(pLay->Lower());
+ SwFrame* pLower = pLay->Lower();
+ while( pLower && pLower->IsLayoutFrame() )
+ {
+ pLay = static_cast<SwLayoutFrame*>(pLower);
+ pLower = pLay->Lower();
+ }
::RestoreContent( pSav, pLay, nullptr );
}
InvalidateSize_();
@@ -667,7 +671,8 @@ namespace
{
SwLayoutFrame* FirstLeaf(SwSectionFrame* pLayFrame)
{
- if (pLayFrame->Lower() && pLayFrame->Lower()->IsColumnFrame())
+ SwFrame* pLower = pLayFrame->Lower();
+ if (pLower && pLower->IsColumnFrame())
return pLayFrame->GetNextLayoutLeaf();
return pLayFrame;
}
@@ -755,7 +760,8 @@ void SwSectionFrame::MoveContentAndDelete( SwSectionFrame* pDel, bool bSave )
else if( pPrvSct && pPrvSct->GetFormat() == pParent )
{ // Wonderful, here we can insert ourselves at the end
pUp = pPrvSct;
- if( pUp->Lower() && pUp->Lower()->IsColumnFrame() )
+ SwFrame* pLower = pUp->Lower();
+ if( pLower && pLower->IsColumnFrame() )
{
pUp = static_cast<SwLayoutFrame*>(pUp->GetLastLower());
// The body of the last column
@@ -1054,13 +1060,14 @@ static SwFootnoteFrame* lcl_FindEndnote( SwSectionFrame* &rpSect, bool &rbEmpty,
SwSectionFrame* pSect = rbEmpty ? rpSect->GetFollow() : rpSect;
while( pSect )
{
- OSL_ENSURE( (pSect->Lower() && pSect->Lower()->IsColumnFrame()) || pSect->GetUpper()->IsFootnoteFrame(),
+ SwFrame* pLower = pSect->Lower();
+ OSL_ENSURE( (pLower && pLower->IsColumnFrame()) || pSect->GetUpper()->IsFootnoteFrame(),
"InsertEndnotes: Where's my column?" );
// i73332: Columned section in endnote
SwColumnFrame* pCol = nullptr;
- if(pSect->Lower() && pSect->Lower()->IsColumnFrame())
- pCol = static_cast<SwColumnFrame*>(pSect->Lower());
+ if(pLower && pLower->IsColumnFrame())
+ pCol = static_cast<SwColumnFrame*>(pLower);
while( pCol ) // check all columns
{
@@ -1105,15 +1112,19 @@ static void lcl_ColumnRefresh( SwSectionFrame* pSect, bool bFollow )
{
bool bOldLock = pSect->IsColLocked();
pSect->ColLock();
- if( pSect->Lower() && pSect->Lower()->IsColumnFrame() )
+ SwFrame* pLower = pSect->Lower();
+ if( pLower && pLower->IsColumnFrame() )
{
- SwColumnFrame *pCol = static_cast<SwColumnFrame*>(pSect->Lower());
+ SwColumnFrame *pCol = static_cast<SwColumnFrame*>(pLower);
do
{ pCol->InvalidateSize_();
pCol->InvalidatePos_();
- static_cast<SwLayoutFrame*>(pCol)->Lower()->InvalidateSize_();
- pCol->Calc(pRenderContext); // calculation of column and
- static_cast<SwLayoutFrame*>(pCol)->Lower()->Calc(pRenderContext); // body
+ if (SwFrame* pColLower = static_cast<SwLayoutFrame*>(pCol)->Lower())
+ {
+ pColLower->InvalidateSize_();
+ pCol->Calc(pRenderContext); // calculation of column and
+ pColLower->Calc(pRenderContext); // body
+ }
pCol = static_cast<SwColumnFrame*>(pCol->GetNext());
} while ( pCol );
}
@@ -1130,7 +1141,8 @@ void SwSectionFrame::CollectEndnotes( SwLayouter* pLayouter )
{
OSL_ENSURE( IsColLocked(), "CollectEndnotes: You love the risk?" );
// i73332: Section in footnode does not have columns!
- OSL_ENSURE( (Lower() && Lower()->IsColumnFrame()) || GetUpper()->IsFootnoteFrame(), "Where's my column?" );
+ SwFrame* pLower = Lower();
+ OSL_ENSURE( (pLower && pLower->IsColumnFrame()) || GetUpper()->IsFootnoteFrame(), "Where's my column?" );
SwSectionFrame* pSect = this;
SwFootnoteFrame* pFootnote;
@@ -1234,7 +1246,8 @@ void SwSectionFrame::CheckClipping( bool bGrow, bool bMaximize )
if ( !(( bHeightChanged || bExtraCalc ) && Lower()) )
return;
- if( Lower()->IsColumnFrame() )
+ SwFrame* pLower = Lower();
+ if( pLower && pLower->IsColumnFrame() )
{
lcl_ColumnRefresh( this, false );
::CalcContent( this );
@@ -1344,8 +1357,8 @@ class ExtraFormatToPositionObjs
{
vcl::RenderContext* pRenderContext = mpSectFrame->getRootFrame()->GetCurrShell()->GetOut();
// perform extra format for multi-columned section.
- if ( !(mpSectFrame->Lower() && mpSectFrame->Lower()->IsColumnFrame() &&
- mpSectFrame->Lower()->GetNext()) )
+ SwFrame* pLower = mpSectFrame->Lower();
+ if ( !(pLower && pLower->IsColumnFrame() && pLower->GetNext()) )
return;
// grow section till bottom of printing area of upper frame
@@ -1373,10 +1386,13 @@ class ExtraFormatToPositionObjs
while ( pColFrame )
{
pColFrame->Calc(pRenderContext);
- pColFrame->Lower()->Calc(pRenderContext);
- if ( pColFrame->Lower()->GetNext() )
+ if (SwFrame* pColLower = pColFrame->Lower())
{
- pColFrame->Lower()->GetNext()->Calc(pRenderContext);
+ pColLower->Calc(pRenderContext);
+ if ( pColLower->GetNext() )
+ {
+ pColLower->GetNext()->Calc(pRenderContext);
+ }
}
pColFrame = static_cast<SwColumnFrame*>(pColFrame->GetNext());
@@ -2363,9 +2379,10 @@ SwTwips SwSectionFrame::Grow_(SwTwips nDist, SwResizeLimitReason& reason, bool b
aRectFnSet.SetHeight( aPrt, nPrtHeight );
}
- if( Lower() && Lower()->IsColumnFrame() && Lower()->GetNext() )
+ SwFrame* pLower = Lower();
+ if( pLower && pLower->IsColumnFrame() && pLower->GetNext() )
{
- SwFrame* pTmp = Lower();
+ SwFrame* pTmp = pLower;
do
{
pTmp->InvalidateSize_();
@@ -2466,9 +2483,10 @@ SwTwips SwSectionFrame::Shrink_( SwTwips nDist, bool bTst )
if( GetUpper() && !GetUpper()->IsFooterFrame() )
GetUpper()->Shrink( nDist, bTst );
- if( Lower() && Lower()->IsColumnFrame() && Lower()->GetNext() )
+ SwFrame* pLower = Lower();
+ if( pLower && pLower->IsColumnFrame() && pLower->GetNext() )
{
- SwFrame* pTmp = Lower();
+ SwFrame* pTmp = pLower;
do
{
pTmp->InvalidateSize_();
@@ -2589,8 +2607,9 @@ SwFrame* SwFrame::GetIndPrev_() const
while( pCol )
{
assert(pCol->IsColumnFrame());
- assert(pCol->GetLower() && pCol->GetLower()->IsBodyFrame());
- if( static_cast<const SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pCol)->Lower())->Lower() )
+ const SwFrame* pLower = pCol->GetLower();
+ assert(pLower && pLower->IsBodyFrame());
+ if( static_cast<const SwLayoutFrame*>(pLower)->Lower() )
return nullptr;
pCol = pCol->GetPrev();
}
@@ -2875,10 +2894,11 @@ void SwSectionFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pN
// on the old column attribute. We're left with creating a
// temporary attribute here.
SwFormatCol aCol;
- if ( Lower() && Lower()->IsColumnFrame() )
+ SwFrame* pLower = Lower();
+ if ( pLower && pLower->IsColumnFrame() )
{
sal_uInt16 nCol = 0;
- SwFrame *pTmp = Lower();
+ SwFrame *pTmp = pLower;
do
{ ++nCol;
pTmp = pTmp->GetNext();
@@ -3020,17 +3040,23 @@ SwFootnoteContFrame* SwSectionFrame::ContainsFootnoteCont( const SwFootnoteContF
OSL_ENSURE( IsAnLower( pLay ), "ContainsFootnoteCont: Wrong FootnoteContainer" );
pLay = static_cast<const SwLayoutFrame*>(pLay->GetNext());
}
- else if( Lower() && Lower()->IsColumnFrame() )
- pLay = static_cast<const SwLayoutFrame*>(Lower());
else
- pLay = nullptr;
+ {
+ const SwFrame* pLower = Lower();
+ if( pLower && pLower->IsColumnFrame() )
+ pLay = static_cast<const SwLayoutFrame*>(pLower);
+ else
+ pLay = nullptr;
+ }
+
while ( !pRet && pLay )
{
- if( pLay->Lower() && pLay->Lower()->GetNext() )
+ const SwFrame* pLower = pLay->Lower();
+ if( pLower && pLower->GetNext() )
{
- OSL_ENSURE( pLay->Lower()->GetNext()->IsFootnoteContFrame(),
+ OSL_ENSURE( pLower->GetNext()->IsFootnoteContFrame(),
"ToMaximize: Unexpected Frame" );
- pRet = const_cast<SwFootnoteContFrame*>(static_cast<const SwFootnoteContFrame*>(pLay->Lower()->GetNext()));
+ pRet = const_cast<SwFootnoteContFrame*>(static_cast<const SwFootnoteContFrame*>(pLower->GetNext()));
}
OSL_ENSURE( !pLay->GetNext() || pLay->GetNext()->IsLayoutFrame(),
"ToMaximize: ColFrame expected" );
@@ -3160,7 +3186,8 @@ bool SwRootFrame::IsInDelList( SwSectionFrame* pSct ) const
bool SwSectionFrame::IsBalancedSection() const
{
bool bRet = false;
- if ( GetSection() && Lower() && Lower()->IsColumnFrame() && Lower()->GetNext() )
+ const SwFrame* pLower = Lower();
+ if ( GetSection() && pLower && pLower->IsColumnFrame() && pLower->GetNext() )
{
bRet = !GetSection()->GetFormat()->GetBalancedColumns().GetValue();
}
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 27bb20c376fc..4b9534be4944 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -238,7 +238,8 @@ void SwFrame::CheckDirChange()
// If we're a page frame and we change our layout direction,
// we have to look for columns and rearrange them.
pBody = static_cast<SwPageFrame*>(this)->FindBodyCont();
- if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame())
+ SwFrame* pLower = pBody ? pBody->Lower() : nullptr;
+ if(pLower && pLower->IsColumnFrame())
pCol = &static_cast<SwPageFrame*>(this)->GetFormat()->GetCol();
}
else if( pFrame->IsColumnFrame() )
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index eced2e301c8a..7ad4e1c2969b 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -115,7 +115,8 @@ SwTabFrame::SwTabFrame( SwTable &rTab, SwFrame* pSib )
else
SwFrame::DestroyFrame(pNew);
}
- OSL_ENSURE( Lower() && Lower()->IsRowFrame(), "SwTabFrame::SwTabFrame: No rows." );
+ SwFrame* pLower = Lower();
+ OSL_ENSURE( pLower && pLower->IsRowFrame(), "SwTabFrame::SwTabFrame: No rows." );
}
SwTabFrame::SwTabFrame( SwTabFrame &rTab )
@@ -169,12 +170,13 @@ void SwTabFrame::JoinAndDelFollows()
void SwTabFrame::RegistFlys()
{
- OSL_ENSURE( Lower() && Lower()->IsRowFrame(), "No rows." );
+ SwFrame* pLower = Lower();
+ OSL_ENSURE( pLower && pLower->IsRowFrame(), "No rows." );
SwPageFrame *pPage = FindPageFrame();
if ( pPage )
{
- SwRowFrame *pRow = static_cast<SwRowFrame*>(Lower());
+ SwRowFrame *pRow = static_cast<SwRowFrame*>(pLower);
do
{
pRow->RegistFlys( pPage );
@@ -438,9 +440,10 @@ static void lcl_MoveRowContent( SwRowFrame& rSourceLine, SwRowFrame& rDestLine )
// Move content of follow cells into master cells
while ( pCurrSourceCell )
{
- if ( pCurrSourceCell->Lower() && pCurrSourceCell->Lower()->IsRowFrame() )
+ SwFrame* pLower = pCurrSourceCell->Lower();
+ if ( pLower && pLower->IsRowFrame() )
{
- SwRowFrame* pTmpSourceRow = static_cast<SwRowFrame*>(pCurrSourceCell->Lower());
+ SwRowFrame* pTmpSourceRow = static_cast<SwRowFrame*>(pLower);
while ( pTmpSourceRow )
{
// #125926# Attention! It is possible,
@@ -469,7 +472,7 @@ static void lcl_MoveRowContent( SwRowFrame& rSourceLine, SwRowFrame& rDestLine )
pTmpSourceRow->InsertBefore( pCurrDestCell, nullptr );
}
- pTmpSourceRow = static_cast<SwRowFrame*>(pCurrSourceCell->Lower());
+ pTmpSourceRow = static_cast<SwRowFrame*>(pLower);
}
}
else
@@ -479,7 +482,7 @@ static void lcl_MoveRowContent( SwRowFrame& rSourceLine, SwRowFrame& rDestLine )
{
// NEW TABLES
SwCellFrame* pDestCell = pCurrDestCell;
- if ( pDestCell->GetTabBox()->getRowSpan() < 1 )
+ if ( pDestCell && pDestCell->GetTabBox()->getRowSpan() < 1 )
pDestCell = & const_cast<SwCellFrame&>(pDestCell->FindStartEndOfRowSpanCell( true ));
// Find last content
@@ -558,8 +561,8 @@ static void lcl_PreprocessRowsInCells( SwTabFrame& rTab, SwRowFrame& rLastLine,
SwFrame* pCell = pTmpLastLineRow->Lower();
while ( pCell )
{
- if ( static_cast<SwCellFrame*>(pCell)->Lower() &&
- static_cast<SwCellFrame*>(pCell)->Lower()->IsRowFrame() )
+ SwFrame* pCellLower = static_cast<SwCellFrame*>(pCell)->Lower();
+ if ( pCellLower && pCellLower->IsRowFrame() )
{
bTableLayoutTooComplex = true;
break;
@@ -617,8 +620,8 @@ static void lcl_PostprocessRowsInCells( SwTabFrame& rTab, SwRowFrame& rLastLine
SwCellFrame* pCurrMasterCell = static_cast<SwCellFrame*>(rLastLine.Lower());
while ( pCurrMasterCell )
{
- if ( pCurrMasterCell->Lower() &&
- pCurrMasterCell->Lower()->IsRowFrame() )
+ SwFrame* pLower = pCurrMasterCell->Lower();
+ if ( pLower && pLower->IsRowFrame() )
{
SwRowFrame* pRowFrame = static_cast<SwRowFrame*>(pCurrMasterCell->GetLastLower());
@@ -1563,8 +1566,9 @@ namespace
}
}
}
- assert(rCell.Lower());
- if (rTab.IsCollapsingBorders() && rCell.Lower() && !rCell.Lower()->IsRowFrame())
+ const SwFrame* pLower = rCell.Lower();
+ assert(pLower);
+ if (rTab.IsCollapsingBorders() && pLower && !pLower->IsRowFrame())
{
if (rRow.GetTopMarginForLowers() != 0
|| rRow.GetBottomMarginForLowers() != 0)
@@ -1970,11 +1974,12 @@ static void lcl_RecalcTable( SwTabFrame& rTab,
SwLayoutFrame *pFirstRow,
SwLayNotify &rNotify )
{
- if ( rTab.Lower() )
+ SwFrame* pLower = rTab.Lower();
+ if ( pLower )
{
if ( !pFirstRow )
{
- pFirstRow = static_cast<SwLayoutFrame*>(rTab.Lower());
+ pFirstRow = static_cast<SwLayoutFrame*>(pLower);
rNotify.SetLowersComplete( true );
}
::SwInvalidatePositions( pFirstRow, LONG_MAX );
@@ -4838,7 +4843,8 @@ static SwTwips lcl_CalcTopAndBottomMargin( const SwLayoutFrame& rCell, const SwB
SwTwips nBottomSpace = 0;
// #i29550#
- if ( pTab->IsCollapsingBorders() && rCell.Lower() && !rCell.Lower()->IsRowFrame() )
+ const SwFrame* pLower = rCell.Lower();
+ if ( pTab->IsCollapsingBorders() && pLower && !pLower->IsRowFrame() )
{
nTopSpace = static_cast<const SwRowFrame*>(rCell.GetUpper())->GetTopMarginForLowers();
nBottomSpace = static_cast<const SwRowFrame*>(rCell.GetUpper())->GetBottomMarginForLowers();
@@ -4870,34 +4876,31 @@ static SwTwips lcl_CalcMinCellHeight( const SwLayoutFrame *_pCell,
SwRectFnSet aRectFnSet(_pCell);
SwTwips nHeight = 0;
const SwFrame* pLow = _pCell->Lower();
- if ( pLow )
+ tools::Long nFlyAdd = 0;
+ while ( pLow )
{
- tools::Long nFlyAdd = 0;
- while ( pLow )
+ if ( pLow->IsRowFrame() )
{
- if ( pLow->IsRowFrame() )
- {
- // #i26945#
- nHeight += ::lcl_CalcMinRowHeight( static_cast<const SwRowFrame*>(pLow),
- _bConsiderObjs );
- }
- else
+ // #i26945#
+ nHeight += ::lcl_CalcMinRowHeight( static_cast<const SwRowFrame*>(pLow),
+ _bConsiderObjs );
+ }
+ else
+ {
+ tools::Long nLowHeight = aRectFnSet.GetHeight(pLow->getFrameArea());
+ nHeight += nLowHeight;
+ // #i26945#
+ if ( _bConsiderObjs )
{
- tools::Long nLowHeight = aRectFnSet.GetHeight(pLow->getFrameArea());
- nHeight += nLowHeight;
- // #i26945#
- if ( _bConsiderObjs )
- {
- nFlyAdd = std::max( tools::Long(0), nFlyAdd - nLowHeight );
- nFlyAdd = std::max( nFlyAdd, ::CalcHeightWithFlys( pLow ) );
- }
+ nFlyAdd = std::max( tools::Long(0), nFlyAdd - nLowHeight );
+ nFlyAdd = std::max( nFlyAdd, ::CalcHeightWithFlys( pLow ) );
}
-
- pLow = pLow->GetNext();
}
- if ( nFlyAdd )
- nHeight += nFlyAdd;
+
+ pLow = pLow->GetNext();
}
+ if ( nFlyAdd )
+ nHeight += nFlyAdd;
// The border/margin needs to be considered too, unfortunately it can't be
// calculated using PrintArea and FrameArea because any or all of those
// may be invalid.
@@ -5023,8 +5026,9 @@ static sal_uInt16 lcl_GetTopSpace( const SwRowFrame& rRow )
pCurrLower = static_cast<const SwCellFrame*>(pCurrLower->GetNext()) )
{
sal_uInt16 nTmpTopSpace = 0;
- if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrame() )
- nTmpTopSpace = lcl_GetTopSpace( *static_cast<const SwRowFrame*>(pCurrLower->Lower()) );
+ const SwFrame* pLower = pCurrLower->Lower();
+ if ( pLower && pLower->IsRowFrame() )
+ nTmpTopSpace = lcl_GetTopSpace( *static_cast<const SwRowFrame*>(pLower) );
else
{
const SwAttrSet& rSet = pCurrLower->GetFormat()->GetAttrSet();
@@ -5044,8 +5048,9 @@ static sal_uInt16 lcl_GetTopLineDist( const SwRowFrame& rRow )
pCurrLower = static_cast<const SwCellFrame*>(pCurrLower->GetNext()) )
{
sal_uInt16 nTmpTopLineDist = 0;
- if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrame() )
- nTmpTopLineDist = lcl_GetTopLineDist( *static_cast<const SwRowFrame*>(pCurrLower->Lower()) );
+ const SwFrame* pLower = pCurrLower->Lower();
+ if ( pLower && pLower->IsRowFrame() )
+ nTmpTopLineDist = lcl_GetTopLineDist( *static_cast<const SwRowFrame*>(pLower) );
else
{
const SwAttrSet& rSet = pCurrLower->GetFormat()->GetAttrSet();
@@ -5065,7 +5070,8 @@ static sal_uInt16 lcl_GetBottomLineSize( const SwRowFrame& rRow )
pCurrLower = static_cast<const SwCellFrame*>(pCurrLower->GetNext()) )
{
sal_uInt16 nTmpBottomLineSize = 0;
- if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pCurrLower->Lower();
+ if ( pLower && pLower->IsRowFrame() )
{
const SwFrame* pRow = pCurrLower->GetLastLower();
nTmpBottomLineSize = lcl_GetBottomLineSize( *static_cast<const SwRowFrame*>(pRow) );
@@ -5090,7 +5096,8 @@ static sal_uInt16 lcl_GetBottomLineDist( const SwRowFrame& rRow )
pCurrLower = static_cast<const SwCellFrame*>(pCurrLower->GetNext()) )
{
sal_uInt16 nTmpBottomLineDist = 0;
- if ( pCurrLower->Lower() && pCurrLower->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pCurrLower->Lower();
+ if ( pLower && pLower->IsRowFrame() )
{
const SwFrame* pRow = pCurrLower->GetLastLower();
nTmpBottomLineDist = lcl_GetBottomLineDist( *static_cast<const SwRowFrame*>(pRow) );
@@ -5307,10 +5314,10 @@ void SwRowFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA
//The last fills the remaining space in the upper.
SwTwips nDiff = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea());
SwFrame *pSibling = GetUpper()->Lower();
- do
+ while ( pSibling )
{ nDiff -= aRectFnSet.GetHeight(pSibling->getFrameArea());
pSibling = pSibling->GetNext();
- } while ( pSibling );
+ }
if (nDiff > 0 && pTabFrame->IsCollapsingBorders())
{
// In SwTabFrame::Format, this value will be added to the table's bottom margin
@@ -5934,17 +5941,18 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
OSL_ENSURE( pAttrs, "CellFrame::Format, pAttrs is 0." );
const SwTabFrame* pTab = FindTabFrame();
SwRectFnSet aRectFnSet(pTab);
+ SwFrame* pLower = Lower();
if ( !isFramePrintAreaValid() )
{
setFramePrintAreaValid(true);
//Adjust position.
- if ( Lower() )
+ if ( pLower )
{
SwTwips nTopSpace, nBottomSpace, nLeftSpace, nRightSpace;
// #i29550#
- if ( pTab->IsCollapsingBorders() && !Lower()->IsRowFrame() )
+ if ( pTab->IsCollapsingBorders() && !pLower->IsRowFrame() )
{
const SvxBoxItem& rBoxItem = pAttrs->GetBox();
nLeftSpace = rBoxItem.GetDistance( SvxBoxItemLine::LEFT );
@@ -6099,7 +6107,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
}
const SwFormatVertOrient &rOri = pAttrs->GetAttrSet().GetVertOrient();
- if ( !Lower() )
+ if ( !pLower )
return;
// From now on, all operations are related to the table cell.
@@ -6111,7 +6119,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
!IsCoveredCell() &&
(pPg = FindPageFrame())!=nullptr )
{
- if ( !Lower()->IsContentFrame() && !Lower()->IsSctFrame() && !Lower()->IsTabFrame() )
+ if ( !pLower->IsContentFrame() && pLower->IsSctFrame() && !pLower->IsTabFrame() )
{
// OSL_ENSURE(for HTML-import!
OSL_ENSURE( false, "VAlign to cell without content" );
@@ -6165,7 +6173,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
tools::Long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
if( ( bVertDir && ( nRemaining -= lcl_CalcTopAndBottomMargin( *this, *pAttrs ) ) < nPrtHeight ) ||
- aRectFnSet.GetTop(Lower()->getFrameArea()) != aRectFnSet.GetPrtTop(*this) )
+ aRectFnSet.GetTop(pLower->getFrameArea()) != aRectFnSet.GetPrtTop(*this) )
{
tools::Long nDiff = aRectFnSet.GetHeight(getFramePrintArea()) - nRemaining;
if ( nDiff >= 0 )
@@ -6190,7 +6198,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
else
{
//Was an old alignment taken into account?
- if ( Lower()->IsContentFrame() )
+ if ( pLower->IsContentFrame() )
{
const tools::Long lYStart = aRectFnSet.GetPrtTop(*this);
lcl_ArrangeLowers( this, lYStart, true );
@@ -6200,7 +6208,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
// Handle rotated portions of lowers: it's possible that we have changed amount of vertical
// space since the last format, and this affects how many rotated portions we need. So throw
// away the current portions to build them using the new line width.
- for (SwFrame* pFrame = Lower(); pFrame; pFrame = pFrame->GetNext())
+ for (SwFrame* pFrame = pLower; pFrame; pFrame = pFrame->GetNext())
{
if (!pFrame->IsTextFrame())
{
@@ -6297,7 +6305,8 @@ void SwCellFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
{
bool bInva = true;
const auto eVertOrient = static_cast<const SwFormatVertOrient*>(pVertOrientItem)->GetVertOrient();
- if(text::VertOrientation::NONE == eVertOrient && Lower() && Lower()->IsContentFrame())
+ SwFrame* pLower = Lower();
+ if(text::VertOrientation::NONE == eVertOrient && pLower && pLower->IsContentFrame())
{
SwRectFnSet aRectFnSet(this);
const tools::Long lYStart = aRectFnSet.GetPrtTop(*this);
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 52701222b25f..0b4f2d2a8eb0 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -451,7 +451,8 @@ bool SwRootFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint,
{
const bool bOldAction = IsCallbackActionEnabled();
const_cast<SwRootFrame*>(this)->SetCallbackActionEnabled( false );
- OSL_ENSURE( (Lower() && Lower()->IsPageFrame()), "No PageFrame found." );
+ const SwFrame* pLower = Lower();
+ OSL_ENSURE( (pLower && pLower->IsPageFrame()), "No PageFrame found." );
if( pCMS && pCMS->m_pFill )
pCMS->m_bFillRet = false;
Point aOldPoint = rPoint;
@@ -465,7 +466,7 @@ bool SwRootFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint,
rPoint.X() > getFrameArea().Right() &&
rPoint.Y() > getFrameArea().Bottom() )
{
- pPage = dynamic_cast<const SwPageFrame*>(Lower());
+ pPage = dynamic_cast<const SwPageFrame*>(pLower);
while ( pPage && pPage->GetNext() )
{
pPage = dynamic_cast<const SwPageFrame*>(pPage->GetNext());
@@ -515,13 +516,13 @@ bool SwCellFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint,
}
}
- if (Lower()->IsLayoutFrame())
+ const SwFrame *pFrame = Lower();
+ if (pFrame && pFrame->IsLayoutFrame())
return SwLayoutFrame::GetModelPositionForViewPoint(pPos, rPoint, pCMS);
Calc(pRenderContext);
bool bRet = false;
- const SwFrame *pFrame = Lower();
while (pFrame && !bRet)
{
pFrame->Calc(pRenderContext);
@@ -569,9 +570,12 @@ bool SwFlyFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint,
//If a Frame contains a graphic, but only text was requested, it basically
//won't accept the Cursor.
- if ( bInside && pCMS && pCMS->m_eState == CursorMoveState::SetOnlyText &&
- (!Lower() || Lower()->IsNoTextFrame()) )
- bInside = false;
+ if ( bInside && pCMS && pCMS->m_eState == CursorMoveState::SetOnlyText)
+ {
+ const SwFrame* pLower = Lower();
+ if (!pLower || pLower->IsNoTextFrame())
+ bInside = false;
+ }
const SwPageFrame *pPage = FindPageFrame();
if ( bInside && pPage && pPage->GetSortedObjs() )
@@ -1008,12 +1012,14 @@ sal_uInt16 SwRootFrame::GetCurrPage( const SwPaM *pActualCursor ) const
sal_uInt16 SwRootFrame::SetCurrPage( SwCursor* pToSet, sal_uInt16 nPageNum )
{
vcl::RenderContext* pRenderContext = GetCurrShell() ? GetCurrShell()->GetOut() : nullptr;
- OSL_ENSURE( Lower() && Lower()->IsPageFrame(), "No page available." );
+ SwFrame* pLower = Lower();
+ assert( (pLower && pLower->IsPageFrame()) && "No page available." );
- SwPageFrame *pPage = static_cast<SwPageFrame*>(Lower());
+ SwPageFrame *pPage = static_cast<SwPageFrame*>(pLower);
bool bEnd =false;
while ( !bEnd && pPage->GetPhyPageNum() != nPageNum )
- { if ( pPage->GetNext() )
+ {
+ if ( pPage->GetNext() )
pPage = static_cast<SwPageFrame*>(pPage->GetNext());
else
{ //Search the first ContentFrame and format until a new page is started
@@ -1603,9 +1609,10 @@ Point SwRootFrame::GetNextPrevContentPos( const Point& rPoint, bool bNext ) cons
*/
Point SwRootFrame::GetPagePos( sal_uInt16 nPageNum ) const
{
- OSL_ENSURE( Lower() && Lower()->IsPageFrame(), "No page available." );
+ const SwFrame* pLower = Lower();
+ assert( (pLower && pLower->IsPageFrame()) && "No page available." );
- const SwPageFrame *pPage = static_cast<const SwPageFrame*>(Lower());
+ const SwPageFrame *pPage = static_cast<const SwPageFrame*>(pLower);
while ( true )
{
if ( pPage->GetPhyPageNum() >= nPageNum || !pPage->GetNext() )
@@ -1989,7 +1996,8 @@ bool SwRootFrame::MakeTableCursors( SwTableCursor& rTableCursor )
if ( pCell->GetNext() )
{
pCell = static_cast<const SwLayoutFrame*>(pCell->GetNext());
- if ( pCell->Lower() && pCell->Lower()->IsRowFrame() )
+ const SwFrame* pLower = pCell->Lower();
+ if ( pLower && pLower->IsRowFrame() )
pCell = pCell->FirstCell();
}
else
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index cef7c0c9d2dc..09cbc2ab4d5b 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -924,8 +924,8 @@ void SwFrame::InsertBehind( SwLayoutFrame *pParent, SwFrame *pBefore )
assert(pParent && "No Parent for Insert.");
//Insert at the beginning of the chain
mpNext = pParent->Lower();
- if ( pParent->Lower() )
- pParent->Lower()->mpPrev = this;
+ if ( mpNext )
+ mpNext->mpPrev = this;
pParent->m_pLower = this;
}
}
@@ -987,10 +987,11 @@ bool SwFrame::InsertGroupBefore( SwFrame* pParent, SwFrame* pBehind, SwFrame* pS
pBehind->GetUpper()->m_pLower = nullptr;
pBehind->mpPrev = nullptr;
SwLayoutFrame* pTmp = static_cast<SwLayoutFrame*>(pSct);
- if( pTmp->Lower() )
+ SwFrame* pLower = pTmp->Lower();
+ if( pLower )
{
- OSL_ENSURE( pTmp->Lower()->IsColumnFrame(), "InsertGrp: Used SectionFrame" );
- pTmp = static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(pTmp->Lower())->Lower());
+ OSL_ENSURE( pLower->IsColumnFrame(), "InsertGrp: Used SectionFrame" );
+ pTmp = static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(pLower)->Lower());
OSL_ENSURE( pTmp, "InsertGrp: Missing ColBody" );
}
pBehind->mpUpper = pTmp;
@@ -2784,11 +2785,13 @@ SwTwips SwLayoutFrame::GrowFrame(SwTwips nDist, SwResizeLimitReason& reason, boo
{
//Footnotes can replace their successor.
SwTwips nSpace = bTst ? 0 : -nDist;
- const SwFrame *pFrame = GetUpper()->Lower();
- do
- { nSpace += aRectFnSet.GetHeight(pFrame->getFrameArea());
- pFrame = pFrame->GetNext();
- } while ( pFrame != GetNext() );
+ if (const SwFrame *pFrame = GetUpper()->Lower())
+ {
+ do
+ { nSpace += aRectFnSet.GetHeight(pFrame->getFrameArea());
+ pFrame = pFrame->GetNext();
+ } while ( pFrame != GetNext() );
+ }
nSpace = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()) -nSpace;
if ( nSpace < 0 )
nSpace = 0;
@@ -2927,10 +2930,10 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
SwTwips nMin = 0;
bool bChgPos = IsVertical();
- if ( Lower() )
+ if (const SwFrame *pFrame = Lower())
{
- if( !Lower()->IsNeighbourFrame() )
- { const SwFrame *pFrame = Lower();
+ if( !pFrame->IsNeighbourFrame() )
+ {
const tools::Long nTmp = aRectFnSet.GetHeight(getFramePrintArea());
while( pFrame && nMin < nTmp )
{ nMin += aRectFnSet.GetHeight(pFrame->getFrameArea());
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index cd19d885222d..17e55bf5ba48 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -145,9 +145,15 @@ void SwTextFrame::ValidateBodyFrame()
SwSwapIfSwapped swap( this );
// See comment in ValidateFrame()
- if ( !IsInFly() && !IsInTab() &&
- !( IsInSct() && FindSctFrame()->Lower()->IsColumnFrame() ) )
- ValidateBodyFrame_( GetUpper() );
+ if ( !IsInFly() && !IsInTab())
+ {
+ if (SwSectionFrame* pSctFrame = FindSctFrame())
+ {
+ SwFrame* pLower = pSctFrame->Lower();
+ if (pLower && !pLower->IsColumnFrame())
+ ValidateBodyFrame_( GetUpper() );
+ }
+ }
}
bool SwTextFrame::GetDropRect_( SwRect &rRect ) const
@@ -512,14 +518,16 @@ void SwTextFrame::AdjustFrame( const SwTwips nChgHght, bool bHasToFit )
// We can get a bit of space in table cells, because there could be some
// left through a vertical alignment to the top.
// Assure that first lower in upper is the current one or is valid.
- if ( IsInTab() &&
- ( GetUpper()->Lower() == this ||
- GetUpper()->Lower()->isFrameAreaDefinitionValid() ) )
+ if (IsInTab())
{
- tools::Long nAdd = aRectFnSet.YDiff( aRectFnSet.GetTop(GetUpper()->Lower()->getFrameArea()),
- aRectFnSet.GetPrtTop(*GetUpper()) );
- OSL_ENSURE( nAdd >= 0, "Ey" );
- nRstHeight += nAdd;
+ SwFrame* pLower = GetUpper()->Lower();
+ if ( pLower == this || (pLower && pLower->isFrameAreaDefinitionValid()) )
+ {
+ tools::Long nAdd = aRectFnSet.YDiff( aRectFnSet.GetTop(pLower->getFrameArea()),
+ aRectFnSet.GetPrtTop(*GetUpper()) );
+ OSL_ENSURE( nAdd >= 0, "Ey" );
+ nRstHeight += nAdd;
+ }
}
// nRstHeight < 0 means that the TextFrame is located completely outside of its Upper.
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index cbdccecb9ff0..08a653311071 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -621,12 +621,17 @@ static bool lcl_IsFrameReadonly(SwTextFrame* pFrame)
const SwFlyFrame* pFly;
const SwSection* pSection;
- if( pFrame && pFrame->IsInFly() &&
- (pFly = pFrame->FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
- pFly->Lower() &&
- !pFly->Lower()->IsNoTextFrame() )
+ if( pFrame && pFrame->IsInFly())
{
- return false;
+ pFly = pFrame->FindFlyFrame();
+ if (pFly->GetFormat()->GetEditInReadonly().GetValue())
+ {
+ const SwFrame* pLower = pFly->Lower();
+ if (pLower && !pLower->IsNoTextFrame())
+ {
+ return false;
+ }
+ }
}
// edit in readonly sections
else if ( pFrame && pFrame->IsInSct() &&
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 67a1abae2dc9..8f7af91704e4 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -178,10 +178,10 @@ SwRect SwContourCache::CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
}
}
+ const SwFrame* pLower = static_cast<const SwFlyFrame*>(pAnchoredObj)->Lower();
if( bHandleContour &&
( pAnchoredObj->DynCastFlyFrame() == nullptr ||
- ( static_cast<const SwFlyFrame*>(pAnchoredObj)->Lower() &&
- static_cast<const SwFlyFrame*>(pAnchoredObj)->Lower()->IsNoTextFrame() ) ) )
+ ( pLower && pLower->IsNoTextFrame() ) ) )
{
aRet = pAnchoredObj->GetObjRectWithSpaces();
if( aRet.Overlaps( rLine ) )
@@ -601,15 +601,16 @@ void SwTextFly::DrawFlyRect( OutputDevice* pOut, const SwRect &rRect )
// and <SwAlignRect(..)> fly frame area
// #i47804# - consider transparent graphics
// and OLE objects.
+ const SwFrame* pLower = pFly->Lower();
bool bClipFlyArea =
( ( css::text::WrapTextMode_THROUGH == rSur.GetSurround() )
// #i68520#
? (pAnchoredObjTmp->GetDrawObj()->GetLayer() != nHellId)
: !rSur.IsContour() ) &&
!pFly->IsBackgroundTransparent() &&
- ( !pFly->Lower() ||
- !pFly->Lower()->IsNoTextFrame() ||
- !static_cast<const SwNoTextFrame*>(pFly->Lower())->IsTransparent() );
+ ( !pLower ||
+ !pLower->IsNoTextFrame() ||
+ !static_cast<const SwNoTextFrame*>(pLower)->IsTransparent() );
if ( bClipFlyArea )
{
// #i68520#
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 84f961781232..09289408fc4c 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -351,8 +351,9 @@ SwTwips SwTextFrame::GetFootnoteFrameHeight_() const
const SwLayoutFrame* pTmp = GetUpper();
while( !bInvalidPos && pTmp )
{
+ const SwFrame* pLower = pTmp->Lower();
bInvalidPos = !pTmp->isFrameAreaPositionValid() ||
- !pTmp->Lower()->isFrameAreaPositionValid();
+ !pLower || !pLower->isFrameAreaPositionValid();
if( pTmp == pCont )
break;
pTmp = pTmp->GetUpper();
diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx
index 4c0dd129da04..9d541644d652 100644
--- a/sw/source/core/text/widorp.cxx
+++ b/sw/source/core/text/widorp.cxx
@@ -69,7 +69,8 @@ SwTextFrameBreak::SwTextFrameBreak( SwTextFrame *pNewFrame, const SwTwips nRst )
if( !m_bKeep && m_pFrame->IsInSct() )
{
const SwSectionFrame* const pSct = m_pFrame->FindSctFrame();
- m_bKeep = pSct->Lower()->IsColumnFrame() && !pSct->MoveAllowed( m_pFrame );
+ if (const SwFrame* pLower = pSct->Lower())
+ m_bKeep = pLower->IsColumnFrame() && !pSct->MoveAllowed( m_pFrame );
}
m_bKeep = m_bKeep || !m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetSplit().GetValue() ||
m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetKeep().GetValue();
diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index dd3aeb3d86a3..e4f58620376a 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -220,7 +220,7 @@ void SwViewShellImp::SetFirstVisPage(OutputDevice const * pRenderContext)
const bool bBookMode = pSwViewOption->IsViewLayoutBookMode();
SwPageFrame *pPage = static_cast<SwPageFrame*>(m_pShell->GetLayout()->Lower());
- SwRect aPageRect = pPage->GetBoundRect(pRenderContext);
+ SwRect aPageRect = pPage ? pPage->GetBoundRect(pRenderContext) : SwRect();
while ( pPage && !aPageRect.Overlaps( m_pShell->VisArea() ) )
{
pPage = static_cast<SwPageFrame*>(pPage->GetNext());
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 4af997226abc..b3a2ac110944 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2801,13 +2801,14 @@ Size SwViewShell::GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const
const SwPageFrame* pPage = static_cast<const SwPageFrame*>
(pTmpRoot->Lower());
- while( --nPageNum && pPage->GetNext() )
+ while( --nPageNum && pPage && pPage->GetNext() )
pPage = static_cast<const SwPageFrame*>( pPage->GetNext() );
- if( !bSkipEmptyPages && pPage->IsEmptyPage() && pPage->GetNext() )
+ if( !bSkipEmptyPages && pPage && pPage->IsEmptyPage() && pPage->GetNext() )
pPage = static_cast<const SwPageFrame*>( pPage->GetNext() );
- aSize = pPage->getFrameArea().SSize();
+ if (pPage)
+ aSize = pPage->getFrameArea().SSize();
}
return aSize;
}