diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-23 21:37:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-24 07:10:29 +0100 |
commit | 5ca88c4a1a97b95c829f6c7c570c4e5219e80e2e (patch) | |
tree | 2c66640aafc90448d32908a7c40960a21e596122 /sd | |
parent | 356006712320c524515a959a022a0f2b02fa63bb (diff) |
static_cast after dynamic_cast
Change-Id: I196d4e9065961d6f4e3fef4475dd5f406e998447
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106451
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/GraphicObjectBar.cxx | 42 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 41 | ||||
-rw-r--r-- | sd/source/ui/view/drviews7.cxx | 7 | ||||
-rw-r--r-- | sd/source/ui/view/sdview2.cxx | 42 |
4 files changed, 68 insertions, 64 deletions
diff --git a/sd/source/ui/view/GraphicObjectBar.cxx b/sd/source/ui/view/GraphicObjectBar.cxx index cba43660e629..b3f9b1468b28 100644 --- a/sd/source/ui/view/GraphicObjectBar.cxx +++ b/sd/source/ui/view/GraphicObjectBar.cxx @@ -90,8 +90,9 @@ void GraphicObjectBar::GetFilterState( SfxItemSet& rSet ) { SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - if( dynamic_cast< SdrGrafObj *>( pObj ) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) ) - bEnable = true; + if( auto pGrafObj = dynamic_cast< SdrGrafObj *>( pObj ) ) + if( pGrafObj->GetGraphicType() == GraphicType::Bitmap ) + bEnable = true; } if( !bEnable ) @@ -106,28 +107,29 @@ void GraphicObjectBar::ExecuteFilter( SfxRequest const & rReq ) { SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - if( dynamic_cast< SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) - { - GraphicObject aFilterObj( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() ); - - if( SvxGraphicFilterResult::NONE == - SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) ) + if( auto pGrafObj = dynamic_cast< SdrGrafObj *>( pObj ) ) + if( pGrafObj->GetGraphicType() == GraphicType::Bitmap ) { - SdrPageView* pPageView = mpView->GetSdrPageView(); + GraphicObject aFilterObj( pGrafObj->GetGraphicObject() ); - if( pPageView ) + if( SvxGraphicFilterResult::NONE == + SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) ) { - SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) ); - OUString aStr = mpView->GetDescriptionOfMarkedObjects() + - " " + SdResId(STR_UNDO_GRAFFILTER); - mpView->BegUndo( aStr ); - pFilteredObj->SetGraphicObject( aFilterObj ); - ::sd::View* const pView = mpView; - pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); - pView->EndUndo(); - return; + SdrPageView* pPageView = mpView->GetSdrPageView(); + + if( pPageView ) + { + SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) ); + OUString aStr = mpView->GetDescriptionOfMarkedObjects() + + " " + SdResId(STR_UNDO_GRAFFILTER); + mpView->BegUndo( aStr ); + pFilteredObj->SetGraphicObject( aFilterObj ); + ::sd::View* const pView = mpView; + pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); + pView->EndUndo(); + return; + } } - } } } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 279eb753af57..30a334bfd6ec 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1425,14 +1425,15 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if( rMarkList.GetMarkCount() == 1 ) { SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - if( dynamic_cast< const SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) - { - GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() ); - m_ExternalEdits.push_back( - std::make_unique<SdrExternalToolEdit>( - mpDrawView.get(), pObj)); - m_ExternalEdits.back()->Edit( &aGraphicObject ); - } + if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj ) ) + if( pGraphicObj->GetGraphicType() == GraphicType::Bitmap ) + { + GraphicObject aGraphicObject( pGraphicObj->GetGraphicObject() ); + m_ExternalEdits.push_back( + std::make_unique<SdrExternalToolEdit>( + mpDrawView.get(), pObj)); + m_ExternalEdits.back()->Edit( &aGraphicObject ); + } } Cancel(); rReq.Ignore(); @@ -1446,20 +1447,20 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - if( dynamic_cast< const SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) - { - SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj); - CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() ); - if (dialog.run() == RET_OK) + if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj ) ) + if( pGraphicObj->GetGraphicType() == GraphicType::Bitmap ) { - SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj(); - SdrPageView* pPageView = mpDrawView->GetSdrPageView(); - OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects() + " Compress"; - mpDrawView->BegUndo( aUndoString ); - mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject ); - mpDrawView->EndUndo(); + CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() ); + if (dialog.run() == RET_OK) + { + SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj(); + SdrPageView* pPageView = mpDrawView->GetSdrPageView(); + OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects() + " Compress"; + mpDrawView->BegUndo( aUndoString ); + mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject ); + mpDrawView->EndUndo(); + } } - } } Cancel(); rReq.Ignore(); diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index baac52ee46e1..93c1bc846a26 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -352,10 +352,9 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) { bool bDisable = true; SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->getQrCode())) - { - bDisable = false; - } + if( auto pGrafObj = dynamic_cast<const SdrGrafObj*>( pObj) ) + if( pGrafObj->getQrCode() ) + bDisable = false; if(bDisable) { rSet.DisableItem(SID_EDIT_QRCODE); diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index e550a2291f87..7f5caafe6733 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -109,18 +109,19 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat { SdrObject* pObj = GetMarkedObjectByIndex(0); - if( dynamic_cast< const SdrOle2Obj *>( pObj ) && static_cast<SdrOle2Obj*>(pObj)->GetObjRef().is() ) - { - // If object has no persistence it must be copied as part of the document - try + if( auto pOle2Obj = dynamic_cast< const SdrOle2Obj *>( pObj ) ) + if( pOle2Obj->GetObjRef() ) { - uno::Reference< embed::XEmbedPersist > xPersObj( static_cast<SdrOle2Obj*>(pObj)->GetObjRef(), uno::UNO_QUERY ); - if ( xPersObj.is() && xPersObj->hasEntry() ) - pSdrOleObj = static_cast<SdrOle2Obj*>(pObj); + // If object has no persistence it must be copied as part of the document + try + { + uno::Reference< embed::XEmbedPersist > xPersObj( pOle2Obj->GetObjRef(), uno::UNO_QUERY ); + if ( xPersObj.is() && xPersObj->hasEntry() ) + pSdrOleObj = static_cast<SdrOle2Obj*>(pObj); + } + catch( uno::Exception& ) + {} } - catch( uno::Exception& ) - {} - } } if( pSdrOleObj ) @@ -155,18 +156,19 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje { SdrObject* pObj = GetMarkedObjectByIndex( 0 ); - if( dynamic_cast< const SdrOle2Obj *>( pObj ) && static_cast<SdrOle2Obj*>(pObj)->GetObjRef().is() ) - { - // If object has no persistence it must be copied as part of the document - try + if( auto pOle2Obj = dynamic_cast< const SdrOle2Obj *>( pObj ) ) + if( pOle2Obj->GetObjRef() ) { - uno::Reference< embed::XEmbedPersist > xPersObj( static_cast<SdrOle2Obj*>(pObj)->GetObjRef(), uno::UNO_QUERY ); - if ( xPersObj.is() && xPersObj->hasEntry() ) - pSdrOleObj = static_cast<SdrOle2Obj*>(pObj); + // If object has no persistence it must be copied as part of the document + try + { + uno::Reference< embed::XEmbedPersist > xPersObj( pOle2Obj->GetObjRef(), uno::UNO_QUERY ); + if ( xPersObj.is() && xPersObj->hasEntry() ) + pSdrOleObj = static_cast<SdrOle2Obj*>(pObj); + } + catch( uno::Exception& ) + {} } - catch( uno::Exception& ) - {} - } } if( mpDocSh ) |