summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-10-12 16:09:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-13 09:30:12 +0200
commitf9ac067da9e61f479e2433d500b9b940e5a45470 (patch)
tree1b057d3b97cc7dcf6d3de377da34cbf23af9c3ee
parent3ee3ae85de3a29ebfb89e75960b65417bfd6ca55 (diff)
static_cast after dynamic_cast
Change-Id: I487b5dc148f5a3d0d45f198c00179002841242ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104213 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/runtime/methods1.cxx16
-rw-r--r--basic/source/sbx/sbxvalue.cxx4
-rw-r--r--cui/source/dialogs/zoom.cxx9
-rw-r--r--editeng/source/editeng/impedit5.cxx3
-rw-r--r--filter/source/msfilter/svdfppt.cxx18
-rw-r--r--reportdesign/source/ui/misc/UITools.cxx108
-rw-r--r--sc/source/core/tool/detfunc.cxx30
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx6
-rw-r--r--sc/source/ui/app/inputwin.cxx4
-rw-r--r--sc/source/ui/app/scmod.cxx6
-rw-r--r--sc/source/ui/docshell/docsh.cxx19
-rw-r--r--sc/source/ui/docshell/docsh4.cxx4
-rw-r--r--sc/source/ui/drawfunc/fuconrec.cxx4
-rw-r--r--sc/source/ui/navipi/content.cxx4
-rw-r--r--sc/source/ui/pagedlg/tphfedit.cxx8
-rw-r--r--sw/source/core/view/vdraw.cxx8
-rw-r--r--sw/source/core/view/viewsh.cxx30
-rw-r--r--sw/source/filter/html/swhtml.cxx4
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx3
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx3
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx23
-rw-r--r--sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx4
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx4
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx16
24 files changed, 161 insertions, 177 deletions
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index fdf4e9560b1b..807806e4cea8 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -115,11 +115,9 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
SbxObject* pObj = nullptr;
if( pObjVar )
pObj = dynamic_cast<SbxObject*>( pObjVar );
- if( !pObj && dynamic_cast<const SbxVariable*>( pObjVar) )
- {
- SbxBase* pObjVarObj = static_cast<SbxVariable*>(pObjVar)->GetObject();
- pObj = dynamic_cast<SbxObject*>( pObjVarObj );
- }
+ if( !pObj )
+ if (auto pSbxVar = dynamic_cast<const SbxVariable*>( pObjVar))
+ pObj = dynamic_cast<SbxObject*>( pSbxVar->GetObject() );
if( !pObj )
{
StarBASIC::Error( ERRCODE_BASIC_BAD_PARAMETER );
@@ -854,11 +852,9 @@ void SbRtl_FindPropertyObject(StarBASIC *, SbxArray & rPar, bool)
{
pObj = dynamic_cast<SbxObject*>( pObjVar );
}
- if( !pObj && dynamic_cast<const SbxVariable*>( pObjVar) )
- {
- SbxBase* pObjVarObj = static_cast<SbxVariable*>(pObjVar)->GetObject();
- pObj = dynamic_cast<SbxObject*>( pObjVarObj );
- }
+ if( !pObj )
+ if (auto pSbxVar = dynamic_cast<const SbxVariable*>( pObjVar))
+ pObj = dynamic_cast<SbxObject*>( pSbxVar->GetObject() );
OUString aNameStr = rPar.Get32(2)->GetOUString();
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 43a8e5243c83..74b2fcd23d98 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -668,8 +668,8 @@ bool SbxValue::ImpIsNumeric( bool bOnlyIntntl ) const
return false;
}
// Test downcast!!!
- if( dynamic_cast<const SbxVariable*>( this) != nullptr )
- const_cast<SbxVariable*>(static_cast<const SbxVariable*>(this))->Broadcast( SfxHintId::BasicDataWanted );
+ if( auto pSbxVar = dynamic_cast<const SbxVariable*>( this) )
+ const_cast<SbxVariable*>(pSbxVar)->Broadcast( SfxHintId::BasicDataWanted );
SbxDataType t = GetType();
if( t == SbxSTRING )
{
diff --git a/cui/source/dialogs/zoom.cxx b/cui/source/dialogs/zoom.cxx
index b80080dfa352..54b40e55857f 100644
--- a/cui/source/dialogs/zoom.cxx
+++ b/cui/source/dialogs/zoom.cxx
@@ -187,12 +187,11 @@ SvxZoomDialog::SvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet)
const SfxPoolItem& rItem = m_rSet.Get(m_rSet.GetPool()->GetWhich(SID_ATTR_ZOOM));
- if (nullptr != dynamic_cast<const SvxZoomItem*>(&rItem))
+ if (auto pZoomItem = dynamic_cast<const SvxZoomItem*>(&rItem))
{
- const SvxZoomItem& rZoomItem = static_cast<const SvxZoomItem&>(rItem);
- const sal_uInt16 nZoom = rZoomItem.GetValue();
- const SvxZoomType eType = rZoomItem.GetType();
- const SvxZoomEnableFlags nValSet = rZoomItem.GetValueSet();
+ const sal_uInt16 nZoom = pZoomItem->GetValue();
+ const SvxZoomType eType = pZoomItem->GetType();
+ const SvxZoomEnableFlags nValSet = pZoomItem->GetValueSet();
ZoomButtonId nButtonId = ZoomButtonId::NONE;
switch (eType)
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index cbe881c35c59..b871247fa70d 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -155,9 +155,8 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
UpdateParagraphsWithStyleSheet( pStyle );
}
}
- else if ( dynamic_cast< const SfxStyleSheet* >(&rBC) != nullptr )
+ else if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) )
{
- SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>(&rBC);
SfxHintId nId = rHint.GetId();
if ( nId == SfxHintId::Dying )
{
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 02c8ce67068a..786c538e18ea 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -778,12 +778,13 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
case PPT_PST_RecolorInfoAtom :
{
- if ( dynamic_cast<const SdrGrafObj* >(pRet) != nullptr && static_cast<SdrGrafObj*>(pRet)->HasGDIMetaFile() )
- {
- Graphic aGraphic( static_cast<SdrGrafObj*>(pRet)->GetGraphic() );
- RecolorGraphic( rSt, aClientDataHd.nRecLen, aGraphic );
- static_cast<SdrGrafObj*>(pRet)->SetGraphic( aGraphic );
- }
+ if ( auto pSdrGrafObj = dynamic_cast<const SdrGrafObj* >(pRet) )
+ if ( pSdrGrafObj->HasGDIMetaFile() )
+ {
+ Graphic aGraphic( pSdrGrafObj->GetGraphic() );
+ RecolorGraphic( rSt, aClientDataHd.nRecLen, aGraphic );
+ static_cast<SdrGrafObj*>(pRet)->SetGraphic( aGraphic );
+ }
}
break;
}
@@ -7103,9 +7104,8 @@ PPTTextObj& PPTTextObj::operator=( PPTTextObj& rTextObj )
static bool IsLine( const SdrObject* pObj )
{
- return dynamic_cast< const SdrPathObj* >(pObj) != nullptr &&
- static_cast<const SdrPathObj*>(pObj)->IsLine() &&
- static_cast<const SdrPathObj*>(pObj)->GetPointCount() == 2;
+ auto pSdrPathObj = dynamic_cast< const SdrPathObj* >(pObj);
+ return pSdrPathObj && pSdrPathObj->IsLine() && pSdrPathObj->GetPointCount() == 2;
}
static bool GetCellPosition( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns,
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index 940250a6fc63..718354514e91 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -383,61 +383,61 @@ namespace
{
vcl::Font aNewFont( _rOriginalFont );
const SfxPoolItem* pItem( nullptr );
- if ( SfxItemState::SET == _rItemSet.GetItemState( _nFont,true,&pItem) && dynamic_cast< const SvxFontItem *>( pItem ) != nullptr)
- {
- const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
- aNewFont.SetFamilyName(pFontItem->GetFamilyName());
- aNewFont.SetStyleName(pFontItem->GetStyleName());
- aNewFont.SetFamily(pFontItem->GetFamily());
- aNewFont.SetPitch(pFontItem->GetPitch());
- aNewFont.SetCharSet(pFontItem->GetCharSet());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( _nFontHeight,true,&pItem) && dynamic_cast< const SvxFontHeightItem *>( pItem ) != nullptr)
- {
- const SvxFontHeightItem* pFontItem = static_cast<const SvxFontHeightItem*>(pItem);
- aNewFont.SetFontHeight(OutputDevice::LogicToLogic(Size(0, pFontItem->GetHeight()), MapMode(MapUnit::MapTwip), MapMode(MapUnit::MapPoint)).Height());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( _nPosture,true,&pItem) && dynamic_cast< const SvxPostureItem *>( pItem ) != nullptr)
- {
- const SvxPostureItem* pFontItem = static_cast<const SvxPostureItem*>(pItem);
- aNewFont.SetItalic(pFontItem->GetPosture());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( _nWeight,true,&pItem) && dynamic_cast< const SvxWeightItem *>( pItem ) != nullptr)
- {
- const SvxWeightItem* pFontItem = static_cast<const SvxWeightItem*>(pItem);
- aNewFont.SetWeight(pFontItem->GetWeight());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_WORDLINEMODE,true,&pItem) && dynamic_cast< const SvxWordLineModeItem *>( pItem ) != nullptr)
- {
- const SvxWordLineModeItem* pFontItem = static_cast<const SvxWordLineModeItem*>(pItem);
- aNewFont.SetWordLineMode(pFontItem->GetValue());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CROSSEDOUT,true,&pItem) && dynamic_cast< const SvxCrossedOutItem *>( pItem ) != nullptr)
- {
- const SvxCrossedOutItem* pFontItem = static_cast<const SvxCrossedOutItem*>(pItem);
- aNewFont.SetStrikeout(pFontItem->GetStrikeout());
- }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( _nFont,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxFontItem *>( pItem ) )
+ {
+ aNewFont.SetFamilyName(pFontItem->GetFamilyName());
+ aNewFont.SetStyleName(pFontItem->GetStyleName());
+ aNewFont.SetFamily(pFontItem->GetFamily());
+ aNewFont.SetPitch(pFontItem->GetPitch());
+ aNewFont.SetCharSet(pFontItem->GetCharSet());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( _nFontHeight,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxFontHeightItem *>( pItem ) )
+ {
+ aNewFont.SetFontHeight(OutputDevice::LogicToLogic(Size(0, pFontItem->GetHeight()), MapMode(MapUnit::MapTwip), MapMode(MapUnit::MapPoint)).Height());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( _nPosture,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxPostureItem *>( pItem ) )
+ {
+ aNewFont.SetItalic(pFontItem->GetPosture());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( _nWeight,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxWeightItem *>( pItem ) )
+ {
+ aNewFont.SetWeight(pFontItem->GetWeight());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_WORDLINEMODE,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxWordLineModeItem *>( pItem ) )
+ {
+ aNewFont.SetWordLineMode(pFontItem->GetValue());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CROSSEDOUT,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxCrossedOutItem *>( pItem ) )
+ {
+ aNewFont.SetStrikeout(pFontItem->GetStrikeout());
+ }
- if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARROTATE,true,&pItem) && dynamic_cast< const SvxCharRotateItem *>( pItem ) != nullptr)
- {
- const SvxCharRotateItem* pRotateItem = static_cast<const SvxCharRotateItem*>(pItem);
- aNewFont.SetOrientation(pRotateItem->GetValue());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARSCALE_W,true,&pItem) && dynamic_cast< const SvxCharScaleWidthItem *>( pItem ) != nullptr)
- {
- const SvxCharScaleWidthItem* pCharItem = static_cast<const SvxCharScaleWidthItem*>(pItem);
- aNewFont.SetWidthType(vcl::unohelper::ConvertFontWidth(pCharItem->GetValue()));
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,true,&pItem) && dynamic_cast< const SvxUnderlineItem *>( pItem ) != nullptr)
- {
- const SvxUnderlineItem* pFontItem = static_cast<const SvxUnderlineItem*>(pItem);
- aNewFont.SetUnderline(pFontItem->GetLineStyle());
- }
- if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_COLOR,true,&pItem) && dynamic_cast< const SvxColorItem *>( pItem ) != nullptr)
- {
- const SvxColorItem* pFontItem = static_cast<const SvxColorItem*>(pItem);
- aNewFont.SetColor(pFontItem->GetValue());
- }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARROTATE,true,&pItem) )
+ if ( auto pRotateItem = dynamic_cast< const SvxCharRotateItem *>( pItem ) )
+ {
+ aNewFont.SetOrientation(pRotateItem->GetValue());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARSCALE_W,true,&pItem) )
+ if ( auto pCharItem = dynamic_cast< const SvxCharScaleWidthItem *>( pItem ) )
+ {
+ aNewFont.SetWidthType(vcl::unohelper::ConvertFontWidth(pCharItem->GetValue()));
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxUnderlineItem *>( pItem ) )
+ {
+ aNewFont.SetUnderline(pFontItem->GetLineStyle());
+ }
+ if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_COLOR,true,&pItem) )
+ if ( auto pFontItem = dynamic_cast< const SvxColorItem *>( pItem ) )
+ {
+ aNewFont.SetColor(pFontItem->GetValue());
+ }
_out_rAwtFont = VCLUnoHelper::CreateFontDescriptor( aNewFont );
}
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 813345b5e46d..823f4337836f 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -758,14 +758,14 @@ void ScDetectiveFunc::DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nR
SdrObject* pObject = aIter.Next();
while (pObject)
{
- if ( pObject->GetLayer() == SC_LAYER_INTERN &&
- dynamic_cast< const SdrRectObj* >(pObject) != nullptr )
- {
- aObjRect = static_cast<SdrRectObj*>(pObject)->GetLogicRect();
- aObjRect.Justify();
- if ( RectIsPoints( aObjRect, aStartCorner, aEndCorner ) )
- ppObj[nDelCount++] = pObject;
- }
+ if ( pObject->GetLayer() == SC_LAYER_INTERN )
+ if ( auto pSdrRectObj = dynamic_cast< const SdrRectObj* >(pObject) )
+ {
+ aObjRect = pSdrRectObj->GetLogicRect();
+ aObjRect.Justify();
+ if ( RectIsPoints( aObjRect, aStartCorner, aEndCorner ) )
+ ppObj[nDelCount++] = pObject;
+ }
pObject = aIter.Next();
}
@@ -1268,13 +1268,13 @@ bool ScDetectiveFunc::DeleteCirclesAt( SCCOL nCol, SCROW nRow )
SdrObject* pObject = aIter.Next();
while (pObject)
{
- if (pObject->GetLayer() == SC_LAYER_INTERN
- && dynamic_cast<const SdrCircObj*>(pObject) != nullptr)
- {
- tools::Rectangle aObjRect = static_cast<SdrCircObj*>(pObject)->GetLogicRect();
- if (RectIsPoints(aObjRect, aStartCorner, aEndCorner))
- ppObj[nDelCount++] = pObject;
- }
+ if (pObject->GetLayer() == SC_LAYER_INTERN)
+ if (auto pSdrCircObj = dynamic_cast<const SdrCircObj*>(pObject) )
+ {
+ tools::Rectangle aObjRect = pSdrCircObj->GetLogicRect();
+ if (RectIsPoints(aObjRect, aStartCorner, aEndCorner))
+ ppObj[nDelCount++] = pObject;
+ }
pObject = aIter.Next();
}
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index a4cf3d25e241..1efcd4091702 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1435,9 +1435,8 @@ IMPL_LINK( ScAccessibleDocument, WindowChildEventListener, VclWindowEvent&, rEve
void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if (dynamic_cast<const ScAccGridWinFocusLostHint*>(&rHint) )
+ if (auto pFocusLostHint = dynamic_cast<const ScAccGridWinFocusLostHint*>(&rHint) )
{
- const ScAccGridWinFocusLostHint* pFocusLostHint = static_cast<const ScAccGridWinFocusLostHint *>(&rHint);
if (pFocusLostHint->GetOldGridWin() == meSplitPos)
{
if (mxTempAcc.is() && mpTempAccEdit)
@@ -1448,9 +1447,8 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
CommitFocusLost();
}
}
- else if (dynamic_cast<const ScAccGridWinFocusGotHint*>(&rHint) )
+ else if (auto pFocusGotHint = dynamic_cast<const ScAccGridWinFocusGotHint*>(&rHint) )
{
- const ScAccGridWinFocusGotHint* pFocusGotHint = static_cast<const ScAccGridWinFocusGotHint*>(&rHint);
if (pFocusGotHint->GetNewGridWin() == meSplitPos)
{
uno::Reference<XAccessible> xAccessible;
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 62bcc1a6446b..9dc99edf72be 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -2282,9 +2282,9 @@ void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
return;
// Does the list of range names need updating?
- if ( dynamic_cast<const SfxEventHint*>(&rHint) )
+ if ( auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
{
- SfxEventHintId nEventId = static_cast<const SfxEventHint*>(&rHint)->GetEventId();
+ SfxEventHintId nEventId = pEventHint->GetEventId();
if ( nEventId == SfxEventHintId::ActivateDoc )
FillRangeNames();
}
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 35212b04a138..3115b27126c1 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -196,9 +196,8 @@ void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, Configura
SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
while ( pObjSh )
{
- if ( dynamic_cast<const ScDocShell * >(pObjSh) != nullptr )
+ if ( auto pDocSh = dynamic_cast<ScDocShell * >(pObjSh) )
{
- ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
if ( bArrows )
ScDetectiveFunc( pDocSh->GetDocument(), 0 ).UpdateAllArrowColors();
if ( bComments )
@@ -239,9 +238,8 @@ void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, Configura
SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
while ( pObjSh )
{
- if ( dynamic_cast<const ScDocShell *>(pObjSh) != nullptr )
+ if ( auto pDocSh = dynamic_cast<ScDocShell *>(pObjSh) )
{
- ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
OutputDevice* pPrinter = pDocSh->GetPrinter();
if ( pPrinter )
pPrinter->SetDigitLanguage( GetOptDigitLanguage() );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 809f44de340f..0d7345e29fcc 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -667,9 +667,9 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
}
- if ( dynamic_cast<const SfxStyleSheetHint*>(&rHint) ) // Template changed
- NotifyStyle( static_cast<const SfxStyleSheetHint&>(rHint) );
- else if ( dynamic_cast<const ScAutoStyleHint*>(&rHint) )
+ if ( auto pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint) ) // Template changed
+ NotifyStyle( *pStyleSheetHint );
+ else if ( auto pStlHint = dynamic_cast<const ScAutoStyleHint*>(&rHint) )
{
//! direct call for AutoStyles
@@ -677,19 +677,18 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
// modifying the document must be asynchronous
// (handled by AddInitial)
- const ScAutoStyleHint& rStlHint = static_cast<const ScAutoStyleHint&>(rHint);
- const ScRange& aRange = rStlHint.GetRange();
- const OUString& aName1 = rStlHint.GetStyle1();
- const OUString& aName2 = rStlHint.GetStyle2();
- sal_uInt32 nTimeout = rStlHint.GetTimeout();
+ const ScRange& aRange = pStlHint->GetRange();
+ const OUString& aName1 = pStlHint->GetStyle1();
+ const OUString& aName2 = pStlHint->GetStyle2();
+ sal_uInt32 nTimeout = pStlHint->GetTimeout();
if (!m_pAutoStyleList)
m_pAutoStyleList.reset( new ScAutoStyleList(this) );
m_pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
}
- else if ( dynamic_cast<const SfxEventHint*>(&rHint) )
+ else if ( auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
{
- SfxEventHintId nEventId = static_cast<const SfxEventHint*>(&rHint)->GetEventId();
+ SfxEventHintId nEventId = pEventHint->GetEventId();
switch ( nEventId )
{
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 11beaa2819b7..d8ed50e85f3f 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -2591,10 +2591,10 @@ ScDocShell* ScDocShell::GetShellByNum( sal_uInt16 nDocNo ) // static
while ( pShell && !pFound )
{
- if ( dynamic_cast<const ScDocShell*>(pShell) != nullptr )
+ if ( auto pDocSh = dynamic_cast<ScDocShell*>(pShell) )
{
if ( nShellCnt == nDocNo )
- pFound = static_cast<ScDocShell*>(pShell);
+ pFound = pDocSh;
else
++nShellCnt;
}
diff --git a/sc/source/ui/drawfunc/fuconrec.cxx b/sc/source/ui/drawfunc/fuconrec.cxx
index 1f33472a6bfe..cc0aaa0f8058 100644
--- a/sc/source/ui/drawfunc/fuconrec.cxx
+++ b/sc/source/ui/drawfunc/fuconrec.cxx
@@ -136,8 +136,8 @@ bool FuConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
// create OutlinerParaObject now so it can be set to vertical
- if ( dynamic_cast<const SdrTextObj*>( pObj) != nullptr )
- static_cast<SdrTextObj*>(pObj)->ForceOutlinerParaObject();
+ if ( auto pSdrTextObj = dynamic_cast<SdrTextObj*>( pObj) )
+ pSdrTextObj->ForceOutlinerParaObject();
OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
if( pOPO && !pOPO->IsVertical() )
pOPO->SetVertical( true );
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 3c4b952e81c9..1b12103737c8 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -940,8 +940,8 @@ void ScContentTree::GetLinkNames()
for (sal_uInt16 i=0; i<nCount; i++)
{
::sfx2::SvBaseLink* pBase = rLinks[i].get();
- if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr)
- InsertContent( ScContentId::AREALINK, static_cast<ScAreaLink*>(pBase)->GetSource() );
+ if (auto pScAreaLink = dynamic_cast<const ScAreaLink*>( pBase))
+ InsertContent( ScContentId::AREALINK, pScAreaLink->GetSource() );
// insert in list the names of source areas
}
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index 4de4c93ff554..e551a614f54a 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -51,10 +51,10 @@ static void lcl_GetFieldData( ScHeaderFieldData& rData )
SfxViewShell* pShell = SfxViewShell::Current();
if (pShell)
{
- if (dynamic_cast<const ScTabViewShell*>( pShell) != nullptr)
- static_cast<ScTabViewShell*>(pShell)->FillFieldData(rData);
- else if (dynamic_cast<const ScPreviewShell*>( pShell) != nullptr)
- static_cast<ScPreviewShell*>(pShell)->FillFieldData(rData);
+ if (auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pShell))
+ pTabViewShell->FillFieldData(rData);
+ else if (auto pPreviewShell = dynamic_cast<ScPreviewShell*>( pShell))
+ pPreviewShell->FillFieldData(rData);
}
}
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index 355da408d885..c0a30276b251 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -51,8 +51,8 @@ void SwViewShellImp::StartAction()
if ( HasDrawView() )
{
CurrShell aCurr( GetShell() );
- if ( dynamic_cast<const SwFEShell*>( m_pShell) != nullptr )
- static_cast<SwFEShell*>(m_pShell)->HideChainMarker(); // might have changed
+ if ( auto pFEShell = dynamic_cast<SwFEShell*>( m_pShell) )
+ pFEShell->HideChainMarker(); // might have changed
}
}
@@ -61,8 +61,8 @@ void SwViewShellImp::EndAction()
if ( HasDrawView() )
{
CurrShell aCurr( GetShell() );
- if ( dynamic_cast<const SwFEShell*>(m_pShell) != nullptr )
- static_cast<SwFEShell*>(m_pShell)->SetChainMarker(); // might have changed
+ if ( auto pFEShell = dynamic_cast<SwFEShell*>(m_pShell) )
+ pFEShell->SetChainMarker(); // might have changed
}
}
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 654c3a373590..59f4b809686b 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -641,16 +641,16 @@ void SwViewShell::UpdateFields(bool bCloseDB)
{
CurrShell aCurr( this );
- bool bCursor = dynamic_cast<const SwCursorShell*>( this ) != nullptr;
- if ( bCursor )
- static_cast<SwCursorShell*>(this)->StartAction();
+ auto pCursorShell = dynamic_cast<SwCursorShell*>( this );
+ if ( pCursorShell )
+ pCursorShell->StartAction();
else
StartAction();
GetDoc()->getIDocumentFieldsAccess().UpdateFields(bCloseDB);
- if ( bCursor )
- static_cast<SwCursorShell*>(this)->EndAction();
+ if ( pCursorShell )
+ pCursorShell->EndAction();
else
EndAction();
}
@@ -716,14 +716,14 @@ void SwViewShell::LayoutIdle()
static void lcl_InvalidateAllContent( SwViewShell& rSh, SwInvalidateFlags nInv )
{
- bool bCursor = dynamic_cast<const SwCursorShell*>( &rSh) != nullptr;
- if ( bCursor )
- static_cast<SwCursorShell&>(rSh).StartAction();
+ auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh);
+ if ( pCursorShell )
+ pCursorShell->StartAction();
else
rSh.StartAction();
rSh.GetLayout()->InvalidateAllContent( nInv );
- if ( bCursor )
- static_cast<SwCursorShell&>(rSh).EndAction();
+ if ( pCursorShell )
+ pCursorShell->EndAction();
else
rSh.EndAction();
@@ -736,16 +736,16 @@ static void lcl_InvalidateAllContent( SwViewShell& rSh, SwInvalidateFlags nInv )
*/
static void lcl_InvalidateAllObjPos( SwViewShell &_rSh )
{
- const bool bIsCursorShell = dynamic_cast<const SwCursorShell*>( &_rSh) != nullptr;
- if ( bIsCursorShell )
- static_cast<SwCursorShell&>(_rSh).StartAction();
+ auto pCursorShell = dynamic_cast<SwCursorShell*>( &_rSh);
+ if ( pCursorShell )
+ pCursorShell->StartAction();
else
_rSh.StartAction();
_rSh.GetLayout()->InvalidateAllObjPos();
- if ( bIsCursorShell )
- static_cast<SwCursorShell&>(_rSh).EndAction();
+ if ( pCursorShell )
+ pCursorShell->EndAction();
else
_rSh.EndAction();
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index d7bbb52ac908..d5cd46f5e3db 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2617,8 +2617,8 @@ SwViewShell *SwHTMLParser::CallStartAction( SwViewShell *pVSh, bool bChkPtr )
if( m_pActionViewShell )
{
- if( dynamic_cast< const SwEditShell *>( m_pActionViewShell ) != nullptr )
- static_cast<SwEditShell*>(m_pActionViewShell)->StartAction();
+ if( auto pEditShell = dynamic_cast< SwEditShell *>( m_pActionViewShell ) )
+ pEditShell->StartAction();
else
m_pActionViewShell->StartAction();
}
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 6b61fd14e519..0c04d094e505 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1579,9 +1579,8 @@ SvxFrameDirection MSWordExportBase::GetDefaultFrameDirection( ) const
{
nDir = TrueFrameDirection( *static_cast< const SwFrameFormat * >(m_pOutFormatNode) );
}
- else if ( dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) != nullptr ) //paragraph
+ else if ( auto pNd = dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) ) //paragraph
{
- const SwContentNode *pNd = static_cast<const SwContentNode *>(m_pOutFormatNode);
SwPosition aPos( *pNd );
nDir = m_rDoc.GetTextDirection( aPos );
}
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index e0600d4cb33d..73d31b68245b 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -401,9 +401,8 @@ void WW8Export::OutGrf(const ww8::Frame &rFrame)
bool bVert = false;
//The default for word in vertical text mode is to center,
//otherwise a sub/super script hack is employed
- if (dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) )
+ if (auto pTextNd = dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) )
{
- const SwTextNode* pTextNd = static_cast<const SwTextNode*>(m_pOutFormatNode);
SwPosition aPos(*pTextNd);
bVert = m_rDoc.IsInVerticalText(aPos);
}
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index d6b0fabe8701..068601af0637 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3637,9 +3637,8 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
nNumId = 0;
}
}
- else if ( dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) != nullptr )
+ else if ( auto pC = dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) )
{
- const SwTextFormatColl* pC = static_cast<const SwTextFormatColl*>(GetExport().m_pOutFormatNode);
if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() )
nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() );
}
@@ -3801,12 +3800,12 @@ void WW8AttributeOutput::TableRowEnd(sal_uInt32 nDepth)
void AttributeOutputBase::FormatPageDescription( const SwFormatPageDesc& rPageDesc )
{
- if ( GetExport().m_bStyDef && dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) )
- {
- const SwTextFormatColl* pC = static_cast<const SwTextFormatColl*>(GetExport().m_pOutFormatNode);
- if ( (SfxItemState::SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.KnowsPageDesc() )
- FormatBreak( SvxFormatBreakItem( SvxBreak::PageBefore, RES_BREAK ) );
- }
+ if ( GetExport().m_bStyDef )
+ if (auto pC = dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) )
+ {
+ if ( (SfxItemState::SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.KnowsPageDesc() )
+ FormatBreak( SvxFormatBreakItem( SvxBreak::PageBefore, RES_BREAK ) );
+ }
}
void WW8AttributeOutput::PageBreakBefore( bool bBreak )
@@ -4803,15 +4802,13 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
if (m_rWW8Export.m_pOutFormatNode)
{
SvxFrameDirection nDirection = SvxFrameDirection::Horizontal_LR_TB;
- if (dynamic_cast<const SwTextNode*>(m_rWW8Export.m_pOutFormatNode) != nullptr)
+ if (auto pTN = dynamic_cast<const SwTextNode*>(m_rWW8Export.m_pOutFormatNode))
{
- SwPosition aPos(*static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode));
+ SwPosition aPos(*pTN);
nDirection = m_rWW8Export.m_rDoc.GetTextDirection(aPos);
}
- else if (dynamic_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode) != nullptr)
+ else if (auto pC = dynamic_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode))
{
- const SwTextFormatColl* pC =
- static_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode);
const SvxFrameDirectionItem &rItem =
ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR);
nDirection = rItem.GetValue();
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index 58070eb13352..0ce6317b294e 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -632,9 +632,9 @@ SwWrtShell* SwSpellDialogChildWindow::GetWrtShell_Impl()
sal_uInt16 nShellIdx = 0;
SfxShell* pShell;
while(nullptr != (pShell = pDispatch->GetShell(nShellIdx++)))
- if(dynamic_cast< const SwView *>( pShell ) != nullptr)
+ if(auto pSwView = dynamic_cast< SwView *>( pShell ))
{
- pView = static_cast<SwView* >(pShell);
+ pView = pSwView;
break;
}
}
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index f2b7fe80669f..607d94c3e33f 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -288,9 +288,9 @@ SwSidebarItem* SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExisten
mbLayout = bFocus;
SwSidebarItem* pAnnotationItem = nullptr;
- if (dynamic_cast< const SwFormatField *>( pItem ) != nullptr)
+ if (auto pSwFormatField = dynamic_cast< SwFormatField *>( pItem ))
{
- mvPostItFields.push_back(std::make_unique<SwAnnotationItem>(static_cast<SwFormatField&>(*pItem), bFocus));
+ mvPostItFields.push_back(std::make_unique<SwAnnotationItem>(*pSwFormatField, bFocus));
pAnnotationItem = mvPostItFields.back().get();
}
OSL_ENSURE(dynamic_cast< const SwFormatField *>( pItem ) != nullptr,"Mgr::InsertItem: seems like new stuff was added");
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index ea103fa2bfac..08bc94f91ca1 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2348,8 +2348,8 @@ KEYINPUT_CHECKTABLE_INSDEL:
if(pObj)
{
EnterDrawTextMode(pObj->GetLogicRect().Center());
- if ( dynamic_cast< const SwDrawTextShell *>( m_rView.GetCurShell() ) != nullptr )
- static_cast<SwDrawTextShell*>(m_rView.GetCurShell())->Init();
+ if ( auto pSwDrawTextShell = dynamic_cast< SwDrawTextShell *>( m_rView.GetCurShell() ) )
+ pSwDrawTextShell->Init();
rSh.GetDrawView()->KeyInput( rKEvt, this );
}
}
@@ -2393,8 +2393,8 @@ KEYINPUT_CHECKTABLE_INSDEL:
if(pObj)
{
EnterDrawTextMode(pObj->GetLogicRect().Center());
- if (dynamic_cast< const SwDrawTextShell *>( m_rView.GetCurShell() ) != nullptr )
- static_cast<SwDrawTextShell*>(m_rView.GetCurShell())->Init();
+ if (auto pSwDrawTextShell = dynamic_cast< SwDrawTextShell *>( m_rView.GetCurShell() ) )
+ pSwDrawTextShell->Init();
}
}
eKeyState = SwKeyState::End;
@@ -3356,8 +3356,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
case SelectionType::DrawObject:
RstMBDownFlags();
EnterDrawTextMode(aDocPos);
- if ( dynamic_cast< const SwDrawTextShell *>( m_rView.GetCurShell() ) != nullptr )
- static_cast<SwDrawTextShell*>(m_rView.GetCurShell())->Init();
+ if ( auto pSwDrawTextShell = dynamic_cast< SwDrawTextShell *>( m_rView.GetCurShell() ) )
+ pSwDrawTextShell->Init();
return;
default: break;
@@ -5090,8 +5090,8 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
if (SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj())
{
EnterDrawTextMode(pObj->GetLogicRect().Center());
- if ( dynamic_cast< const SwDrawTextShell *>( m_rView.GetCurShell() ) != nullptr )
- static_cast<SwDrawTextShell*>(m_rView.GetCurShell())->Init();
+ if ( auto pSwDrawTextShell = dynamic_cast< SwDrawTextShell *>( m_rView.GetCurShell() ) )
+ pSwDrawTextShell->Init();
}
}
}