summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-07-01 14:04:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-07-04 15:49:04 +0200
commit3e8f89f80ca0405c01d9b068ca9e85328e87404b (patch)
tree06afbb057b5156351f38b1eecd166ab80fbdc99c
parent1a6833a00fb7fcf04c71fcaa05dbee1f15a075d4 (diff)
tdf#137544 avoid some dynamic_cast cost
Change-Id: Ib60369eabb2ce5e9cde2dce80137b786130c0eec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136804 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--svx/source/unodraw/unopage.cxx9
-rw-r--r--svx/source/unodraw/unoshape.cxx18
2 files changed, 16 insertions, 11 deletions
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index ee91c36c9afe..96ab565f1c68 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -516,8 +516,9 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
if (!pNewObj)
return nullptr;
- if( auto pScene = dynamic_cast<E3dScene* >(pNewObj) )
+ if( nType == SdrObjKind::E3D_Scene )
{
+ auto pScene = static_cast<E3dScene* >(pNewObj);
// initialise scene
double fW = static_cast<double>(aSize.Width);
@@ -534,8 +535,9 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
pScene->SetBoundAndSnapRectsDirty();
}
- else if(auto pObj = dynamic_cast<E3dExtrudeObj* >(pNewObj))
+ else if(nType == SdrObjKind::E3D_Extrusion)
{
+ auto pObj = static_cast<E3dExtrudeObj* >(pNewObj);
basegfx::B2DPolygon aNewPolygon;
aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
@@ -546,8 +548,9 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
// #107245# pObj->SetExtrudeCharacterMode(sal_True);
pObj->SetMergedItem(Svx3DCharacterModeItem(true));
}
- else if(auto pLatheObj = dynamic_cast<E3dLatheObj* >(pNewObj))
+ else if(nType == SdrObjKind::E3D_Lathe)
{
+ auto pLatheObj = static_cast<E3dLatheObj* >(pNewObj);
basegfx::B2DPolygon aNewPolygon;
aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 0ef2f314d19f..e618c209d697 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -3105,15 +3105,17 @@ void SvxShape::setAllPropertiesToDefault()
{
::SolarMutexGuard aGuard;
- if( !HasSdrObject() )
+ SdrObject* pSdrObj = GetSdrObject();
+ if( !pSdrObj )
throw lang::DisposedException();
- GetSdrObject()->ClearMergedItem(); // nWhich == 0 => all
+ pSdrObj->ClearMergedItem(); // nWhich == 0 => all
- if(dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr)
+ const SdrObjKind nObjId = pSdrObj->GetObjIdentifier();
+ if(nObjId == SdrObjKind::Graphic) // SdrGrafObj
{
// defaults for graphic objects have changed:
- GetSdrObject()->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
- GetSdrObject()->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
+ pSdrObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
+ pSdrObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
}
// #i68523# special handling for Svx3DCharacterModeItem, this is not saved
@@ -3121,12 +3123,12 @@ void SvxShape::setAllPropertiesToDefault()
// does not load lathe or extrude objects, it is possible to set the items
// here.
// For other solution possibilities, see task description.
- if( dynamic_cast<const E3dLatheObj* >(GetSdrObject()) != nullptr|| dynamic_cast<const E3dExtrudeObj* >(GetSdrObject()) != nullptr)
+ if( nObjId == SdrObjKind::E3D_Lathe /*E3dLatheObj*/ || nObjId == SdrObjKind::E3D_Extrusion /*E3dExtrudeObj*/ )
{
- GetSdrObject()->SetMergedItem(Svx3DCharacterModeItem(true));
+ pSdrObj->SetMergedItem(Svx3DCharacterModeItem(true));
}
- GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
+ pSdrObj->getSdrModelFromSdrObject().SetChanged();
}
void SvxShape::setPropertiesToDefault(