summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-10-13 09:45:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-13 10:34:24 +0200
commitc93cdd4e2416c81ccc4b90fd96421d7e45cecd70 (patch)
tree7be3b0f61ffb1900ea3be238d1849be02fcb1bc6 /sw
parente360269e8e217359e131ca4ae33a5668a2efab78 (diff)
static_cast after dynamic_cast
Change-Id: If1194bd3364fef8b2d0c26c22854745d0fb7b412 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104223 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/layout/objectformatter.cxx29
-rw-r--r--sw/source/core/layout/pagechg.cxx37
-rw-r--r--sw/source/core/layout/paintfrm.cxx27
-rw-r--r--sw/source/core/layout/sectfrm.cxx16
-rw-r--r--sw/source/core/layout/ssfrm.cxx12
-rw-r--r--sw/source/core/layout/tabfrm.cxx6
-rw-r--r--sw/source/core/layout/trvlfrm.cxx8
-rw-r--r--sw/source/core/layout/wsfrm.cxx23
-rw-r--r--sw/source/core/sw3io/swacorr.cxx6
-rw-r--r--sw/source/core/text/itrcrsr.cxx4
-rw-r--r--sw/source/core/text/porfly.cxx6
-rw-r--r--sw/source/core/text/porrst.cxx3
-rw-r--r--sw/source/core/text/txtfrm.cxx3
-rw-r--r--sw/source/core/undo/rolbck.cxx10
14 files changed, 84 insertions, 106 deletions
diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx
index e48439a2bdf0..ca7d713273d4 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -267,13 +267,12 @@ void SwObjectFormatter::FormatObj_( SwAnchoredObject& _rAnchoredObj )
mpPgNumAndTypeOfAnchors->Collect( _rAnchoredObj );
}
- if ( dynamic_cast<const SwFlyFrame*>( &_rAnchoredObj) != nullptr )
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( &_rAnchoredObj) )
{
- SwFlyFrame& rFlyFrame = static_cast<SwFlyFrame&>(_rAnchoredObj);
// --> #i34753# - reset flag, which prevents a positioning
- if ( rFlyFrame.IsFlyLayFrame() )
+ if ( pFlyFrame->IsFlyLayFrame() )
{
- static_cast<SwFlyLayFrame&>(rFlyFrame).SetNoMakePos( false );
+ static_cast<SwFlyLayFrame*>(pFlyFrame)->SetNoMakePos( false );
}
// #i81146# new loop control
@@ -283,7 +282,7 @@ void SwObjectFormatter::FormatObj_( SwAnchoredObject& _rAnchoredObj )
do {
if ( mpLayAction )
{
- mpLayAction->FormatLayoutFly( &rFlyFrame );
+ mpLayAction->FormatLayoutFly( pFlyFrame );
// --> consider, if the layout action
// has to be restarted due to a delete of a page frame.
if ( mpLayAction->IsAgain() )
@@ -293,22 +292,22 @@ void SwObjectFormatter::FormatObj_( SwAnchoredObject& _rAnchoredObj )
}
else
{
- FormatLayout_( rFlyFrame );
+ FormatLayout_( *pFlyFrame );
}
// --> #i34753# - prevent further positioning, if
// to-page|to-fly anchored Writer fly frame is already clipped.
- if ( rFlyFrame.IsFlyLayFrame() && rFlyFrame.IsClipped() )
+ if ( pFlyFrame->IsFlyLayFrame() && pFlyFrame->IsClipped() )
{
- static_cast<SwFlyLayFrame&>(rFlyFrame).SetNoMakePos( true );
+ static_cast<SwFlyLayFrame*>(pFlyFrame)->SetNoMakePos( true );
}
// #i23129#, #i36347# - pass correct page frame
// to the object formatter
- SwObjectFormatter::FormatObjsAtFrame( rFlyFrame,
- *(rFlyFrame.FindPageFrame()),
+ SwObjectFormatter::FormatObjsAtFrame( *pFlyFrame,
+ *(pFlyFrame->FindPageFrame()),
mpLayAction );
if ( mpLayAction )
{
- mpLayAction->FormatFlyContent( &rFlyFrame );
+ mpLayAction->FormatFlyContent( pFlyFrame );
// --> consider, if the layout action
// has to be restarted due to a delete of a page frame.
if ( mpLayAction->IsAgain() )
@@ -318,21 +317,21 @@ void SwObjectFormatter::FormatObj_( SwAnchoredObject& _rAnchoredObj )
}
else
{
- FormatObjContent( rFlyFrame );
+ FormatObjContent( *pFlyFrame );
}
if ( ++nLoopControlRuns >= nLoopControlMax )
{
OSL_FAIL( "LoopControl in SwObjectFormatter::FormatObj_: Stage 3!!!" );
- rFlyFrame.ValidateThisAndAllLowers( 2 );
+ pFlyFrame->ValidateThisAndAllLowers( 2 );
nLoopControlRuns = 0;
}
// --> #i57917#
// stop formatting of anchored object, if restart of layout process is requested.
- } while ( !rFlyFrame.isFrameAreaDefinitionValid() &&
+ } while ( !pFlyFrame->isFrameAreaDefinitionValid() &&
!_rAnchoredObj.RestartLayoutProcess() &&
- rFlyFrame.GetAnchorFrame() == &GetAnchorFrame() );
+ pFlyFrame->GetAnchorFrame() == &GetAnchorFrame() );
}
else if ( dynamic_cast<const SwAnchoredDrawObject*>( &_rAnchoredObj) != nullptr )
{
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index eee3bfb9ade5..73ca8c534e5f 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -430,9 +430,8 @@ static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage )
// OD 23.06.2003 #108784# - consider 'virtual' drawing objects
SwDrawContact *pContact =
static_cast<SwDrawContact*>(::GetUserCall(pSdrObj));
- if ( dynamic_cast< const SwDrawVirtObj *>( pSdrObj ) != nullptr )
+ if ( auto pDrawVirtObj = dynamic_cast<SwDrawVirtObj *>( pSdrObj ) )
{
- SwDrawVirtObj* pDrawVirtObj = static_cast<SwDrawVirtObj*>(pSdrObj);
if ( pContact )
{
pDrawVirtObj->RemoveFromWriterLayout();
@@ -851,9 +850,8 @@ void SwPageFrame::Cut()
// #i28701#
SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
- if ( dynamic_cast< const SwFlyAtContentFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyAtContentFrame *>( pAnchoredObj ) )
{
- SwFlyFrame* pFly = static_cast<SwFlyAtContentFrame*>(pAnchoredObj);
SwPageFrame *pAnchPage = pFly->GetAnchorFrame() ?
pFly->AnchorFrame()->FindPageFrame() : nullptr;
if ( pAnchPage && (pAnchPage != this) )
@@ -949,9 +947,8 @@ static void lcl_PrepFlyInCntRegister( SwContentFrame *pFrame )
for(SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
{
// #i28701#
- if ( dynamic_cast< const SwFlyInContentFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyInContentFrame *>( pAnchoredObj ) )
{
- SwFlyFrame* pFly = static_cast<SwFlyInContentFrame*>(pAnchoredObj);
SwContentFrame *pCnt = pFly->ContainsContent();
while ( pCnt )
{
@@ -978,9 +975,8 @@ void SwPageFrame::PrepareRegisterChg()
for(SwAnchoredObject* pAnchoredObj : *GetSortedObjs())
{
// #i28701#
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
pFrame = pFly->ContainsContent();
while ( pFrame )
{
@@ -1867,8 +1863,8 @@ void SwRootFrame::StartAllAction()
if ( GetCurrShell() )
for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
{
- if ( dynamic_cast<const SwCursorShell*>( &rSh) != nullptr )
- static_cast<SwCursorShell*>(&rSh)->StartAction();
+ if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
+ pCursorShell->StartAction();
else
rSh.StartAction();
}
@@ -1883,12 +1879,12 @@ void SwRootFrame::EndAllAction( bool bVirDev )
{
const bool bOldEndActionByVirDev = rSh.IsEndActionByVirDev();
rSh.SetEndActionByVirDev( bVirDev );
- if ( dynamic_cast<const SwCursorShell*>( &rSh) != nullptr )
+ if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
{
- static_cast<SwCursorShell*>(&rSh)->EndAction();
- static_cast<SwCursorShell*>(&rSh)->CallChgLnk();
- if ( dynamic_cast<const SwFEShell*>( &rSh) != nullptr )
- static_cast<SwFEShell*>(&rSh)->SetChainMarker();
+ pCursorShell->EndAction();
+ pCursorShell->CallChgLnk();
+ if ( auto pFEShell = dynamic_cast<SwFEShell*>( &rSh) )
+ pFEShell->SetChainMarker();
}
else
rSh.EndAction();
@@ -1941,8 +1937,8 @@ void SwRootFrame::UnoRestoreAllActions()
sal_uInt16 nActions = rSh.GetRestoreActions();
while( nActions-- )
{
- if ( dynamic_cast<const SwCursorShell*>( &rSh) != nullptr )
- static_cast<SwCursorShell*>(&rSh)->StartAction();
+ if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
+ pCursorShell->StartAction();
else
rSh.StartAction();
}
@@ -1979,9 +1975,8 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset )
SwObjPositioningInProgress aPosInProgress( *pAnchoredObj );
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame* pFlyFrame( static_cast<SwFlyFrame*>(pAnchoredObj) );
lcl_MoveAllLowers( pFlyFrame, rOffset );
pFlyFrame->NotifyDrawObj();
// --> let the active embedded object be moved
@@ -2010,10 +2005,8 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset )
}
}
}
- else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchoredObj ) != nullptr )
+ else if ( auto pAnchoredDrawObj = dynamic_cast<SwAnchoredDrawObject *>( pAnchoredObj ) )
{
- SwAnchoredDrawObject* pAnchoredDrawObj( static_cast<SwAnchoredDrawObject*>(pAnchoredObj) );
-
// don't touch objects that are not yet positioned:
if ( pAnchoredDrawObj->NotYetPositioned() )
continue;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index bbb6868a235f..39bc05d4d806 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1395,11 +1395,10 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
if (!pPage->GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId(pSdrObj->GetLayer()))
continue;
- if (dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) == nullptr)
+ const SwFlyFrame *pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ if (!pFly)
continue;
- const SwFlyFrame *pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
-
if (pSelfFly == pFly || gProp.pSRetoucheFly == pFly || !rRect.IsOver(pFly->getFrameArea()))
continue;
@@ -3815,9 +3814,9 @@ bool SwFlyFrame::IsPaint( SdrObject *pObj, const SwViewShell *pSh )
{
bPaint = false;
}
- if ( dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) != nullptr )
+ if ( auto pFlyDraw = dynamic_cast<SwVirtFlyDrawObj *>( pObj ) )
{
- SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
+ SwFlyFrame *pFly = pFlyDraw->GetFlyFrame();
if ( gProp.pSFlyOnlyDraw && gProp.pSFlyOnlyDraw == pFly )
return true;
@@ -6472,18 +6471,16 @@ void SwLayoutFrame::RefreshLaySubsidiary( const SwPageFrame *pPage,
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
if ( pPage->GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId(
- pAnchoredObj->GetDrawObj()->GetLayer() ) &&
- dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
- {
- const SwFlyFrame *pFly =
- static_cast<const SwFlyFrame*>(pAnchoredObj);
- if ( pFly->IsFlyInContentFrame() && pFly->getFrameArea().IsOver( rRect ) )
+ pAnchoredObj->GetDrawObj()->GetLayer() ) )
+ if (auto pFly = dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) )
{
- if ( !pFly->Lower() || !pFly->Lower()->IsNoTextFrame() ||
- !static_cast<const SwNoTextFrame*>(pFly->Lower())->HasAnimation())
- pFly->RefreshLaySubsidiary( pPage, rRect );
+ if ( pFly->IsFlyInContentFrame() && pFly->getFrameArea().IsOver( rRect ) )
+ {
+ if ( !pFly->Lower() || !pFly->Lower()->IsNoTextFrame() ||
+ !static_cast<const SwNoTextFrame*>(pFly->Lower())->HasAnimation())
+ pFly->RefreshLaySubsidiary( pPage, rRect );
+ }
}
- }
}
}
}
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 2e5ebf3f1c29..e6daa4b65ee8 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -866,8 +866,8 @@ const SwSectionFormat* SwSectionFrame::GetEndSectFormat_() const
const SwSectionFormat *pFormat = m_pSection->GetFormat();
while( !pFormat->GetEndAtTextEnd().IsAtEnd() )
{
- if( dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) != nullptr )
- pFormat = static_cast<const SwSectionFormat*>(pFormat->GetRegisteredIn());
+ if( auto pNewFormat = dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) )
+ pFormat = pNewFormat;
else
return nullptr;
}
@@ -2515,8 +2515,8 @@ bool SwSectionFrame::IsDescendantFrom( const SwSectionFormat* pFormat ) const
const SwSectionFormat *pMyFormat = m_pSection->GetFormat();
while( pFormat != pMyFormat )
{
- if( dynamic_cast< const SwSectionFormat *>( pMyFormat->GetRegisteredIn()) != nullptr )
- pMyFormat = static_cast<const SwSectionFormat*>(pMyFormat->GetRegisteredIn());
+ if( auto pNewFormat = dynamic_cast< const SwSectionFormat *>( pMyFormat->GetRegisteredIn()) )
+ pMyFormat = pNewFormat;
else
return false;
}
@@ -2532,8 +2532,8 @@ void SwSectionFrame::CalcFootnoteAtEndFlag()
FTNEND_ATTXTEND_OWNNUMANDFMT == nVal;
while( !m_bFootnoteAtEnd && !m_bOwnFootnoteNum )
{
- if( dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) != nullptr )
- pFormat = static_cast<SwSectionFormat*>(pFormat->GetRegisteredIn());
+ if( auto pNewFormat = dynamic_cast<SwSectionFormat *>( pFormat->GetRegisteredIn()) )
+ pFormat = pNewFormat;
else
break;
nVal = pFormat->GetFootnoteAtTextEnd( false ).GetValue();
@@ -2557,8 +2557,8 @@ void SwSectionFrame::CalcEndAtEndFlag()
m_bEndnAtEnd = pFormat->GetEndAtTextEnd( false ).IsAtEnd();
while( !m_bEndnAtEnd )
{
- if( dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) != nullptr )
- pFormat = static_cast<SwSectionFormat*>(pFormat->GetRegisteredIn());
+ if( auto pNewFormat = dynamic_cast<SwSectionFormat *>( pFormat->GetRegisteredIn()) )
+ pFormat = pNewFormat;
else
break;
m_bEndnAtEnd = pFormat->GetEndAtTextEnd( false ).IsAtEnd();
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 602ccab141b6..7fe3bc82b9fa 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -265,8 +265,8 @@ void SwFrame::CheckDirChange()
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
- if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
- static_cast<SwFlyFrame*>(pAnchoredObj)->CheckDirChange();
+ if( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+ pFlyFrame->CheckDirChange();
else
{
// OD 2004-04-06 #i26791# - direct object
@@ -349,9 +349,9 @@ void SwFrame::DestroyImpl()
for (size_t i = m_pDrawObjs->size(); i; )
{
SwAnchoredObject* pAnchoredObj = (*m_pDrawObjs)[--i];
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
+ SwFrame::DestroyFrame(pFlyFrame);
}
else
{
@@ -532,9 +532,9 @@ void SwLayoutFrame::DestroyImpl()
// #i28701#
SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
+ SwFrame::DestroyFrame(pFlyFrame);
assert(!GetDrawObjs() || nCnt > GetDrawObjs()->size());
}
else
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 288ac0e760c8..103f8260037a 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2746,9 +2746,8 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
for ( size_t i = 0; i < pPage->GetSortedObjs()->size(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i];
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
const SwRect aFlyRect = pFly->GetObjRectWithSpaces();
// #i26945# - correction of conditions,
// if Writer fly frame has to be considered:
@@ -4868,9 +4867,8 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, long lYStart, bool bInva )
default: break;
}
}
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
// OD 2004-05-18 #i28701# - no direct move of objects,
// which are anchored to-paragraph/to-character, if
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 30633ba4bd2d..745cec996b5c 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -388,9 +388,9 @@ bool SwPageFrame::FillSelection( SwSelectionList& rList, const SwRect& rRect ) c
const SwSortedObjs &rObjs = *GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) == nullptr )
+ const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ if( !pFly )
continue;
- const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
if( pFly->FillSelection( rList, rRect ) )
bRet = true;
}
@@ -2568,9 +2568,9 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) == nullptr )
+ const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ if ( !pFly )
continue;
- const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
const SwVirtFlyDrawObj* pObj = pFly->GetVirtDrawObj();
const SwFormatSurround &rSur = pFly->GetFormat()->GetSurround();
SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat().GetAnchor());
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 70e3fdfaa92f..254c1640392a 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1875,9 +1875,8 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
OSL_ENSURE( pBoss->IsPageFrame(), "Header/Footer out of page?" );
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
OSL_ENSURE( !pFly->IsFlyInContentFrame(), "FlyInCnt at Page?" );
const SwFormatVertOrient &rVert =
pFly->GetFormat()->GetVertOrient();
@@ -2045,10 +2044,10 @@ void SwFrame::ValidateThisAndAllLowers( const sal_uInt16 nStage )
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchObj = (*pObjs)[i];
- if ( dynamic_cast< const SwFlyFrame *>( pAnchObj ) != nullptr )
- static_cast<SwFlyFrame*>(pAnchObj)->ValidateThisAndAllLowers( 2 );
- else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchObj ) != nullptr )
- static_cast<SwAnchoredDrawObject*>(pAnchObj)->ValidateThis();
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchObj ) )
+ pFlyFrame->ValidateThisAndAllLowers( 2 );
+ else if ( auto pAnchoredDrawObj = dynamic_cast<SwAnchoredDrawObject *>( pAnchObj ) )
+ pAnchoredDrawObj->ValidateThis();
}
}
}
@@ -3478,9 +3477,8 @@ static void InvaPercentFlys( SwFrame *pFrame, SwTwips nDiff )
OSL_ENSURE( pFrame->GetDrawObjs(), "Can't find any Objects" );
for (SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
{
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
const SwFormatFrameSize &rSz = pFly->GetFormat()->GetFrameSize();
if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
{
@@ -3610,9 +3608,8 @@ static bool lcl_IsFlyHeightClipped( SwLayoutFrame *pLay )
for ( size_t i = 0; i < nCnt; ++i )
{
SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
if ( pFly->IsHeightClipped() &&
( !pFly->IsFlyFreeFrame() || pFly->GetPageFrame() ) )
return true;
@@ -4088,9 +4085,8 @@ static void lcl_InvalidateAllContent( SwContentFrame *pCnt, SwInvalidateFlags nI
SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
if ( pFly->IsFlyInContentFrame() )
{
::lcl_InvalidateContent( pFly->ContainsContent(), nInv );
@@ -4119,9 +4115,8 @@ void SwRootFrame::InvalidateAllContent( SwInvalidateFlags nInv )
const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
::lcl_InvalidateContent( pFly->ContainsContent(), nInv );
if ( nInv & SwInvalidateFlags::Direction )
pFly->CheckDirChange();
diff --git a/sw/source/core/sw3io/swacorr.cxx b/sw/source/core/sw3io/swacorr.cxx
index 19c0b236fa05..97fcc55431b0 100644
--- a/sw/source/core/sw3io/swacorr.cxx
+++ b/sw/source/core/sw3io/swacorr.cxx
@@ -64,10 +64,10 @@ bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg,
const OUString& rFileName, const OUString& rShort,
SfxObjectShell& rObjSh, OUString& rLong )
{
- if( nullptr == dynamic_cast<const SwDocShell*>( &rObjSh) )
+ SwDocShell* pDShell = dynamic_cast<SwDocShell*>(&rObjSh);
+ if( !pDShell )
return false;
- SwDocShell& rDShell = static_cast<SwDocShell&>(rObjSh);
ErrCode nRet = ERRCODE_NONE;
// mba: relative URLs don't make sense here
@@ -77,7 +77,7 @@ bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg,
nRet = aBlk.BeginPutDoc( rShort, rShort );
if( ! nRet.IsError() )
{
- rDShell.GetEditShell()->CopySelToDoc( *pDoc );
+ pDShell->GetEditShell()->CopySelToDoc( *pDoc );
nRet = aBlk.PutDoc();
aBlk.AddName ( rShort, rShort );
if( ! nRet.IsError() )
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 9ca00be6df8d..a7e7752796f7 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1910,9 +1910,9 @@ bool SwTextFrame::FillSelection( SwSelectionList& rSelList, const SwRect& rRect
const SwSortedObjs &rObjs = *GetDrawObjs();
for (SwAnchoredObject* pAnchoredObj : rObjs)
{
- if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) == nullptr )
+ const SwFlyFrame* pFly = dynamic_cast<const SwFlyFrame*>(pAnchoredObj);
+ if( !pFly )
continue;
- const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj);
if( pFly->IsFlyInContentFrame() && pFly->FillSelection( rSelList, rRect ) )
bRet = true;
}
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 8a34966b7873..a352984aba18 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -163,10 +163,10 @@ void SwTextFrame::MoveFlyInCnt(SwTextFrame *pNew,
TextFrameIndex const nIndex(MapModelToViewPos(*pPos));
if (nStart <= nIndex && nIndex < nEnd)
{
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- RemoveFly( static_cast<SwFlyFrame*>(pAnchoredObj) );
- pNew->AppendFly( static_cast<SwFlyFrame*>(pAnchoredObj) );
+ RemoveFly( pFlyFrame );
+ pNew->AppendFly( pFlyFrame );
}
else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchoredObj ) != nullptr )
{
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index c37e03e7b3a4..ec7d14e5e605 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -205,8 +205,7 @@ SwTwips SwTextFrame::EmptyHeight() const
{
if (IsCollapse()) {
SwViewShell *pSh = getRootFrame()->GetCurrShell();
- if ( dynamic_cast<const SwCursorShell*>( pSh ) != nullptr ) {
- SwCursorShell *pCrSh = static_cast<SwCursorShell*>(pSh);
+ if ( auto pCrSh = dynamic_cast<SwCursorShell*>( pSh ) ) {
// this is called during formatting so avoid recursive layout
SwContentFrame const*const pCurrFrame = pCrSh->GetCurrFrame(false);
if (pCurrFrame==static_cast<SwContentFrame const *>(this)) {
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 93d9e775966b..0178f275e540 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2412,9 +2412,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
{
- SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
if( !pFly->IsFlyInContentFrame() )
{
const SvxBrushItem &rBack =
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index d7464b6f58d2..54fcd33b6815 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -1510,15 +1510,13 @@ void SwRegHistory::MakeSetWhichIds()
return;
const SfxItemSet* pSet = nullptr;
- if( dynamic_cast< const SwContentNode *>( GetRegisteredIn() ) != nullptr )
+ if( auto pContentNode = dynamic_cast< const SwContentNode *>( GetRegisteredIn() ) )
{
- pSet = static_cast<SwContentNode*>(
- GetRegisteredIn())->GetpSwAttrSet();
+ pSet = pContentNode->GetpSwAttrSet();
}
- else if ( dynamic_cast< const SwFormat *>( GetRegisteredIn() ) != nullptr )
+ else if ( auto pSwFormat = dynamic_cast< const SwFormat *>( GetRegisteredIn() ) )
{
- pSet = &static_cast<SwFormat*>(
- GetRegisteredIn())->GetAttrSet();
+ pSet = &pSwFormat->GetAttrSet();
}
if( pSet && pSet->Count() )
{