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 <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2025-03-27 12:33:35 +01:00
parent a790b8f4d5
commit a8ace35363
5 changed files with 28 additions and 5 deletions
+1
View File
@@ -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; }
@@ -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;
@@ -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)
@@ -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();
}
@@ -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);