include/svx/EnhancedCustomShape2d.hxx | 1 svx/inc/sdr/properties/attributeproperties.hxx | 2 - svx/source/customshapes/EnhancedCustomShape2d.cxx | 21 ++++++++++++++++++ svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 3 -- svx/source/sdr/properties/attributeproperties.cxx | 6 +++-- 5 files changed, 28 insertions(+), 5 deletions(-)
New commits: commit a8ace353634afa9be103b1dc74613c9dac45b8d4 Author: Noel Grandin <[email protected]> AuthorDate: Thu Mar 27 11:57:48 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Mar 27 12:33:35 2025 +0100 tdf#130326 speedup load of complex XLSX Shaves 10% off load time by avoiding some unnecessary stylesheet work. Change-Id: Ide5545c4bea16904c62d76e3cf0676bdfddcf267 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183374 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/svx/EnhancedCustomShape2d.hxx b/include/svx/EnhancedCustomShape2d.hxx index ba638b0be900..09467d87f142 100644 --- a/include/svx/EnhancedCustomShape2d.hxx +++ b/include/svx/EnhancedCustomShape2d.hxx @@ -191,6 +191,7 @@ class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final : public SfxItemSet rtl::Reference<SdrObject> CreateLineGeometry(); rtl::Reference<SdrObject> CreateObject( bool bLineGeometryNeededOnly ); + rtl::Reference<SdrObject> CreateObject( bool bLineGeometryNeededOnly, SfxStyleSheet* pNewStyleSheet ); void ApplyGluePoints( SdrObject* pObj ); tools::Rectangle GetTextRect() const; const tools::Rectangle& GetLogicRect() const { return m_aLogicRect; } diff --git a/svx/inc/sdr/properties/attributeproperties.hxx b/svx/inc/sdr/properties/attributeproperties.hxx index 19d7a0f7aa18..adc303de00a6 100644 --- a/svx/inc/sdr/properties/attributeproperties.hxx +++ b/svx/inc/sdr/properties/attributeproperties.hxx @@ -63,7 +63,7 @@ namespace sdr::properties // Get the local ItemSet. This directly returns the local ItemSet of the object. No // merging of ItemSets is done for e.g. Group objects. - virtual const SfxItemSet& GetObjectItemSet() const override; + virtual const SfxItemSet& GetObjectItemSet() const override final; // destructor virtual ~AttributeProperties() override; diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 46e02bfc97cb..9d7db116863c 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -3041,6 +3041,27 @@ rtl::Reference<SdrObject> EnhancedCustomShape2d::CreateObject( bool bLineGeometr return pRet; } +/** Set the stylesheet immediately after creation, to avoid unnecessary stylesheet adding and removing. */ +rtl::Reference<SdrObject> EnhancedCustomShape2d::CreateObject( bool bLineGeometryNeededOnly, SfxStyleSheet* pNewStyleSheet ) +{ + rtl::Reference<SdrObject> pRet; + + if ( m_eSpType == mso_sptRectangle ) + { + pRet = new SdrRectObj(mrSdrObjCustomShape.getSdrModelFromSdrObject(), m_aLogicRect); + pRet->NbcSetStyleSheet(pNewStyleSheet, true); + pRet->SetMergedItemSet( *this ); + } + else + { + pRet = CreatePathObj( bLineGeometryNeededOnly ); + if (pRet) + pRet->NbcSetStyleSheet(pNewStyleSheet, true); + } + + return pRet; +} + static SdrEscapeDirection lcl_GetEscapeDirection(sal_Int32 nDirection) { switch (nDirection) diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 0bbb73ae40e6..19a277219273 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -271,7 +271,7 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render() bool bFlipH = aCustomShape2d.IsFlipHorz(); bool bLineGeometryNeededOnly = bTextPathOn; - rtl::Reference<SdrObject> xRenderedShape(aCustomShape2d.CreateObject(bLineGeometryNeededOnly)); + rtl::Reference<SdrObject> xRenderedShape(aCustomShape2d.CreateObject(bLineGeometryNeededOnly, pSdrObjCustomShape->GetStyleSheet())); if (xRenderedShape) { if ( bTextPathOn ) @@ -324,7 +324,6 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render() xRenderedShape->NbcMirror( aTop, aBottom ); } - xRenderedShape->NbcSetStyleSheet(pSdrObjCustomShape->GetStyleSheet(), true); xRenderedShape->RecalcSnapRect(); } diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index 3094eb01a1de..7b15d586a2cd 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -353,8 +353,10 @@ namespace sdr::properties void AttributeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool /*bBroadcast*/, bool /*bAdjustTextFrameWidthAndHeight*/) { - // guarantee SfxItemSet existence - GetObjectItemSet(); + // Make sure we have a SfxItemSet. We are deliberately bypassing our + // own AttributeProperties::GetObjectItemSet here, because we dont want to set a default stylesheet, + // and then immediately remove it, which is costly. + DefaultProperties::GetObjectItemSet(); ImpRemoveStyleSheet(); ImpAddStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
