diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-08 13:33:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-08 14:38:15 +0200 |
commit | 3afb514362a2ce2701628256fa96d4a5324433d6 (patch) | |
tree | 914e6c3b6a37f66543db8515b1031ae65a230b63 /svx | |
parent | 73c8bd42650dafc38c87b5e6dc1ef222d4f6175c (diff) |
simplify static_cast after dynamic_cast
Change-Id: I53ae7f18519fdd878730d1d0316ebc408271c66d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121811
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 9 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeHandle.cxx | 14 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap4.cxx | 6 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 5 |
4 files changed, 16 insertions, 18 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 86d2f9bfb00b..6f280f3d7304 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -195,14 +195,11 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce // get the text bounds and set at text object tools::Rectangle aTextBounds(rSdrObjCustomShape.GetSnapRect()); - const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape))); + auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxShape)); - if(bIsSdrObjCustomShape) + if(pSdrObjCustomShape) { - SdrObjCustomShape& rSdrObjCustomShape2( - static_cast< SdrObjCustomShape& >( - *SdrObject::getSdrObjectFromXShape(mxShape))); - EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape2); + EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); aTextBounds = aCustomShape2d.GetTextRect(); } diff --git a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx index 2a9fd1f19991..d2d5c8df6b5b 100644 --- a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx @@ -49,16 +49,15 @@ void SAL_CALL EnhancedCustomShapeHandle::release() noexcept // XCustomShapeHandle css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition() { - const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape))); + auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape)); - if(!bIsSdrObjCustomShape) + if(!pSdrObjCustomShape) { throw css::uno::RuntimeException(); } - SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*SdrObject::getSdrObjectFromXShape(mxCustomShape))); Point aPosition; - EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); + EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); if(!aCustomShape2d.GetHandlePosition(mnIndex, aPosition)) { @@ -70,15 +69,14 @@ css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition() void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt ) { - const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape))); + auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(SdrObject::getSdrObjectFromXShape(mxCustomShape)); - if(!bIsSdrObjCustomShape) + if(!pSdrObjCustomShape) { throw css::uno::RuntimeException(); } - SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*SdrObject::getSdrObjectFromXShape(mxCustomShape))); - EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); + EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape); if(!aCustomShape2d.SetHandleControllerPosition(mnIndex, aPnt)) { diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 9274a60a2e28..ea590892daaa 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -87,10 +87,12 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro // TODO/LATER: seems to make no sense for iconified object awt::Rectangle aVisArea; - if( (rValue >>= aVisArea) && dynamic_cast<const SdrOle2Obj* >(GetSdrObject()) != nullptr) + if( !(rValue >>= aVisArea)) + break; + if( auto pOle2Obj = dynamic_cast<SdrOle2Obj* >(GetSdrObject()) ) { Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height ); - uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef(); + uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef(); if( xObj.is() ) { try diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 46611422ff23..6445b81e06db 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -2693,8 +2693,9 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn case OWN_ATTR_MIRRORED: { bool bMirror = false; - if( HasSdrObject() && dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr ) - bMirror = static_cast<SdrGrafObj*>(GetSdrObject())->IsMirrored(); + if( HasSdrObject() ) + if (auto pGrafObj = dynamic_cast<SdrGrafObj*>(GetSdrObject()) ) + bMirror = pGrafObj->IsMirrored(); rValue <<= bMirror; break; |