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 <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2024-09-17 08:34:49 +02:00
committed by Noel Grandin
parent a95b90bc0c
commit 3b5b421eed
4 changed files with 28 additions and 7 deletions

View File

@@ -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<bool(const SvxColorItem&)>& ) const;
/// Iterate over all RES_CHRATR_UNDERLINE SvxUnderlineItem, if the function returns false, iteration is stopped
SW_DLLPUBLIC void ForEachCharacterUnderlineItem(const std::function<bool(const SvxUnderlineItem&)>& ) const;
// Call into intransparent Basic; expect possible Return String.
void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs );

View File

@@ -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 },

View File

@@ -1452,6 +1452,26 @@ void SwDoc::ForEachCharacterColorItem( const std::function<bool(const SvxColorIt
}
}
/// Iterate over all SvxUnderlineItem, if the function returns false, iteration is stopped
void SwDoc::ForEachCharacterUnderlineItem( const std::function<bool(const SvxUnderlineItem&)>& 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<std::shared_ptr<SfxItemSet>> aStyles;
for (auto eFamily : { IStyleAccess::AUTO_STYLE_CHAR, IStyleAccess::AUTO_STYLE_RUBY, IStyleAccess::AUTO_STYLE_PARA, IStyleAccess::AUTO_STYLE_NOTXT })
{
const_cast<SwDoc*>(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)
{

View File

@@ -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<const SvxUnderlineItem&>(*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());