sw/inc/doc.hxx | 6 ++++++ sw/source/core/bastyp/init.cxx | 4 ++-- sw/source/core/doc/doc.cxx | 36 ++++++++++++++++++++++++++++++++++++ sw/source/filter/ww8/rtfexport.cxx | 20 ++++++++------------ 4 files changed, 52 insertions(+), 14 deletions(-)
New commits: commit c2f32dbd8a64bb986b01aed746e7448fadb8cbe0 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Sep 24 15:31:16 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 24 17:01:57 2024 +0200 dont use GetItemSurrogates for gathering SvxShadowItem which is very expensive these days Change-Id: I93833d703407304e8ed20be0783e0562352b927a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173867 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index abc125138b71..a90f82fcd720 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1471,6 +1471,9 @@ public: /// Iterate over all RES_BOX SvxBoxItem, if the function returns false, iteration is stopped SW_DLLPUBLIC void ForEachBoxItem(const std::function<bool(const SvxBoxItem&)>& ) const; + /// Iterate over all RES_SHADOW SvxShadowItem, if the function returns false, iteration is stopped + SW_DLLPUBLIC void ForEachShadowItem(const std::function<bool(const SvxShadowItem&)>& ) 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 814f4b23bcb8..3bbfd40268a1 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -409,7 +409,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes() { RES_ANCHOR, new SwFormatAnchor, 0, SFX_ITEMINFOFLAG_NONE }, { RES_BACKGROUND, new SvxBrushItem( RES_BACKGROUND ), SID_ATTR_BRUSH, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, { RES_BOX, new SvxBoxItem( RES_BOX ), SID_ATTR_BORDER_OUTER, SFX_ITEMINFOFLAG_NONE }, - { RES_SHADOW, new SvxShadowItem( RES_SHADOW ), SID_ATTR_BORDER_SHADOW, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, + { RES_SHADOW, new SvxShadowItem( RES_SHADOW ), SID_ATTR_BORDER_SHADOW, SFX_ITEMINFOFLAG_NONE }, { RES_FRMMACRO, new SvxMacroItem( RES_FRMMACRO ), SID_ATTR_MACROITEM, SFX_ITEMINFOFLAG_NONE }, { RES_COL, new SwFormatCol, FN_ATTR_COLUMNS, SFX_ITEMINFOFLAG_NONE }, { RES_KEEP, new SvxFormatKeepItem( false, RES_KEEP ), SID_ATTR_PARA_KEEP, SFX_ITEMINFOFLAG_NONE }, diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index db1762009ef4..fe9a5be66c00 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1621,6 +1621,24 @@ void SwDoc::ForEachBoxItem(const std::function<bool(const SvxBoxItem&)>& rFunc ) } } +/// Iterate over all RES_SHADOW SvxBoxItem, if the function returns false, iteration is stopped +void SwDoc::ForEachShadowItem(const std::function<bool(const SvxShadowItem&)>& rFunc ) const +{ + SwNodeOffset nCount = GetNodes().Count(); + for (SwNodeOffset i(0); i < nCount; ++i) + { + const SwNode* pNode = GetNodes()[i]; + if (pNode->IsContentNode()) + { + const SwContentNode* pTextNode = pNode->GetContentNode(); + if (pTextNode->HasSwAttrSet()) + if (const SvxShadowItem* pItem = pTextNode->GetSwAttrSet().GetItemIfSet(RES_SHADOW)) + if (!rFunc(*pItem)) + return; + } + } +} + void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress) { const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds(); diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 5ff491f53e8b..0ce35c6f9c29 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1388,12 +1388,10 @@ void RtfExport::OutColorTable() { InsColor(pShadow->GetColor()); } - rPool.GetItemSurrogates(aSurrogates, RES_SHADOW); - for (const SfxPoolItem* pItem : aSurrogates) - { - pShadow = &static_cast<const SvxShadowItem&>(*pItem); - InsColor(pShadow->GetColor()); - } + m_rDoc.ForEachShadowItem([this](const SvxShadowItem& rShadow) -> bool { + InsColor(rShadow.GetColor()); + return true; + }); } // frame border color commit a8161a4aea3fc7e2f24435c30befdf82421653e6 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Sep 23 21:35:06 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 24 17:01:48 2024 +0200 dont use GetItemSurrogates for gathering SvxBoxItem which is very expensive these days Change-Id: I0cb9af2afcbdb802e6a783df6cd30f5905e1ff1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173854 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 776120717e73..abc125138b71 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1468,6 +1468,9 @@ public: /// Iterate over all RES_UNKNOWNATR_CONTAINER SvXMLAttrContainerItem, if the function returns false, iteration is stopped SW_DLLPUBLIC void ForEachUnknownAtrContainerItem(const std::function<bool(const SvXMLAttrContainerItem&)>& ) const; + /// Iterate over all RES_BOX SvxBoxItem, if the function returns false, iteration is stopped + SW_DLLPUBLIC void ForEachBoxItem(const std::function<bool(const SvxBoxItem&)>& ) 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 9dbf4043d88f..814f4b23bcb8 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -408,7 +408,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes() { RES_HORI_ORIENT, new SwFormatHoriOrient, FN_HORI_ORIENT, SFX_ITEMINFOFLAG_NONE }, { RES_ANCHOR, new SwFormatAnchor, 0, SFX_ITEMINFOFLAG_NONE }, { RES_BACKGROUND, new SvxBrushItem( RES_BACKGROUND ), SID_ATTR_BRUSH, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, - { RES_BOX, new SvxBoxItem( RES_BOX ), SID_ATTR_BORDER_OUTER, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, + { RES_BOX, new SvxBoxItem( RES_BOX ), SID_ATTR_BORDER_OUTER, SFX_ITEMINFOFLAG_NONE }, { RES_SHADOW, new SvxShadowItem( RES_SHADOW ), SID_ATTR_BORDER_SHADOW, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, { RES_FRMMACRO, new SvxMacroItem( RES_FRMMACRO ), SID_ATTR_MACROITEM, SFX_ITEMINFOFLAG_NONE }, { RES_COL, new SwFormatCol, FN_ATTR_COLUMNS, SFX_ITEMINFOFLAG_NONE }, diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 2724ccb0fb7c..db1762009ef4 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1603,6 +1603,24 @@ void SwDoc::ForEachUnknownAtrContainerItem(const std::function<bool(const SvXMLA } } +/// Iterate over all RES_BOX SvxBoxItem, if the function returns false, iteration is stopped +void SwDoc::ForEachBoxItem(const std::function<bool(const SvxBoxItem&)>& rFunc ) const +{ + SwNodeOffset nCount = GetNodes().Count(); + for (SwNodeOffset i(0); i < nCount; ++i) + { + const SwNode* pNode = GetNodes()[i]; + if (pNode->IsContentNode()) + { + const SwContentNode* pTextNode = pNode->GetContentNode(); + if (pTextNode->HasSwAttrSet()) + if (const SvxBoxItem* pItem = pTextNode->GetSwAttrSet().GetItemIfSet(RES_BOX)) + if (!rFunc(*pItem)) + return; + } + } +} + void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress) { const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds(); diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index d7bbeb6bfb53..5ff491f53e8b 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1401,12 +1401,10 @@ void RtfExport::OutColorTable() const SvxBoxItem* pBox = rPool.GetUserDefaultItem(RES_BOX); if (nullptr != pBox) InsColorLine(*pBox); - rPool.GetItemSurrogates(aSurrogates, RES_BOX); - for (const SfxPoolItem* pItem : aSurrogates) - { - pBox = &static_cast<const SvxBoxItem&>(*pItem); - InsColorLine(*pBox); - } + m_rDoc.ForEachBoxItem([this](const SvxBoxItem& rBox) -> bool { + InsColorLine(rBox); + return true; + }); } {