summaryrefslogtreecommitdiff
path: root/sc
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 /sc
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>
Diffstat (limited to 'sc')
-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
9 files changed, 40 insertions, 45 deletions
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);
}
}