From 5ba447bdcd13ba3d7c27c8609f207910227e4ab6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 7 Nov 2017 13:55:06 +0200 Subject: new loplugin simplifydynamiccast simplify dynamic_cast followed by static_cast Change-Id: I965afcf05d1675094cfde53d3590a0fd00f26279 Reviewed-on: https://gerrit.libreoffice.org/44460 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- svx/source/customshapes/EnhancedCustomShape3d.cxx | 4 ++-- svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 4 ++-- svx/source/engine3d/view3d.cxx | 8 ++++---- svx/source/stbctrls/pszctrl.cxx | 12 ++++++------ svx/source/stbctrls/xmlsecctrl.cxx | 4 ++-- svx/source/stbctrls/zoomctrl.cxx | 7 +++---- svx/source/svdraw/svdpagv.cxx | 4 ++-- 7 files changed, 21 insertions(+), 22 deletions(-) (limited to 'svx') diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx index 6d65bcc0ff63..9a048049c370 100644 --- a/svx/source/customshapes/EnhancedCustomShape3d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx @@ -377,7 +377,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con SfxItemSet aLocalSet(aSet); drawing::FillStyle aLocalFillStyle(eFillStyle); - if ( dynamic_cast( pNext) != nullptr ) + if ( auto pPathObj = dynamic_cast(pNext) ) { const SfxItemSet& rSet = pNext->GetMergedItemSet(); bool bNeedToConvertToContour(false); @@ -453,7 +453,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con } else { - aPolyPoly = static_cast(pNext)->GetPathPoly(); + aPolyPoly = pPathObj->GetPathPoly(); } } else diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index d4a6fc657fea..00100d8afad9 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -415,9 +415,9 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom basegfx::B2DPolyPolygon aPP; const SdrObject* pNext = aIter.Next(); - if ( dynamic_cast( pNext) != nullptr ) + if ( auto pPathObj = dynamic_cast(pNext) ) { - aPP = static_cast(pNext)->GetPathPoly(); + aPP = pPathObj->GetPathPoly(); } else { diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index d7edf4da5655..dd4396c91a56 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -418,9 +418,9 @@ SdrModel* E3dView::GetMarkedObjModel() const { const SdrObject* pSrcOb=pSrcPg->GetObj(nOb); - if(dynamic_cast< const E3dScene* >( pSrcOb) != nullptr) + if(auto p3dscene = dynamic_cast< const E3dScene* >( pSrcOb)) { - pScene = const_cast(static_cast(pSrcOb)); + pScene = const_cast(p3dscene); // delete all not intentionally cloned 3d objects pScene->removeAllNonSelectedObjects(); @@ -476,9 +476,9 @@ bool E3dView::Paste( for(size_t nOb = 0; nOb < nObjCount; ++nOb) { const SdrObject* pSrcOb = pSrcPg->GetObj(nOb); - if(dynamic_cast< const E3dScene* >(pSrcOb) != nullptr) + if(auto p3dscene = dynamic_cast< const E3dScene* >(pSrcOb)) { - E3dScene* pSrcScene = const_cast(static_cast(pSrcOb)); + E3dScene* pSrcScene = const_cast(p3dscene); ImpCloneAll3DObjectsToDestScene(pSrcScene, pDstScene, aDist); } } diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx index 1ad57366f88a..334670aabb11 100644 --- a/svx/source/stbctrls/pszctrl.cxx +++ b/svx/source/stbctrls/pszctrl.cxx @@ -299,24 +299,24 @@ void SvxPosSizeStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eSt SAL_WARN( "svx.stbcrtls","unknown slot id"); } } - else if ( dynamic_cast( pState) != nullptr ) + else if ( auto pPointItem = dynamic_cast( pState) ) { // show position - pImpl->aPos = static_cast(pState)->GetValue(); + pImpl->aPos = pPointItem->GetValue(); pImpl->bPos = true; pImpl->bTable = false; } - else if ( dynamic_cast( pState) != nullptr ) + else if ( auto pSizeItem = dynamic_cast( pState) ) { // show size - pImpl->aSize = static_cast(pState)->GetSize(); + pImpl->aSize = pSizeItem->GetSize(); pImpl->bSize = true; pImpl->bTable = false; } - else if ( dynamic_cast( pState) != nullptr ) + else if ( auto pStringItem = dynamic_cast( pState) ) { // show string (table cel or different) - pImpl->aStr = static_cast(pState)->GetValue(); + pImpl->aStr = pStringItem->GetValue(); pImpl->bTable = true; pImpl->bPos = false; pImpl->bSize = false; diff --git a/svx/source/stbctrls/xmlsecctrl.cxx b/svx/source/stbctrls/xmlsecctrl.cxx index 90e8b55fbe36..ae43e64dc405 100644 --- a/svx/source/stbctrls/xmlsecctrl.cxx +++ b/svx/source/stbctrls/xmlsecctrl.cxx @@ -71,9 +71,9 @@ void XmlSecStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, cons { mpImpl->mnState = SignatureState::UNKNOWN; } - else if( dynamic_cast< const SfxUInt16Item* >(pState) != nullptr ) + else if( auto pUint16Item = dynamic_cast< const SfxUInt16Item* >(pState) ) { - mpImpl->mnState = static_cast(static_cast(pState)->GetValue()); + mpImpl->mnState = static_cast(pUint16Item->GetValue()); } else { diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx index cf9b42cbc833..ed92af23be34 100644 --- a/svx/source/stbctrls/zoomctrl.cxx +++ b/svx/source/stbctrls/zoomctrl.cxx @@ -116,17 +116,16 @@ void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, GetStatusBar().SetItemText( GetId(), "" ); nValueSet = SvxZoomEnableFlags::NONE; } - else if ( dynamic_cast< const SfxUInt16Item* >(pState) != nullptr ) + else if ( auto pItem = dynamic_cast< const SfxUInt16Item* >(pState) ) { - const SfxUInt16Item* pItem = static_cast(pState); nZoom = pItem->GetValue(); OUString aStr(unicode::formatPercent(nZoom, Application::GetSettings().GetUILanguageTag())); GetStatusBar().SetItemText( GetId(), aStr ); - if ( dynamic_cast( pState) != nullptr ) + if ( auto pZoomItem = dynamic_cast(pState) ) { - nValueSet = static_cast(pState)->GetValueSet(); + nValueSet = pZoomItem->GetValueSet(); } else { diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 5f502bf1ed0d..ab837a7c58e6 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -642,11 +642,11 @@ bool SdrPageView::IsObjMarkable(SdrObject const * pObj) const return false; // only visible are selectable if (!pObj->IsInserted()) return false; // Obj deleted? - if (dynamic_cast(pObj) != nullptr) + if (auto pObjGroup = dynamic_cast(pObj)) { // If object is a Group object, visibility may depend on // multiple layers. If one object is markable, Group is markable. - SdrObjList* pObjList = static_cast(pObj)->GetSubList(); + SdrObjList* pObjList = pObjGroup->GetSubList(); if (pObjList && pObjList->GetObjCount()) { -- cgit