dont use GetItemSurrogates for gathering SvxColorItem

which is very expensive these days

Change-Id: I26da48f3b29bc3029d359214e0c50fa51e9e2194
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173479
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin
2024-09-16 21:04:59 +02:00
committed by Noel Grandin
parent 539856dbb7
commit 08c58ac519
4 changed files with 31 additions and 7 deletions

View File

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

View File

@@ -279,7 +279,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes()
// m_nWhich, m_pItem, m_nSlotID, m_nItemInfoFlags
{ RES_CHRATR_CASEMAP, new SvxCaseMapItem( SvxCaseMap::NotMapped, RES_CHRATR_CASEMAP), SID_ATTR_CHAR_CASEMAP, SFX_ITEMINFOFLAG_NONE },
{ RES_CHRATR_CHARSETCOLOR, new SvxColorItem(RES_CHRATR_CHARSETCOLOR), SID_ATTR_CHAR_CHARSETCOLOR, SFX_ITEMINFOFLAG_NONE },
{ RES_CHRATR_COLOR, new SvxColorItem(RES_CHRATR_COLOR), SID_ATTR_CHAR_COLOR, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE },
{ RES_CHRATR_COLOR, new SvxColorItem(RES_CHRATR_COLOR), SID_ATTR_CHAR_COLOR, SFX_ITEMINFOFLAG_NONE },
{ RES_CHRATR_CONTOUR, new SvxContourItem( false, RES_CHRATR_CONTOUR ), SID_ATTR_CHAR_CONTOUR, SFX_ITEMINFOFLAG_NONE },
{ RES_CHRATR_CROSSEDOUT, new SvxCrossedOutItem( STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ), SID_ATTR_CHAR_STRIKEOUT, SFX_ITEMINFOFLAG_NONE },
{ RES_CHRATR_ESCAPEMENT, new SvxEscapementItem( RES_CHRATR_ESCAPEMENT ), SID_ATTR_CHAR_ESCAPEMENT, SFX_ITEMINFOFLAG_NONE },

View File

@@ -52,6 +52,7 @@
#include <editeng/formatbreakitem.hxx>
#include <editeng/pbinitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/colritem.hxx>
#include <unotools/localedatawrapper.hxx>
#include <officecfg/Office/Writer.hxx>
@@ -1430,6 +1431,28 @@ void SwDoc::ForEachCharacterBoxItem( const std::function<bool(const SvxBoxItem&)
}
}
/// Iterate over all SvxColorItem, if the function returns false, iteration is stopped
void SwDoc::ForEachCharacterColorItem( const std::function<bool(const SvxColorItem&)>& rFunc ) const
{
for(SwCharFormat* pFormat : *GetCharFormats())
{
const SwAttrSet& rAttrSet = pFormat->GetAttrSet();
if (const SvxColorItem* pColorItem = rAttrSet.GetItemIfSet(RES_CHRATR_COLOR))
if (!rFunc(*pColorItem))
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 SvxColorItem* pColorItem = rxItemSet->GetItemIfSet(RES_CHRATR_COLOR))
if (!rFunc(*pColorItem))
return;
}
}
void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress)
{
const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();

View File

@@ -1325,12 +1325,10 @@ void RtfExport::OutColorTable()
pCol = rPool.GetUserDefaultItem(RES_CHRATR_COLOR);
if (pCol)
InsColor(pCol->GetValue());
rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_COLOR);
for (const SfxPoolItem* pItem : aSurrogates)
{
pCol = &static_cast<const SvxColorItem&>(*pItem);
InsColor(pCol->GetValue());
}
m_rDoc.ForEachCharacterColorItem([this](const SvxColorItem& rColorItem) -> bool {
InsColor(rColorItem.GetValue());
return true;
});
auto pUnder = GetDfltAttr(RES_CHRATR_UNDERLINE);
InsColor(pUnder->GetColor());