diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-12-27 11:02:51 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-12-27 08:56:55 +0100 |
commit | 5d2141e7004275ed08dc1a8f37bdadd73eca276e (patch) | |
tree | 434850297c5da58d0e2fe78025b17edaaea700a9 | |
parent | 03b9b00ae7ca132244fc669186e6577bd776c738 (diff) |
escherex: dynamic_cast followed by static_cast
Change-Id: I551dd671d9ee61a79b4c69f8d593aea2a7e517c6
Reviewed-on: https://gerrit.libreoffice.org/47076
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index cdc634d66647..fc74cf75490f 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -1245,13 +1245,15 @@ bool EscherPropertyContainer::CreateOLEGraphicProperties(const uno::Reference<dr if ( rXShape.is() ) { - SdrObject* pSdrOLE2( GetSdrObjectFromXShape( rXShape ) ); // SJ: leaving unoapi, because currently there is - if ( pSdrOLE2 && nullptr != dynamic_cast<const SdrOle2Obj* > (pSdrOLE2) ) // no access to the native graphic object + SdrObject* pObject = GetSdrObjectFromXShape(rXShape); // SJ: leaving unoapi, because currently there is + const SdrOle2Obj* pOle2Obj = pObject == nullptr ? nullptr : dynamic_cast<const SdrOle2Obj*>(pObject); + if (pOle2Obj != nullptr) // no access to the native graphic object { - const Graphic* pGraphic = static_cast<SdrOle2Obj*>(pSdrOLE2)->GetGraphic(); - if ( pGraphic ) + const Graphic* pGraphic = pOle2Obj->GetGraphic(); + if (pGraphic) { - std::unique_ptr<GraphicObject> xGraphicObject(new GraphicObject(*pGraphic)); + Graphic aGraphic(*pGraphic); + std::unique_ptr<GraphicObject> xGraphicObject(new GraphicObject(aGraphic)); bRetValue = CreateGraphicProperties(rXShape, *xGraphicObject); } } @@ -1294,10 +1296,11 @@ bool EscherPropertyContainer::CreateMediaGraphicProperties(const uno::Reference< bool bRetValue = false; if ( rXShape.is() ) { - SdrObject* pSdrMedia( GetSdrObjectFromXShape( rXShape ) ); // SJ: leaving unoapi, because currently there is - if ( dynamic_cast<const SdrMediaObj* >(pSdrMedia) != nullptr ) // no access to the native graphic object + SdrObject* pSdrObject(GetSdrObjectFromXShape(rXShape)); // SJ: leaving unoapi, because currently there is + auto* pSdrMediaObj = dynamic_cast<const SdrMediaObj*>(pSdrObject); + if (pSdrMediaObj != nullptr) // no access to the native graphic object { - std::unique_ptr<GraphicObject> xGraphicObject(new GraphicObject(static_cast<SdrMediaObj*>(pSdrMedia)->getSnapshot())); + std::unique_ptr<GraphicObject> xGraphicObject(new GraphicObject(pSdrMediaObj->getSnapshot())); bRetValue = CreateGraphicProperties(rXShape, *xGraphicObject); } } @@ -4561,8 +4564,8 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) if (aType == "drawing.Custom") { - SdrObject* pCustoShape( GetSdrObjectFromXShape( aXShape ) ); - if ( dynamic_cast<const SdrObjCustomShape* >(pCustoShape) != nullptr ) + SdrObject* pCustoShape(GetSdrObjectFromXShape(aXShape)); + if (dynamic_cast<const SdrObjCustomShape*>(pCustoShape) != nullptr) { const SdrCustomShapeGeometryItem& rGeometryItem = pCustoShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); @@ -4606,15 +4609,16 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) } else if ( nGluePointType == drawing::EnhancedCustomShapeGluePointType::SEGMENTS ) { - SdrObject* pPoly = pCustoShape->DoConvertToPolyObj( true, true ); - if ( dynamic_cast<const SdrPathObj* >( pPoly ) != nullptr ) + SdrObject* pObject = pCustoShape->DoConvertToPolyObj(true, true); + const SdrPathObj* pSdrPathObj = dynamic_cast<const SdrPathObj*>(pObject); + if (pSdrPathObj != nullptr) { sal_Int16 a, b, nIndex = 0; sal_uInt32 nDistance = 0xffffffff; // #i74631# use explicit constructor here. Also XPolyPolygon is not necessary, // reducing to PolyPolygon - const tools::PolyPolygon aPolyPoly(static_cast<SdrPathObj*>(pPoly)->GetPathPoly()); + const tools::PolyPolygon aPolyPoly(pSdrPathObj->GetPathPoly()); for ( a = 0; a < aPolyPoly.Count(); a++ ) { |