From 56cd3b2b5d395165cd4add2f46ac4ba25a4ea4af Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 21 Feb 2022 16:14:03 +0200 Subject: tdf#64914 slow opening large chart shaves 2% off the load time by avoid the cost of comphelper::getFromUnoTunnel Change-Id: I9d0438bd0ad3cf753d34fe181481f3a57193651c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130284 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svx/source/unodraw/unoshap2.cxx | 21 +++++++++++++++------ svx/source/unodraw/unoshap3.cxx | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'svx') diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index e68676b577c8..057b55de9fde 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -169,22 +169,31 @@ void SAL_CALL SvxShapeGroup::leaveGroup( ) void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape, size_t nPos ) { - if (!HasSdrObject() || !mxPage.is()) + SvxShape* pShape = comphelper::getFromUnoTunnel( xShape ); + if (!pShape) { OSL_FAIL("could not add XShape to group shape!"); return; } + addShape(*pShape, nPos); +} - SvxShape* pShape = comphelper::getFromUnoTunnel( xShape ); - if (!pShape) +void SvxShapeGroup::addShape( SvxShape& rShape ) +{ + addShape(rShape, SAL_MAX_SIZE); +} + +void SvxShapeGroup::addShape( SvxShape& rShape, size_t nPos ) +{ + if (!HasSdrObject() || !mxPage.is()) { OSL_FAIL("could not add XShape to group shape!"); return; } - SdrObject* pSdrShape = pShape->GetSdrObject(); + SdrObject* pSdrShape = rShape.GetSdrObject(); if( pSdrShape == nullptr ) - pSdrShape = mxPage->CreateSdrObject_( xShape ); + pSdrShape = mxPage->CreateSdrObject_( &rShape ); if( pSdrShape->IsInserted() ) pSdrShape->getParentSdrObjListFromSdrObject()->RemoveObject( pSdrShape->GetOrdNum() ); @@ -205,7 +214,7 @@ void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape // Establish connection between new SdrObject and its wrapper before // inserting the new shape into the group. There a new wrapper // would be created when this connection would not already exist. - pShape->Create( pSdrShape, mxPage.get() ); + rShape.Create( pSdrShape, mxPage.get() ); GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); } diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx index f1763aeb041d..0704a4e5caa1 100644 --- a/svx/source/unodraw/unoshap3.cxx +++ b/svx/source/unodraw/unoshap3.cxx @@ -131,6 +131,27 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); } +void Svx3DSceneObject::addShape( SvxShape& rShape ) +{ + SolarMutexGuard aGuard; + + if(!HasSdrObject() || !mxPage.is() || nullptr != rShape.GetSdrObject() ) + throw uno::RuntimeException(); + + SdrObject* pSdrShape = mxPage->CreateSdrObject_( &rShape ); + if( dynamic_cast(pSdrShape) != nullptr ) + { + GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape ); + rShape.Create(pSdrShape, mxPage.get()); + } + else + { + SdrObject::Free( pSdrShape ); + throw uno::RuntimeException(); + } + + GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); +} void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xShape ) { -- cgit