sw/inc/doc.hxx | 3 + sw/inc/tblafmt.hxx | 1 sw/source/core/bastyp/init.cxx | 2 - sw/source/core/doc/doc.cxx | 56 +++++++++++++++++++++++++++++++++++++ sw/source/filter/ww8/rtfexport.cxx | 10 ++---- 5 files changed, 65 insertions(+), 7 deletions(-)
New commits: commit 5650b8a66231033a03ae9e4c35d5aaab907655d6 Author: Noel Grandin <[email protected]> AuthorDate: Sun Sep 8 19:16:40 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Sep 9 07:58:31 2024 +0200 dont use GetItemSurrogates for gathering SvxOverlineItem which is very expensive these days Change-Id: I0ac24ba8ef4df9310b9e6ca5cfd7a132a61bb889 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173049 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 80f29accb3dd..6da96bd2cb82 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1434,6 +1434,9 @@ public: /// Iterate over all SwFormatURL, if the function returns false, iteration is stopped SW_DLLPUBLIC void ForEachFormatURL( const std::function<bool(const SwFormatURL&)>& ) const; + /// Iterate over all SvxOverlineItem, if the function returns false, iteration is stopped + SW_DLLPUBLIC void ForEachOverlineItem( const std::function<bool(const SvxOverlineItem&)>& ) const; + // Call into intransparent Basic; expect possible Return String. void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs ); diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 16f84d8ad42c..a209eab50382 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -304,6 +304,7 @@ public: SwCellStyleDescriptor(const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rCellStyleDesc) : m_rCellStyleDesc(rCellStyleDesc) { } const OUString& GetName() const { return m_rCellStyleDesc.first; } + const SwBoxAutoFormat& GetAutoFormat() const { return *m_rCellStyleDesc.second; } }; class SwCellStyleTable diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index a1d5908458b9..cc964e7aa01a 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -319,7 +319,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes() { RES_CHRATR_SCALEW, new SvxCharScaleWidthItem( 100, RES_CHRATR_SCALEW ), SID_ATTR_CHAR_SCALEWIDTH, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_RELIEF, new SvxCharReliefItem( FontRelief::NONE, RES_CHRATR_RELIEF ), SID_ATTR_CHAR_RELIEF, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_HIDDEN, new SvxCharHiddenItem( false, RES_CHRATR_HIDDEN ), SID_ATTR_CHAR_HIDDEN, SFX_ITEMINFOFLAG_NONE }, - { RES_CHRATR_OVERLINE, new SvxOverlineItem( LINESTYLE_NONE, RES_CHRATR_OVERLINE ), SID_ATTR_CHAR_OVERLINE, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, + { RES_CHRATR_OVERLINE, new SvxOverlineItem( LINESTYLE_NONE, RES_CHRATR_OVERLINE ), SID_ATTR_CHAR_OVERLINE, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_RSID, new SvxRsidItem( 0, RES_CHRATR_RSID ), 0, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_BOX, new SvxBoxItem( RES_CHRATR_BOX ), SID_ATTR_CHAR_BOX, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, { RES_CHRATR_SHADOW, new SvxShadowItem( RES_CHRATR_SHADOW ), SID_ATTR_CHAR_SHADOW, SFX_ITEMINFOFLAG_NONE }, diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 4214849e88a7..ec69fb2057d7 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -51,6 +51,7 @@ #include <editeng/keepitem.hxx> #include <editeng/formatbreakitem.hxx> #include <editeng/pbinitem.hxx> +#include <editeng/udlnitem.hxx> #include <unotools/localedatawrapper.hxx> #include <officecfg/Office/Writer.hxx> @@ -113,6 +114,7 @@ #include <unoprnms.hxx> #include <unomap.hxx> #include <fmturl.hxx> +#include <tblafmt.hxx> using namespace ::com::sun::star; @@ -1224,6 +1226,60 @@ static bool lcl_CheckSmartTagsAgain( SwNode* pNd, void* ) return true; } +/// Iterate over all SvxOverlineItem, if the function returns false, iteration is stopped +void SwDoc::ForEachOverlineItem( const std::function<bool(const SvxOverlineItem&)>& rFunc ) const +{ + SwNodeOffset nCount = GetNodes().Count(); + for (SwNodeOffset i(0); i < nCount; ++i) + { + SwNode* pNode = GetNodes()[i]; + if (!pNode->IsTextNode()) + continue; + SwTextNode* pTextNode = pNode->GetTextNode(); + const SwAttrSet& rAttrSet = pTextNode->GetSwAttrSet(); + if (const SvxOverlineItem* pItem = rAttrSet.GetItemIfSet(RES_CHRATR_OVERLINE, false)) + if (!rFunc(*pItem)) + return; + if (pTextNode->HasHints()) + { + SwpHints& rHints = pTextNode->GetSwpHints(); + for (size_t j = 0; j < rHints.Count(); ++j) + { + const SwTextAttr* pTextAttr = rHints.Get(j); + if (pTextAttr->Which() != RES_TXTATR_AUTOFMT) + continue; + const SwFormatAutoFormat& rAutoFormat = pTextAttr->GetAutoFormat(); + const std::shared_ptr<SfxItemSet> & rxItemSet = rAutoFormat.GetStyleHandle(); + if (const SvxOverlineItem* pItem = rxItemSet->GetItemIfSet(RES_CHRATR_OVERLINE, false)) + if (!rFunc(*pItem)) + return; + } + } + } + const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap(); + const SwTableAutoFormatTable& rTableStyles = GetTableStyles(); + for (size_t i=0; i < rTableStyles.size(); ++i) + { + const SwTableAutoFormat& rTableStyle = rTableStyles[i]; + for (const sal_uInt32 nBoxIndex : aTableTemplateMap) + { + const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex); + const SvxOverlineItem rOverlineItem = rBoxFormat.GetOverline(); + if (!rFunc(rOverlineItem)) + return; + } + } + const SwCellStyleTable& rCellStyleTable = GetCellStyles(); + for (size_t i=0; i < rCellStyleTable.size(); ++i) + { + const SwCellStyleDescriptor& rCellStyle = rCellStyleTable[i]; + const SwBoxAutoFormat& rBoxFormat = rCellStyle.GetAutoFormat(); + const SvxOverlineItem rOverlineItem = rBoxFormat.GetOverline(); + if (!rFunc(rOverlineItem)) + return; + } +} + /** * Re-trigger spelling in the idle handler. * diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index d2337de3845b..9cc2a4fa7977 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1343,12 +1343,10 @@ void RtfExport::OutColorTable() auto pOver = GetDfltAttr(RES_CHRATR_OVERLINE); InsColor(pOver->GetColor()); - rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_OVERLINE); - for (const SfxPoolItem* pItem : aSurrogates) - { - pOver = &static_cast<const SvxOverlineItem&>(*pItem); - InsColor(pOver->GetColor()); - } + m_rDoc.ForEachOverlineItem([this](const SvxOverlineItem& rOver) -> bool { + InsColor(rOver.GetColor()); + return true; + }); } // background color
