From 3b5b421eed8de62d06a1f53a4d7d88c8fe90795d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 17 Sep 2024 08:34:49 +0200 Subject: [PATCH] dont use GetItemSurrogates for gathering SvxUnderlineItem which is very expensive these days Change-Id: Ia8485f38b7aeb763a49a1acb433e22d1360694e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173513 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/inc/doc.hxx | 3 +++ sw/source/core/bastyp/init.cxx | 2 +- sw/source/core/doc/doc.cxx | 20 ++++++++++++++++++++ sw/source/filter/ww8/rtfexport.cxx | 10 ++++------ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 2471d7c9a578..9b6e56db50d9 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1446,6 +1446,9 @@ public: /// Iterate over all RES_CHRATR_COLOR SvxColorItem, if the function returns false, iteration is stopped SW_DLLPUBLIC void ForEachCharacterColorItem(const std::function& ) const; + /// Iterate over all RES_CHRATR_UNDERLINE SvxUnderlineItem, if the function returns false, iteration is stopped + SW_DLLPUBLIC void ForEachCharacterUnderlineItem(const std::function& ) const; + // Call into intransparent Basic; expect possible Return String. void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs ); diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 796b4ae68780..daca2f32d7c4 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -290,7 +290,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes() { RES_CHRATR_POSTURE, new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE ), SID_ATTR_CHAR_POSTURE, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_UNUSED1, new SfxVoidItem( RES_CHRATR_UNUSED1 ), 0, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_SHADOWED, new SvxShadowedItem( false, RES_CHRATR_SHADOWED ), SID_ATTR_CHAR_SHADOWED, SFX_ITEMINFOFLAG_NONE }, - { RES_CHRATR_UNDERLINE, new SvxUnderlineItem( LINESTYLE_NONE, RES_CHRATR_UNDERLINE ), SID_ATTR_CHAR_UNDERLINE, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, + { RES_CHRATR_UNDERLINE, new SvxUnderlineItem( LINESTYLE_NONE, RES_CHRATR_UNDERLINE ), SID_ATTR_CHAR_UNDERLINE, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_WEIGHT, new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT ), SID_ATTR_CHAR_WEIGHT, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_WORDLINEMODE, new SvxWordLineModeItem( false, RES_CHRATR_WORDLINEMODE ), SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_AUTOKERN, new SvxAutoKernItem( false, RES_CHRATR_AUTOKERN ), SID_ATTR_CHAR_AUTOKERN, SFX_ITEMINFOFLAG_NONE }, diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 102eee83a852..bc5ec45973eb 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1452,6 +1452,26 @@ void SwDoc::ForEachCharacterColorItem( const std::function& rFunc ) const +{ + for(SwCharFormat* pFormat : *GetCharFormats()) + { + const SwAttrSet& rAttrSet = pFormat->GetAttrSet(); + if (const SvxUnderlineItem* pItem = rAttrSet.GetItemIfSet(RES_CHRATR_UNDERLINE)) + if (!rFunc(*pItem)) + return; + } + std::vector> aStyles; + for (auto eFamily : { IStyleAccess::AUTO_STYLE_CHAR, IStyleAccess::AUTO_STYLE_RUBY, IStyleAccess::AUTO_STYLE_PARA, IStyleAccess::AUTO_STYLE_NOTXT }) + { + const_cast(this)->GetIStyleAccess().getAllStyles(aStyles, eFamily); + for (const auto & rxItemSet : aStyles) + if (const SvxUnderlineItem* pItem = rxItemSet->GetItemIfSet(RES_CHRATR_UNDERLINE)) + if (!rFunc(*pItem)) + return; + } +} void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress) { diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 8191b36665e7..ee490d562013 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1332,12 +1332,10 @@ void RtfExport::OutColorTable() auto pUnder = GetDfltAttr(RES_CHRATR_UNDERLINE); InsColor(pUnder->GetColor()); - rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_UNDERLINE); - for (const SfxPoolItem* pItem : aSurrogates) - { - pUnder = &static_cast(*pItem); - InsColor(pUnder->GetColor()); - } + m_rDoc.ForEachCharacterUnderlineItem([this](const SvxUnderlineItem& rUnder) -> bool { + InsColor(rUnder.GetColor()); + return true; + }); auto pOver = GetDfltAttr(RES_CHRATR_OVERLINE); InsColor(pOver->GetColor());