diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-13 11:02:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-13 12:47:38 +0200 |
commit | 1374f5fdcbbd24b9ba614b378fd94f5ff95ad102 (patch) | |
tree | a47982a70463150dced3c7c1a7d13c669febd681 /sc | |
parent | 97b7b6030a6cf5b28ae0c1f61f7f55167b82dab6 (diff) |
static_cast after dynamic_cast
Change-Id: I53e10fbebfd07c471ddd9b264562317251700500
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104225
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/undo/undotab.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 27 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/unoobj/datauno.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/unoobj/linkuno.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/unoobj/notesuno.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheets.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/drawvie3.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/drawview.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 4 |
11 files changed, 72 insertions, 90 deletions
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index 16148d5e61a9..c3a9476d7804 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -213,9 +213,9 @@ void ScUndoMakeOutline::Redo() void ScUndoMakeOutline::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) { - ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell(); + ScTabViewShell& rViewShell = *pViewTarget->GetViewShell(); if (bMake) rViewShell.MakeOutline( bColumns ); @@ -303,8 +303,8 @@ void ScUndoOutlineLevel::Redo() void ScUndoOutlineLevel::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->SelectLevel( bColumns, nLevel ); + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->SelectLevel( bColumns, nLevel ); } bool ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget& rTarget) const @@ -400,9 +400,9 @@ void ScUndoOutlineBlock::Redo() void ScUndoOutlineBlock::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) { - ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell(); + ScTabViewShell& rViewShell = *pViewTarget->GetViewShell(); if (bShow) rViewShell.ShowMarkedOutlines(); @@ -493,8 +493,8 @@ void ScUndoRemoveAllOutlines::Redo() void ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->RemoveAllOutlines(); + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->RemoveAllOutlines(); } bool ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const @@ -590,8 +590,8 @@ void ScUndoAutoOutline::Redo() void ScUndoAutoOutline::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->AutoOutline(); + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->AutoOutline(); } bool ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const @@ -1217,9 +1217,9 @@ void ScUndoImportData::Redo() void ScUndoImportData::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) { - ScTabViewShell& rViewShell = *static_cast<ScTabViewTarget&>(rTarget).GetViewShell(); + ScTabViewShell& rViewShell = *pViewTarget->GetViewShell(); SCTAB nDummy; ScImportParam aNewParam(aImportParam); @@ -1393,8 +1393,8 @@ void ScUndoRepeatDB::Redo() void ScUndoRepeatDB::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->RepeatDB(); + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->RepeatDB(); } bool ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index f9956bded40c..4118b1bcbd5d 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -142,8 +142,8 @@ void ScUndoInsertTab::Redo() void ScUndoInsertTab::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher(). + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->GetViewData().GetDispatcher(). Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD); } @@ -236,8 +236,8 @@ void ScUndoInsertTables::Redo() void ScUndoInsertTables::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher(). + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->GetViewData().GetDispatcher(). Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD); } @@ -394,9 +394,9 @@ void ScUndoDeleteTab::Redo() void ScUndoDeleteTab::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) { - ScTabViewShell* pViewShell = static_cast<ScTabViewTarget&>(rTarget).GetViewShell(); + ScTabViewShell* pViewShell = pViewTarget->GetViewShell(); pViewShell->DeleteTable( pViewShell->GetViewData().GetTabNo() ); } } @@ -842,9 +842,9 @@ void ScUndoMakeScenario::Redo() void ScUndoMakeScenario::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) { - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->MakeScenario( aName, aComment, aColor, nFlags ); + pViewTarget->GetViewShell()->MakeScenario( aName, aComment, aColor, nFlags ); } } @@ -996,8 +996,8 @@ void ScUndoImportTab::Redo() void ScUndoImportTab::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher(). + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->GetViewData().GetDispatcher(). Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD); } @@ -1123,8 +1123,8 @@ void ScUndoShowHideTab::Redo() void ScUndoShowHideTab::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher(). + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->GetViewData().GetDispatcher(). Execute( bShow ? FID_TABLE_SHOW : FID_TABLE_HIDE, SfxCallMode::SLOT | SfxCallMode::RECORD); } @@ -1532,8 +1532,8 @@ void ScUndoLayoutRTL::Redo() void ScUndoLayoutRTL::Repeat(SfxRepeatTarget& rTarget) { - if (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr) - static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher(). + if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget)) + pViewTarget->GetViewShell()->GetViewData().GetDispatcher(). Execute( FID_TAB_RTL, SfxCallMode::SLOT | SfxCallMode::RECORD); } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index b60984d7b53b..8e5667800811 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1544,19 +1544,17 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint ) } return; } - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) ) { - const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint); - ScDocument& rDoc = pDocShell->GetDocument(); std::unique_ptr<ScRangeList> pUndoRanges; if ( rDoc.HasUnoRefUndo() ) pUndoRanges.reset(new ScRangeList( aRanges )); - if ( aRanges.UpdateReference( rRef.GetMode(), &rDoc, rRef.GetRange(), - rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) ) + if ( aRanges.UpdateReference( pRefHint->GetMode(), &rDoc, pRefHint->GetRange(), + pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ) ) { - if ( rRef.GetMode() == URM_INSDEL + if ( pRefHint->GetMode() == URM_INSDEL && aRanges.size() == 1 && comphelper::getUnoTunnelImplementation<ScTableSheetObj>(xThis) ) @@ -1578,14 +1576,13 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint ) rDoc.AddUnoRefChange( nObjectId, *pUndoRanges ); } } - else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) + else if ( auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) { - const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint); - if ( rUndoHint.GetObjectId() == nObjectId ) + if ( pUndoHint->GetObjectId() == nObjectId ) { // restore ranges from hint - aRanges = rUndoHint.GetRanges(); + aRanges = pUndoHint->GetRanges(); RefChanged(); if ( !aValueListeners.empty() ) @@ -7408,9 +7405,8 @@ void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aShee for ( sal_uInt16 i=0; i<nCount; i++ ) { ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get(); - if (dynamic_cast<const ScTableLink*>( pBase) != nullptr) + if (auto pTabLink = dynamic_cast<ScTableLink*>( pBase)) { - ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase); if ( aFileString == pTabLink->GetFileName() ) pTabLink->Update(); // include Paint&Undo @@ -8673,11 +8669,10 @@ ScCellsObj::~ScCellsObj() void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) ) { - const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint); - aRanges.UpdateReference( rRef.GetMode(), &pDocShell->GetDocument(), rRef.GetRange(), - rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ); + aRanges.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(), + pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ); } else if ( rHint.GetId() == SfxHintId::Dying ) { diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 2d3a61972efa..ffbcba6c234f 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2737,13 +2737,11 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint m_pDocument->AddUnoRefChange(m_nObjectId, *pUndoRanges); } } - else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) + else if ( auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) { - const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint); - do { - if (rUndoHint.GetObjectId() != m_nObjectId) + if (pUndoHint->GetObjectId() != m_nObjectId) break; // The hint object provides the old ranges. Restore the old state @@ -2755,7 +2753,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint break; } - const ScRangeList& rRanges = rUndoHint.GetRanges(); + const ScRangeList& rRanges = pUndoHint->GetRanges(); size_t nCount = rRanges.size(); if (nCount != m_pRangeIndices->size()) diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 677a6852fe2c..2f2bdae144a4 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1554,13 +1554,12 @@ void ScDatabaseRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) if ( rHint.GetId() == SfxHintId::Dying ) pDocShell = nullptr; - else if ( dynamic_cast<const ScDBRangeRefreshedHint*>(&rHint) ) + else if ( auto pRefreshHint = dynamic_cast<const ScDBRangeRefreshedHint*>(&rHint) ) { ScDBData* pDBData = GetDBData_Impl(); - const ScDBRangeRefreshedHint& rRef = static_cast<const ScDBRangeRefreshedHint&>(rHint); ScImportParam aParam; pDBData->GetImportParam(aParam); - if (aParam == rRef.GetImportParam()) + if (aParam == pRefreshHint->GetImportParam()) Refreshed_Impl(); } } diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 7dea06ff2a9b..46a0755d802b 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -93,10 +93,9 @@ void ScSheetLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) //! notify if links in document are changed // UpdateRef is not needed here - if ( dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) + if ( auto pRefreshHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) { - const ScLinkRefreshedHint& rLH = static_cast<const ScLinkRefreshedHint&>(rHint); - if ( rLH.GetLinkType() == ScLinkRefType::SHEET && rLH.GetUrl() == aFileName ) + if ( pRefreshHint->GetLinkType() == ScLinkRefType::SHEET && pRefreshHint->GetUrl() == aFileName ) Refreshed_Impl(); } else @@ -115,9 +114,8 @@ ScTableLink* ScSheetLinkObj::GetLink_Impl() const for (size_t i=0; i<nCount; i++) { ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get(); - if (dynamic_cast<const ScTableLink*>( pBase) != nullptr) + if (auto pTabLink = dynamic_cast<ScTableLink*>( pBase)) { - ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase); if ( pTabLink->GetFileName() == aFileName ) return pTabLink; } @@ -560,10 +558,10 @@ static ScAreaLink* lcl_GetAreaLink( ScDocShell* pDocShell, size_t nPos ) for (size_t i=0; i<nTotalCount; i++) { ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get(); - if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr) + if (auto pAreaLink = dynamic_cast<ScAreaLink*>( pBase)) { if ( nAreaCount == nPos ) - return static_cast<ScAreaLink*>(pBase); + return pAreaLink; ++nAreaCount; } } @@ -592,14 +590,13 @@ void ScAreaLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) //! notify if links in document are changed // UpdateRef is not needed here - if ( dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) + if ( auto pRefreshedHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) { - const ScLinkRefreshedHint& rLH = static_cast<const ScLinkRefreshedHint&>(rHint); - if ( rLH.GetLinkType() == ScLinkRefType::AREA ) + if ( pRefreshedHint->GetLinkType() == ScLinkRefType::AREA ) { // get this link to compare dest position ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos); - if ( pLink && pLink->GetDestArea().aStart == rLH.GetDestPos() ) + if ( pLink && pLink->GetDestArea().aStart == pRefreshedHint->GetDestPos() ) Refreshed_Impl(); } } @@ -1014,13 +1011,12 @@ void ScDDELinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) //! notify if links in document are changed // UpdateRef is not needed here - if ( dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) + if ( auto pRefreshedHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) { - const ScLinkRefreshedHint& rLH = static_cast<const ScLinkRefreshedHint&>(rHint); - if ( rLH.GetLinkType() == ScLinkRefType::DDE && - rLH.GetDdeAppl() == aAppl && - rLH.GetDdeTopic() == aTopic && - rLH.GetDdeItem() == aItem ) //! mode is ignored + if ( pRefreshedHint->GetLinkType() == ScLinkRefType::DDE && + pRefreshedHint->GetDdeAppl() == aAppl && + pRefreshedHint->GetDdeTopic() == aTopic && + pRefreshedHint->GetDdeItem() == aItem ) //! mode is ignored Refreshed_Impl(); } else diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx index e43fec8eb86b..8929192825b6 100644 --- a/sc/source/ui/unoobj/notesuno.cxx +++ b/sc/source/ui/unoobj/notesuno.cxx @@ -75,13 +75,7 @@ ScAnnotationObj::~ScAnnotationObj() void ScAnnotationObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) - { -// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; - - //! Ref-Update - } - else if ( rHint.GetId() == SfxHintId::Dying ) + if ( rHint.GetId() == SfxHintId::Dying ) { pDocShell = nullptr; // became invalid } diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index fbef67a68e32..616440ac0daa 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -500,10 +500,10 @@ void ScVbaWorksheets::PrintPreview( const css::uno::Any& /*EnableChanges*/ ) dispatchExecute( pViewShell, SID_VIEWSHELL1 ); SfxViewShell* pShell = SfxViewShell::Get( pViewFrame->GetFrame().GetFrameInterface()->getController() ); - if ( dynamic_cast<const ScPreviewShell*>( pShell) == nullptr ) + ScPreviewShell* pPrvShell = dynamic_cast< ScPreviewShell* >( pShell ); + if ( !pPrvShell ) return; - ScPreviewShell* pPrvShell = static_cast< ScPreviewShell* >( pShell ); ScPreview* pPrvView = pPrvShell->GetPreview(); const ScDocument& rDoc = pViewShell->GetViewData().GetDocument(); ScMarkData aMarkData(rDoc.GetSheetLimits()); diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx index b8e9623fe172..2305083b4739 100644 --- a/sc/source/ui/view/drawvie3.cxx +++ b/sc/source/ui/view/drawvie3.cxx @@ -180,9 +180,9 @@ void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) adjustAnchoredPosition(*pSdrHint, rDoc, nTab); FmFormView::Notify( rBC,rHint ); } - else if (dynamic_cast<const ScTabDeletedHint*>(&rHint)) // Sheet has been deleted + else if (auto pDeletedHint = dynamic_cast<const ScTabDeletedHint*>(&rHint)) // Sheet has been deleted { - SCTAB nDelTab = static_cast<const ScTabDeletedHint&>(rHint).GetTab(); + SCTAB nDelTab = pDeletedHint->GetTab(); if (ValidTab(nDelTab)) { // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here @@ -190,9 +190,9 @@ void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) HideSdrPage(); } } - else if (dynamic_cast<const ScTabSizeChangedHint*>(&rHint)) // Size has been changed + else if (auto pChangedHint = dynamic_cast<const ScTabSizeChangedHint*>(&rHint)) // Size has been changed { - if ( nTab == static_cast<const ScTabSizeChangedHint&>(rHint).GetTab() ) + if ( nTab == pChangedHint->GetTab() ) UpdateWorkArea(); } else @@ -217,8 +217,8 @@ void ScDrawView::UpdateIMap( SdrObject* pObj ) SfxViewFrame::GetTargetList( aTargetList ); // handle graphics from object - if ( dynamic_cast<const SdrGrafObj*>( pObj) != nullptr ) - aGraphic = static_cast<SdrGrafObj*>(pObj)->GetGraphic(); + if ( auto pGrafObj = dynamic_cast<SdrGrafObj*>( pObj) ) + aGraphic = pGrafObj->GetGraphic(); else { const Graphic* pGraphic = static_cast<const SdrOle2Obj*>(pObj)->GetGraphic(); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 029220816f25..50d8f32334b1 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -434,9 +434,9 @@ void ScDrawView::MarkListHasChanged() for (size_t i=0; i<nMarkCount; ++i) { SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); - if ( dynamic_cast<const SdrObjGroup*>( pObj) != nullptr ) + if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) ) { - const SdrObjList *pLst = static_cast<SdrObjGroup*>(pObj)->GetSubList(); + const SdrObjList *pLst = pObjGroup->GetSubList(); const size_t nListCount = pLst->GetObjCount(); if ( nListCount == 0 ) { @@ -923,9 +923,9 @@ void ScDrawView::MarkDropObj( SdrObject* pObj ) void ScDrawView::SyncForGrid( SdrObject* pObj ) { // process members of a group shape separately - if ( dynamic_cast<const SdrObjGroup*>( pObj) != nullptr ) + if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) ) { - SdrObjList *pLst = static_cast<SdrObjGroup*>(pObj)->GetSubList(); + SdrObjList *pLst = pObjGroup->GetSubList(); for ( size_t i = 0, nCount = pLst->GetObjCount(); i < nCount; ++i ) SyncForGrid( pLst->GetObj( i ) ); } diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index a27339a914ef..4d61b2e06fec 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -512,9 +512,9 @@ static sal_uInt16 lcl_DocShellNr( const ScDocument& rDoc ) SfxObjectShell* pShell = SfxObjectShell::GetFirst(); while ( pShell ) { - if ( dynamic_cast<const ScDocShell *>(pShell) != nullptr ) + if ( auto pDocShell = dynamic_cast<const ScDocShell *>(pShell) ) { - if ( &static_cast<ScDocShell*>(pShell)->GetDocument() == &rDoc ) + if ( &pDocShell->GetDocument() == &rDoc ) return nShellCnt; ++nShellCnt; |