[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 24 10:48:35 UTC 2021
sw/inc/anchoredobject.hxx | 5 +-
sw/qa/extras/uiwriter/uiwriter2.cxx | 8 +--
sw/source/core/access/accpara.cxx | 4 -
sw/source/core/doc/doclay.cxx | 2
sw/source/core/draw/dview.cxx | 8 +--
sw/source/core/frmedt/feshview.cxx | 4 -
sw/source/core/frmedt/fetab.cxx | 2
sw/source/core/inc/flyfrm.hxx | 3 +
sw/source/core/inc/frame.hxx | 1
sw/source/core/layout/anchoredobject.cxx | 10 ++++
sw/source/core/layout/atrfrm.cxx | 2
sw/source/core/layout/calcmove.cxx | 4 -
sw/source/core/layout/flowfrm.cxx | 2
sw/source/core/layout/fly.cxx | 19 +++++++--
sw/source/core/layout/flycnt.cxx | 2
sw/source/core/layout/flylay.cxx | 4 -
sw/source/core/layout/frmtool.cxx | 16 +++----
sw/source/core/layout/hffrm.cxx | 2
sw/source/core/layout/layact.cxx | 8 +--
sw/source/core/layout/laycache.cxx | 4 -
sw/source/core/layout/objectformatter.cxx | 4 -
sw/source/core/layout/pagechg.cxx | 6 +-
sw/source/core/layout/paintfrm.cxx | 10 ++--
sw/source/core/layout/ssfrm.cxx | 8 +--
sw/source/core/layout/tabfrm.cxx | 8 +--
sw/source/core/layout/trvlfrm.cxx | 4 -
sw/source/core/layout/wsfrm.cxx | 16 +++----
sw/source/core/objectpositioning/anchoredobjectposition.cxx | 2
sw/source/core/text/itrcrsr.cxx | 2
sw/source/core/text/porfly.cxx | 2
sw/source/core/text/porlay.cxx | 2
sw/source/core/text/txtfly.cxx | 25 +++++-------
sw/source/core/text/txtfrm.cxx | 2
sw/source/core/text/txtftn.cxx | 2
sw/source/core/text/xmldump.cxx | 2
35 files changed, 116 insertions(+), 89 deletions(-)
New commits:
commit 35fa0a7369d6ba3a051923c4f813107c16d2c617
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Aug 24 09:59:43 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 24 12:47:52 2021 +0200
reduce cost of dynamic casting to SwFlyFrame
which is often hot on doing document layout
Change-Id: Ie78b6a6da4dba38b4ab682f4e1b9d86cc8171918
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120938
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx
index 1db20eaf494c..2dd945e4cd5c 100644
--- a/sw/inc/anchoredobject.hxx
+++ b/sw/inc/anchoredobject.hxx
@@ -28,7 +28,7 @@ class SdrObject;
class SwFrame;
class SwLayoutFrame;
class SwTextFrame;
-
+class SwFlyFrame;
class SwPageFrame;
class SwFrameFormat;
@@ -488,6 +488,9 @@ class SW_DLLPUBLIC SwAnchoredObject
/** The element name to show in the XML dump. */
virtual const char* getElementName( ) const { return "SwAnchoredObject"; }
+
+ virtual const SwFlyFrame* DynCastFlyFrame() const;
+ virtual SwFlyFrame* DynCastFlyFrame();
};
/// Helper class for notify that positioning of an anchored object is in progress.
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index a3f63a80d816..8461ef96197a 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1804,7 +1804,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloatButtonSmallTable)
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pAnchored->size());
SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
- SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ SwFlyFrame* pFlyFrame = pAnchoredObj->DynCastFlyFrame();
CPPUNIT_ASSERT(pFlyFrame);
CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
@@ -1849,7 +1849,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloatButton)
SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
// The unfloat button is not visible until it gets selected
- SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ SwFlyFrame* pFlyFrame = pAnchoredObj->DynCastFlyFrame();
CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pFlyFrame);
CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(),
!pFlyFrame->IsShowUnfloatButton(pWrtShell));
@@ -1875,7 +1875,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloatButtonReadOnlyMode)
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pAnchored->size());
SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
- SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ SwFlyFrame* pFlyFrame = pAnchoredObj->DynCastFlyFrame();
CPPUNIT_ASSERT(pFlyFrame);
CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell));
@@ -1921,7 +1921,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testUnfloating)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailureMessage.getStr(), static_cast<size_t>(1),
pAnchored->size());
SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
- pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ pFlyFrame = pAnchoredObj->DynCastFlyFrame();
CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pFlyFrame);
}
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 24b3b81d005d..7d6ec354244b 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1557,9 +1557,9 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl(
break;
}
- if ( const SwFlyFrame* pFlyFrame = dynamic_cast<const SwFlyFrame*>(pUpperFrame) )
+ if ( pUpperFrame->IsFlyFrame() )
{
- pUpperFrame = pFlyFrame->GetAnchorFrame();
+ pUpperFrame = static_cast<const SwFlyFrame*>(pUpperFrame)->GetAnchorFrame();
}
else
{
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 091fc3bc743f..5c5d92a26270 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -546,7 +546,7 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso,
for(SwAnchoredObject* pAnchoredObj : rObjs)
{
SwFrameFormat *pFly;
- if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) != nullptr )
+ if ( pAnchoredObj->DynCastFlyFrame() != nullptr )
pFly = &(pAnchoredObj->GetFrameFormat());
else if ( bDrawAlso )
pFly = &(pAnchoredObj->GetFrameFormat());
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index aa116d3d7bb7..fb0e1f9c8294 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -379,7 +379,7 @@ void SwDrawView::MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
nNewPos );
pDrawPage->RecalcObjOrdNums();
// adjustments for accessibility API
- if ( auto pTmpFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pTmpFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
m_rImp.DisposeAccessibleFrame( pTmpFlyFrame );
m_rImp.AddAccessibleFrame( pTmpFlyFrame );
@@ -412,7 +412,7 @@ void SwDrawView::MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
nTmpNewPos );
pDrawPage->RecalcObjOrdNums();
// adjustments for accessibility API
- if ( auto pTmpFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pTmpFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
m_rImp.DisposeAccessibleFrame( pTmpFlyFrame );
m_rImp.AddAccessibleFrame( pTmpFlyFrame );
@@ -515,7 +515,7 @@ void SwDrawView::ObjOrderChanged( SdrObject* pObj, size_t nOldPos,
// On move forward, assure that object is moved before its own children.
// Only Writer fly frames can have children.
- if ( dynamic_cast< const SwFlyFrame *>( pMovedAnchoredObj ) != nullptr &&
+ if ( pMovedAnchoredObj->DynCastFlyFrame() &&
bMovedForward && nNewPos < nObjCount - 1 )
{
sal_uInt32 nMaxChildOrdNum =
@@ -586,7 +586,7 @@ void SwDrawView::ObjOrderChanged( SdrObject* pObj, size_t nOldPos,
std::vector< SdrObject* > aMovedChildObjs;
// move 'children' accordingly
- if ( auto pFlyFrame = dynamic_cast< SwFlyFrame *>( pMovedAnchoredObj ) )
+ if ( auto pFlyFrame = pMovedAnchoredObj->DynCastFlyFrame() )
{
// adjustments for accessibility API
m_rImp.DisposeAccessibleFrame( pFlyFrame );
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 5a6f85f0a163..d4e1f57d3ade 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -487,7 +487,7 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
Point aBest;
for(SwAnchoredObject* pAnchObj : *pPage->GetSortedObjs())
{
- if( auto pTmp = dynamic_cast<SwFlyFrame*>( pAnchObj) )
+ if( auto pTmp = pAnchObj->DynCastFlyFrame() )
{
if( pTmp == pOld )
bOld = true;
@@ -873,7 +873,7 @@ static void lcl_NotifyNeighbours( const SdrMarkList *pLst )
for ( size_t i = 0; i < nCount; ++i )
{
SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i];
- SwFlyFrame* pAct = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ SwFlyFrame* pAct = pAnchoredObj->DynCastFlyFrame();
if ( !pAct )
continue;
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index cb8cec705604..04c046806a6e 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -1660,7 +1660,7 @@ const SwFrame* SwFEShell::GetBox( const Point &rPt, bool* pbRow, bool* pbCol ) c
for ( size_t i = 0; !pFrame && i < pPage->GetSortedObjs()->size(); ++i )
{
SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFlyFrame = pObj->DynCastFlyFrame() )
{
pFrame = lcl_FindFrame( pFlyFrame, rPt, nFuzzy, pbRow, pbCol );
}
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 47017e71e50e..467407d1654e 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -301,6 +301,9 @@ public:
// For testing only (see uiwriter)
void ActiveUnfloatButton(SwWrtShell* pWrtSh);
+ virtual const SwFlyFrame* DynCastFlyFrame() const override;
+ virtual SwFlyFrame* DynCastFlyFrame() override;
+
private:
void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
void PaintDecorators() const;
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 65936fb9bce3..a6504b25cdc0 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index cedca5d10a4a..fa14bc6f743d 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -907,4 +907,14 @@ Point SwAnchoredObject::GetRelPosToLine() const
return aRelPos;
}
+const SwFlyFrame* SwAnchoredObject::DynCastFlyFrame() const
+{
+ return nullptr;
+}
+
+SwFlyFrame* SwAnchoredObject::DynCastFlyFrame()
+{
+ return nullptr;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 711957cea1f2..932c3613ad3d 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3111,7 +3111,7 @@ void SwFlyFrameFormat::MakeFrames()
{
// #i28701# - consider changed type of
// <SwSortedObjs> entries.
- if( dynamic_cast<const SwFlyFrame*>( pObj) != nullptr &&
+ if( pObj->DynCastFlyFrame() != nullptr &&
(&pObj->GetFrameFormat()) == this )
{
bAdd = false;
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 004fd4114d5c..39a183f9e38c 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -717,7 +717,7 @@ static void lcl_CheckObjects(SwSortedObjs& rSortedObjs, const SwFrame* pFrame, t
// #i28701# - consider changed type of <SwSortedObjs>
// entries.
tools::Long nTmp = 0;
- if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if( pFly->getFrameArea().Top() != FAR_AWAY &&
( pFrame->IsPageFrame() ? pFly->IsFlyLayFrame() :
@@ -1128,7 +1128,7 @@ void SwContentFrame::MakePrtArea( const SwBorderAttrs &rAttrs )
// <SwSortedObjs> entries
SwAnchoredObject* pObj = (*GetDrawObjs())[i];
const SwFrameFormat& rFormat = pObj->GetFrameFormat();
- const bool bFly = dynamic_cast<const SwFlyFrame*>( pObj) != nullptr;
+ const bool bFly = pObj->DynCastFlyFrame() != nullptr;
if ((bFly && (FAR_AWAY == pObj->GetObjRect().Width()))
|| rFormat.GetFrameSize().GetWidthPercent())
{
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 407232509e09..a86c35d9bbd1 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -376,7 +376,7 @@ sal_uInt8 SwFlowFrame::BwdMoveNecessary( const SwPageFrame *pPage, const SwRect
if( m_rThis.IsLayoutFrame() && //Fly Lower of This?
Is_Lower_Of( &m_rThis, pObj->GetDrawObj() ) )
continue;
- if( auto pFly = dynamic_cast<const SwFlyFrame*>(pObj) )
+ if( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->IsAnLower( &m_rThis ) )//This Lower of Fly?
continue;
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index bdc5f9d60a77..6f4b774dd3a4 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -322,7 +322,7 @@ void SwFlyFrame::DeleteCnt()
while ( pFrame->GetDrawObjs() && pFrame->GetDrawObjs()->size() )
{
SwAnchoredObject *pAnchoredObj = (*pFrame->GetDrawObjs())[0];
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
+ if ( auto pFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
SwFrame::DestroyFrame(pFlyFrame);
}
@@ -2392,7 +2392,7 @@ void SwFrame::InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs )
pAnchoredObj->SetClearedEnvironment( false );
}
// distinguish between writer fly frames and drawing objects
- if ( auto pFly = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
pFly->Invalidate_();
pFly->InvalidatePos_();
@@ -2426,7 +2426,7 @@ void SwLayoutFrame::NotifyLowerObjs( const bool _bUnlockPosOfObjs )
// for at-character/as-character anchored objects the anchor character
// text frame is taken.
const SwFrame* pAnchorFrame = pObj->GetAnchorFrameContainingAnchPos();
- if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->getFrameArea().Left() == FAR_AWAY )
continue;
@@ -2927,7 +2927,7 @@ SwTwips SwFlyFrame::CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
- if ( auto pFly = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
// consider only Writer fly frames, which follow the text flow.
if ( pFly->IsFlyLayFrame() &&
@@ -2957,4 +2957,15 @@ const SwFormatAnchor* SwFlyFrame::GetAnchorFromPoolItem(const SfxPoolItem& rItem
return nullptr;
}
}
+
+const SwFlyFrame* SwFlyFrame::DynCastFlyFrame() const
+{
+ return this;
+}
+
+SwFlyFrame* SwFlyFrame::DynCastFlyFrame()
+{
+ return this;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index d36da1909e27..71b0d493879a 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -148,7 +148,7 @@ void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rH
SwSortedObjs &rObjs = *pContent->GetDrawObjs();
for(SwAnchoredObject* rObj : rObjs)
{
- SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(rObj);
+ SwFlyFrame* pFlyFrame = rObj->DynCastFlyFrame();
if (pFlyFrame &&
&(pFlyFrame->GetFrameFormat()) == pMyFlyFrameFormat)
{
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index aee8a93f423b..6f46da0baba5 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -865,7 +865,7 @@ void SwPageFrame::AppendFlyToPage( SwFlyFrame *pNew )
SwSortedObjs &rObjs = *pNew->GetDrawObjs();
for (SwAnchoredObject* pTmpObj : rObjs)
{
- if ( auto pTmpFly = dynamic_cast<SwFlyFrame*>( pTmpObj) )
+ if ( auto pTmpFly = pTmpObj->DynCastFlyFrame() )
{
// #i28701# - use new method <GetPageFrame()>
if ( pTmpFly->IsFlyFreeFrame() && !pTmpFly->GetPageFrame() )
@@ -1009,7 +1009,7 @@ void SwPageFrame::MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest )
SwSortedObjs &rObjs = *pToMove->GetDrawObjs();
for (SwAnchoredObject* pObj : rObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyFreeFrame() )
{
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 59429f55ddf2..1602604f01c8 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -296,7 +296,7 @@ SwFrameNotify::~SwFrameNotify() COVERITY_NOEXCEPT_FALSE
// registered at the correct page frame, if frame
// position has changed.
if ( bAbsP && pContact->ObjAnchoredAtFly() &&
- dynamic_cast<const SwFlyFrame*>( pObj) != nullptr )
+ pObj->DynCastFlyFrame() != nullptr )
{
// determine to-fly anchored Writer fly frame
SwFlyFrame* pFlyFrame = static_cast<SwFlyFrame*>(pObj);
@@ -356,7 +356,7 @@ SwFrameNotify::~SwFrameNotify() COVERITY_NOEXCEPT_FALSE
// perform notification via the corresponding invalidations
if ( bNotify )
{
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFlyFrame = pObj->DynCastFlyFrame() )
{
if ( bNotifySize )
pFlyFrame->InvalidateSize_();
@@ -2307,7 +2307,7 @@ static bool lcl_hasTabFrame(const SwTextFrame* pTextFrame)
if (pSortedObjs->size() > 0)
{
SwAnchoredObject* pObject = (*pSortedObjs)[0];
- if (auto pFly = dynamic_cast<SwFlyFrame*>(pObject))
+ if (auto pFly = pObject->DynCastFlyFrame())
{
if (pFly->Lower() && pFly->Lower()->IsTabFrame())
return true;
@@ -2769,7 +2769,7 @@ static void lcl_RemoveObjsFromPage( SwFrame* _pFrame )
pObj->ResetLayoutProcessBools();
// #115759# - remove also lower objects of as-character
// anchored Writer fly frames from page
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFlyFrame = pObj->DynCastFlyFrame() )
{
// #115759# - remove also direct lowers of Writer
// fly frame from page
@@ -2928,7 +2928,7 @@ static void lcl_AddObjsToPage( SwFrame* _pFrame, SwPageFrame* _pPage )
pObj->UnlockPosition();
// #115759# - add also lower objects of as-character
// anchored Writer fly frames from page
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFlyFrame = pObj->DynCastFlyFrame() )
{
if (pFlyFrame->IsFlyFreeFrame())
{
@@ -3134,7 +3134,7 @@ static void lcl_Regist( SwPageFrame *pPage, const SwFrame *pAnch )
SwSortedObjs *pObjs = const_cast<SwSortedObjs*>(pAnch->GetDrawObjs());
for (SwAnchoredObject* pObj : *pObjs)
{
- if (SwFlyFrame* pFly = dynamic_cast<SwFlyFrame*>(pObj))
+ if (SwFlyFrame* pFly = pObj->DynCastFlyFrame())
{
// register (not if already known)
// #i28701# - use new method <GetPageFrame()>
@@ -3320,7 +3320,7 @@ static void lcl_NotifyContent( const SdrObject *pThis, SwContentFrame *pCnt,
const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
for (SwAnchoredObject* pObj : rObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyInContentFrame() )
{
@@ -3450,7 +3450,7 @@ void Notify_Background( const SdrObject* pObj,
const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) != nullptr )
+ if ( pAnchoredObj->DynCastFlyFrame() != nullptr )
{
if( pAnchoredObj->GetDrawObj() == pObj )
continue;
diff --git a/sw/source/core/layout/hffrm.cxx b/sw/source/core/layout/hffrm.cxx
index 2ad55a8bb0ab..b29713b18841 100644
--- a/sw/source/core/layout/hffrm.cxx
+++ b/sw/source/core/layout/hffrm.cxx
@@ -665,7 +665,7 @@ static void DelFlys( const SwLayoutFrame& rFrame, SwPageFrame &rPage)
i < rPage.GetSortedObjs()->size() )
{
SwAnchoredObject* pObj = (*rPage.GetSortedObjs())[i];
- if (SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pObj))
+ if (SwFlyFrame* pFlyFrame = pObj->DynCastFlyFrame())
{
if (rFrame.IsAnLower(pFlyFrame))
{
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 95a48df5efda..8bc306ee8505 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -919,7 +919,7 @@ static const SwFrame *lcl_FindFirstInvaContent( const SwLayoutFrame *pLay, tools
const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
for (SwAnchoredObject* pObj : rObjs)
{
- if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pObj ) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyInContentFrame() )
{
@@ -953,7 +953,7 @@ static const SwAnchoredObject* lcl_FindFirstInvaObj( const SwPageFrame* _pPage,
for (SwAnchoredObject* pObj : *_pPage->GetSortedObjs())
{
- if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pObj ) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->getFrameArea().Top() <= _nBottom )
{
@@ -2061,7 +2061,7 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, IdleJobType eJob )
const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
for (SwAnchoredObject* pObj : rObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pObj ) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyInContentFrame() )
{
@@ -2142,7 +2142,7 @@ bool SwLayIdle::DoIdleJob( IdleJobType eJob, bool bVisAreaOnly )
i < pPage->GetSortedObjs()->size(); ++i )
{
const SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
- if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pObj ) )
+ if ( auto pFly = pObj->DynCastFlyFrame() )
{
const SwContentFrame *pC = pFly->ContainsContent();
while( pC )
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx
index 1e4ae047b5fc..9af0d23ac69f 100644
--- a/sw/source/core/layout/laycache.cxx
+++ b/sw/source/core/layout/laycache.cxx
@@ -287,7 +287,7 @@ void SwLayoutCache::Write( SvStream &rStream, const SwDoc& rDoc )
SwSortedObjs &rObjs = *pPage->GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if (SwFlyFrame *pFly = dynamic_cast<SwFlyFrame*>(pAnchoredObj))
+ if (SwFlyFrame *pFly = pAnchoredObj->DynCastFlyFrame())
{
if( pFly->getFrameArea().Left() != FAR_AWAY &&
!pFly->GetAnchorFrame()->FindFooterOrHeader() )
@@ -1001,7 +1001,7 @@ void SwLayHelper::CheckFlyCache_( SwPageFrame* pPage )
o3tl::sorted_vector< const SdrObject*, SdrObjectCompare > aFlySet;
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if (SwFlyFrame *pFly = dynamic_cast<SwFlyFrame*>(pAnchoredObj)) // a text frame?
+ if (SwFlyFrame *pFly = pAnchoredObj->DynCastFlyFrame()) // a text frame?
{
if( pFly->GetAnchorFrame() &&
!pFly->GetAnchorFrame()->FindFooterOrHeader() )
diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx
index 184fcc820e33..15ca544a2d9c 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -224,7 +224,7 @@ void SwObjectFormatter::FormatLayout_( SwLayoutFrame& _rLayoutFrame )
*/
void SwObjectFormatter::FormatObjContent( SwAnchoredObject& _rAnchoredObj )
{
- if ( dynamic_cast<const SwFlyFrame*>( &_rAnchoredObj) == nullptr )
+ if ( !_rAnchoredObj.DynCastFlyFrame() )
{
// only Writer fly frames have content
return;
@@ -268,7 +268,7 @@ void SwObjectFormatter::FormatObj_( SwAnchoredObject& _rAnchoredObj )
mpPgNumAndTypeOfAnchors->Collect( _rAnchoredObj );
}
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( &_rAnchoredObj) )
+ if ( auto pFlyFrame = _rAnchoredObj.DynCastFlyFrame() )
{
// --> #i34753# - reset flag, which prevents a positioning
if ( pFlyFrame->IsFlyLayFrame() )
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 2f254f93f909..4d289a69e5d7 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -977,7 +977,7 @@ void SwPageFrame::PrepareRegisterChg()
for(SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
{
// #i28701#
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
pFrame = pFly->ContainsContent();
while ( pFrame )
@@ -1834,7 +1834,7 @@ void SwRootFrame::ImplCalcBrowseWidth()
// #i28701#
SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
- const bool bFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr;
+ const bool bFly = pAnchoredObj->DynCastFlyFrame() != nullptr;
if ((bFly && (FAR_AWAY == pAnchoredObj->GetObjRect().Width()))
|| rFormat.GetFrameSize().GetWidthPercent())
{
@@ -2006,7 +2006,7 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset )
SwObjPositioningInProgress aPosInProgress( *pAnchoredObj );
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
lcl_MoveAllLowers( pFlyFrame, rOffset );
// tdf#138785 update position specific to as-char flys
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index baa5a9ac40e1..ceba5eb0fe59 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1402,7 +1402,7 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
if (!pPage->GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId(pSdrObj->GetLayer()))
continue;
- const SwFlyFrame *pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ const SwFlyFrame *pFly = pAnchoredObj->DynCastFlyFrame();
if (!pFly)
continue;
@@ -3970,7 +3970,7 @@ void SwFrame::SetDrawObjsAsDeleted( bool bDeleted )
{
for (SwAnchoredObject* pAnchoredObj : *pObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
pFly->SetDeleted(bDeleted);
}
@@ -6571,7 +6571,7 @@ void SwLayoutFrame::RefreshLaySubsidiary( const SwPageFrame *pPage,
{
if ( pPage->GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId(
pAnchoredObj->GetDrawObj()->GetLayer() ) )
- if (auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
+ if (auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyInContentFrame() && pFly->getFrameArea().IsOver( rRect ) )
{
@@ -7046,7 +7046,7 @@ void SwPageFrame::RefreshExtraData( const SwRect &rRect ) const
if ( bLineInFly && GetSortedObjs() )
for (SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
{
- if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if ( pFly->getFrameArea().Top() <= aRect.Bottom() &&
pFly->getFrameArea().Bottom() >= aRect.Top() )
@@ -7078,7 +7078,7 @@ void SwLayoutFrame::RefreshExtraData( const SwRect &rRect ) const
if ( bLineInFly && pCnt->GetDrawObjs() )
for (SwAnchoredObject* pAnchoredObj : *pCnt->GetDrawObjs())
{
- if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyInContentFrame() &&
pFly->getFrameArea().Top() <= rRect.Bottom() &&
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index b4ac7980e90a..486d67bb9e95 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -267,7 +267,7 @@ void SwFrame::CheckDirChange()
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
- if( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if( auto pFlyFrame = pAnchoredObj->DynCastFlyFrame() )
pFlyFrame->CheckDirChange();
else
{
@@ -351,7 +351,7 @@ void SwFrame::DestroyImpl()
for (size_t i = m_pDrawObjs->size(); i; )
{
SwAnchoredObject* pAnchoredObj = (*m_pDrawObjs)[--i];
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
SwFrame::DestroyFrame(pFlyFrame);
}
@@ -504,7 +504,7 @@ void SwLayoutFrame::DestroyImpl()
const size_t nCnt = pFrame->GetDrawObjs()->size();
// #i28701#
SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[0];
- if (SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj))
+ if (SwFlyFrame* pFlyFrame = pAnchoredObj->DynCastFlyFrame())
{
SwFrame::DestroyFrame(pFlyFrame);
assert(!pFrame->GetDrawObjs() || nCnt > pFrame->GetDrawObjs()->size());
@@ -540,7 +540,7 @@ void SwLayoutFrame::DestroyImpl()
// #i28701#
SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
SwFrame::DestroyFrame(pFlyFrame);
assert(!GetDrawObjs() || nCnt > GetDrawObjs()->size());
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 3ec2a091749a..dcda38b419bf 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -258,7 +258,7 @@ static void lcl_InvalidateLowerObjs( SwLayoutFrame& _rLayoutFrame,
pAnchoredObj->UnlockPosition();
pAnchoredObj->InvalidateObjPos();
- SwFlyFrame *pFly = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+ SwFlyFrame *pFly = pAnchoredObj->DynCastFlyFrame();
// move anchored object 'out of range'
if ( _bMoveObjsOutOfRange )
@@ -2777,7 +2777,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
for ( size_t i = 0; i < pPage->GetSortedObjs()->size(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i];
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
const SwRect aFlyRect = pFly->GetObjRectWithSpaces();
// #i26945# - correction of conditions,
@@ -5001,7 +5001,7 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, tools::Long lYStart, bool bI
default: break;
}
}
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
// OD 2004-05-18 #i28701# - no direct move of objects,
@@ -5380,7 +5380,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
if ( bConsiderWrapOnObjPos || css::text::WrapTextMode_THROUGH != rSur.GetSurround() )
{
// frames, which the cell is a lower of, aren't relevant
- if ( auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if ( pFly->IsAnLower( this ) )
continue;
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 2ce4542351bd..377713b98178 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -389,7 +389,7 @@ bool SwPageFrame::FillSelection( SwSelectionList& rList, const SwRect& rRect ) c
const SwSortedObjs &rObjs = *GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ const SwFlyFrame* pFly = pAnchoredObj->DynCastFlyFrame();
if( !pFly )
continue;
if( pFly->FillSelection( rList, rRect ) )
@@ -2569,7 +2569,7 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ const SwFlyFrame* pFly = pAnchoredObj->DynCastFlyFrame();
if ( !pFly )
continue;
const SwVirtFlyDrawObj* pObj = pFly->GetVirtDrawObj();
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 53bf49df5346..a01b349f0de8 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1910,7 +1910,7 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
OSL_ENSURE( pBoss->IsPageFrame(), "Header/Footer out of page?" );
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
OSL_ENSURE( !pFly->IsFlyInContentFrame(), "FlyInCnt at Page?" );
const SwFormatVertOrient &rVert =
@@ -2063,7 +2063,7 @@ void SwFrame::ValidateThisAndAllLowers( const sal_uInt16 nStage )
const bool bOnlyObject = 1 == nStage;
const bool bIncludeObjects = 1 <= nStage;
- if ( !bOnlyObject || dynamic_cast< const SwFlyFrame *>( this ) != nullptr )
+ if ( !bOnlyObject || IsFlyFrame() )
{
setFrameAreaSizeValid(true);
setFramePrintAreaValid(true);
@@ -2079,7 +2079,7 @@ void SwFrame::ValidateThisAndAllLowers( const sal_uInt16 nStage )
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchObj = (*pObjs)[i];
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchObj ) )
+ if ( auto pFlyFrame = pAnchObj->DynCastFlyFrame() )
pFlyFrame->ValidateThisAndAllLowers( 2 );
else if ( auto pAnchoredDrawObj = dynamic_cast<SwAnchoredDrawObject *>( pAnchObj ) )
pAnchoredDrawObj->ValidateThis();
@@ -3532,7 +3532,7 @@ static void InvaPercentFlys( SwFrame *pFrame, SwTwips nDiff )
OSL_ENSURE( pFrame->GetDrawObjs(), "Can't find any Objects" );
for (SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
{
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
const SwFormatFrameSize &rSz = pFly->GetFormat()->GetFrameSize();
if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
@@ -3663,7 +3663,7 @@ static bool lcl_IsFlyHeightClipped( SwLayoutFrame *pLay )
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if ( pFly->IsHeightClipped() &&
( !pFly->IsFlyFreeFrame() || pFly->GetPageFrame() ) )
@@ -3970,7 +3970,7 @@ void SwLayoutFrame::FormatWidthCols( const SwBorderAttrs &rAttrs,
}
// #i68520#
- SwFlyFrame *pFlyFrame = dynamic_cast<SwFlyFrame*>(this);
+ SwFlyFrame *pFlyFrame = IsFlyFrame() ? static_cast<SwFlyFrame*>(this) : nullptr;
if (pFlyFrame)
{
pFlyFrame->InvalidateObjRectWithSpaces();
@@ -4140,7 +4140,7 @@ static void lcl_InvalidateAllContent( SwContentFrame *pCnt, SwInvalidateFlags nI
SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if ( pFly->IsFlyInContentFrame() )
{
@@ -4170,7 +4170,7 @@ void SwRootFrame::InvalidateAllContent( SwInvalidateFlags nInv )
const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
::lcl_InvalidateContent( pFly->ContainsContent(), nInv );
if ( nInv & SwInvalidateFlags::Direction )
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 323d6772184c..ee516c49eec5 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -903,7 +903,7 @@ SwTwips SwAnchoredObjectPosition::CalcRelPosX(
// it is horizontal positioned left or right, but not relative to character,
// it has to be drawn aside another object, which have the same horizontal
// position and lay below it.
- if ( dynamic_cast<const SwFlyFrame*>( &GetAnchoredObj() ) != nullptr &&
+ if ( GetAnchoredObj().DynCastFlyFrame() &&
( mpContact->ObjAnchoredAtPara() || mpContact->ObjAnchoredAtChar() ) &&
( eHoriOrient == text::HoriOrientation::LEFT || eHoriOrient == text::HoriOrientation::RIGHT ) &&
eRelOrient != text::RelOrientation::CHAR )
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 8f94315a2c5c..287b32460ad6 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1926,7 +1926,7 @@ bool SwTextFrame::FillSelection( SwSelectionList& rSelList, const SwRect& rRect
const SwSortedObjs &rObjs = *GetDrawObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ const SwFlyFrame* pFly = pAnchoredObj->DynCastFlyFrame();
if( !pFly )
continue;
if( pFly->IsFlyInContentFrame() && pFly->FillSelection( rSelList, rRect ) )
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index aade772d4bb9..743f23dd87af 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -165,7 +165,7 @@ void SwTextFrame::MoveFlyInCnt(SwTextFrame *pNew,
TextFrameIndex const nIndex(MapModelToViewPos(*pPos));
if (nStart <= nIndex && nIndex < nEnd)
{
- if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFlyFrame = pAnchoredObj->DynCastFlyFrame() )
{
RemoveFly( pFlyFrame );
pNew->AppendFly( pFlyFrame );
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 052b95fec597..5a2ee141a67d 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -669,7 +669,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
for ( size_t i = 0; rInf.GetTextFrame()->GetDrawObjs() && i < pObjs->size(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*rInf.GetTextFrame()->GetDrawObjs())[i];
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
bool bDeleted = false;
size_t nAuthor = std::string::npos;
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index b2799b08acf8..2e8e58b533ab 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -176,7 +176,7 @@ SwRect SwContourCache::CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
}
if( bHandleContour &&
- ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) == nullptr ||
+ ( pAnchoredObj->DynCastFlyFrame() == nullptr ||
( static_cast<const SwFlyFrame*>(pAnchoredObj)->Lower() &&
static_cast<const SwFlyFrame*>(pAnchoredObj)->Lower()->IsNoTextFrame() ) ) )
{
@@ -492,22 +492,21 @@ void SwTextFly::DrawTextOpaque( SwDrawTextInfo &rInf )
{
// #i68520#
const SwAnchoredObject* pTmpAnchoredObj = (*mpAnchoredObjList)[i];
- if( dynamic_cast<const SwFlyFrame*>(pTmpAnchoredObj) &&
- mpCurrAnchoredObj != pTmpAnchoredObj )
+ const SwFlyFrame* pFly = pTmpAnchoredObj->DynCastFlyFrame();
+ if( pFly && mpCurrAnchoredObj != pTmpAnchoredObj )
{
// #i68520#
- const SwFlyFrame& rFly = dynamic_cast<const SwFlyFrame&>(*pTmpAnchoredObj);
- if( aRegion.GetOrigin().IsOver( rFly.getFrameArea() ) )
+ if( aRegion.GetOrigin().IsOver( pFly->getFrameArea() ) )
{
- const SwFrameFormat *pFormat = rFly.GetFormat();
+ const SwFrameFormat *pFormat = pFly->GetFormat();
const SwFormatSurround &rSur = pFormat->GetSurround();
const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
// Only the ones who are opaque and more to the top
- if( ! rFly.IsBackgroundTransparent() &&
+ if( ! pFly->IsBackgroundTransparent() &&
css::text::WrapTextMode_THROUGH == rSur.GetSurround() &&
( !rSur.IsAnchorOnly() ||
// #i68520#
- GetMaster() == rFly.GetAnchorFrame() ||
+ GetMaster() == pFly->GetAnchorFrame() ||
((RndStdIds::FLY_AT_PARA != rAnchor.GetAnchorId()) &&
(RndStdIds::FLY_AT_CHAR != rAnchor.GetAnchorId())
)
@@ -519,14 +518,14 @@ void SwTextFly::DrawTextOpaque( SwDrawTextInfo &rInf )
{
// Except for the content is transparent
const SwNoTextFrame *pNoText =
- rFly.Lower() && rFly.Lower()->IsNoTextFrame()
- ? static_cast<const SwNoTextFrame*>(rFly.Lower())
+ pFly->Lower() && pFly->Lower()->IsNoTextFrame()
+ ? static_cast<const SwNoTextFrame*>(pFly->Lower())
: nullptr;
if ( !pNoText ||
(!pNoText->IsTransparent() && !rSur.IsContour()) )
{
bOpaque = true;
- aRegion -= rFly.getFrameArea();
+ aRegion -= pFly->getFrameArea();
}
}
}
@@ -582,7 +581,7 @@ void SwTextFly::DrawFlyRect( OutputDevice* pOut, const SwRect &rRect )
continue;
// #i68520#
- const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObjTmp);
+ const SwFlyFrame* pFly = pAnchoredObjTmp->DynCastFlyFrame();
if (pFly)
{
// #i68520#
@@ -669,7 +668,7 @@ bool SwTextFly::GetTop( const SwAnchoredObject* _pAnchoredObj,
// bEvade: consider pNew, if we are not inside a fly
// consider pNew, if pNew is lower of <mpCurrAnchoredObj>
bool bEvade = !mpCurrAnchoredObj ||
- Is_Lower_Of( dynamic_cast<const SwFlyFrame*>(mpCurrAnchoredObj), pNew);
+ Is_Lower_Of( mpCurrAnchoredObj->DynCastFlyFrame(), pNew);
if ( !bEvade )
{
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index c7ff1de7cd7e..66f32157a59d 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2424,7 +2424,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
- if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
{
if( !pFly->IsFlyInContentFrame() )
{
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index c35388bccb24..ed9e525da9de 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -240,7 +240,7 @@ static SwTwips lcl_GetFootnoteLower( const SwTextFrame* pFrame, SwTwips nLower )
{
SwRect aRect( pAnchoredObj->GetObjRect() );
- auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pAnchoredObj );
+ auto pFlyFrame = pAnchoredObj->DynCastFlyFrame();
if ( !pFlyFrame ||
pFlyFrame->isFrameAreaDefinitionValid() )
{
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index fd3d0ef4d62e..03cf10e86b80 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -406,7 +406,7 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
for (SwAnchoredObject const*const pObj : *pObjs)
{ // just print pointer, full details will be printed on its anchor frame
// this nonsense is needed because of multiple inheritance
- if (SwFlyFrame const*const pFly = dynamic_cast<SwFlyFrame const*>(pObj))
+ if (SwFlyFrame const* pFly = pObj->DynCastFlyFrame())
{
(void)xmlTextWriterStartElement(writer, BAD_CAST("fly"));
(void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pFly);
More information about the Libreoffice-commits
mailing list