svx/source/sdr/properties/textproperties.cxx | 60 ++++++++++++--------------- sw/inc/doc.hxx | 1 sw/source/core/doc/docfly.cxx | 19 ++++++++ sw/source/core/unocore/unoframe.cxx | 13 ----- 4 files changed, 48 insertions(+), 45 deletions(-)
New commits: commit e4519e38d3598c3e26f2585bbc2553bc7ff5db4c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 20 09:59:09 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Mar 21 21:21:57 2024 +0100 tdf#158556 speedup docx load Avoid O(n^2) loop in SwXFrame::setPropertyValue, we even have an index to search for this stuff Reduces load time from 325s to 172s Change-Id: I6c6c03206ef81be1d7d7702a4313acd23d75442d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165044 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 241e2d68664e0e53cf02fe9986462c4a9ecd8d42) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165110 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ea95cef85636..99cb33c75826 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -838,6 +838,7 @@ public: std::vector<SwFrameFormat const*> GetFlyFrameFormats( FlyCntType eType, bool bIgnoreTextBoxes); + SwFrameFormat* GetFlyFrameFormatByName( const OUString& sFrameFormatName ); // Copy formats in own arrays and return them. SwFrameFormat *CopyFrameFormat ( const SwFrameFormat& ); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index c492212487c3..203894123007 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -149,6 +149,25 @@ SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreText return pRetFormat; } +SwFrameFormat* SwDoc::GetFlyFrameFormatByName( const OUString& rFrameFormatName ) +{ + auto pFrameFormats = GetSpzFrameFormats(); + auto it = pFrameFormats->findByTypeAndName( RES_FLYFRMFMT, rFrameFormatName ); + auto endIt = pFrameFormats->typeAndNameEnd(); + for ( ; it != endIt; ++it) + { + sw::SpzFrameFormat* pFlyFormat = *it; + const SwNodeIndex* pIdx = pFlyFormat->GetContent().GetContentIdx(); + if( !pIdx || !pIdx->GetNodes().IsDocNodes() ) + continue; + + const SwNode* pNd = GetNodes()[ pIdx->GetIndex() + 1 ]; + if( !pNd->IsNoTextNode()) + return pFlyFormat; + } + return nullptr; +} + std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats( FlyCntType const eType, bool const bIgnoreTextBoxes) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 7880a749b95c..62c4c76ac3ab 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1713,18 +1713,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& } else { - const size_t nCount = pDoc->GetFlyCount(FLYCNTTYPE_FRM); - - SwFrameFormat* pChain = nullptr; - for( size_t i = 0; i < nCount; ++i ) - { - SwFrameFormat* pFormat2 = pDoc->GetFlyNum(i, FLYCNTTYPE_FRM); - if(sChainName == pFormat2->GetName() ) - { - pChain = pFormat2; - break; - } - } + SwFrameFormat* pChain = pDoc->GetFlyFrameFormatByName(sChainName); if(pChain) { SwFrameFormat* pSource = bNextFrame ? pFormat : pChain; commit d83d68f120ad3ccfc036e25cf9d5b04fb36f7c8b Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 6 14:12:51 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Mar 21 21:21:49 2024 +0100 tdf#158773 reduce cost of TextProperties::Notify Shaves 30% off the load time here, by re-arranging the logic so we do th expensive dynamic_cast less often Change-Id: If7a1605994e620dbdb61010506c624cc738359a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164466 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 3b784236d7c3bf386deeeadcf79d9e9b289bf991) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165112 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index 55b366bdc03b..17f63d044dcf 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -554,50 +554,44 @@ namespace sdr::properties if(!rObj.HasText()) return; + SfxHintId nId(rHint.GetId()); const svx::ITextProvider& rTextProvider(getTextProvider()); - if(dynamic_cast<const SfxStyleSheet *>(&rBC) != nullptr) - { - SfxHintId nId(rHint.GetId()); - if(SfxHintId::DataChanged == nId) + if(SfxHintId::DataChanged == nId && dynamic_cast<const SfxStyleSheet *>(&rBC) != nullptr) + { + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) { - sal_Int32 nText = rTextProvider.getTextCount(); - while (nText--) - { - OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); - if( pParaObj ) - pParaObj->ClearPortionInfo(); - } - rObj.SetTextSizeDirty(); - - if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight()) - { - // here only repaint wanted - rObj.ActionChanged(); - //rObj.BroadcastObjectChange(); - } + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); + if( pParaObj ) + pParaObj->ClearPortionInfo(); + } + rObj.SetTextSizeDirty(); - // #i101556# content of StyleSheet has changed -> new version - maVersion++; + if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight()) + { + // here only repaint wanted + rObj.ActionChanged(); + //rObj.BroadcastObjectChange(); } - if(SfxHintId::Dying == nId) + // #i101556# content of StyleSheet has changed -> new version + maVersion++; + } + else if(SfxHintId::Dying == nId && dynamic_cast<const SfxStyleSheet *>(&rBC) != nullptr) + { + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) { - sal_Int32 nText = rTextProvider.getTextCount(); - while (nText--) - { - OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); - if( pParaObj ) - pParaObj->ClearPortionInfo(); - } + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); + if( pParaObj ) + pParaObj->ClearPortionInfo(); } } - else if(dynamic_cast<const SfxStyleSheetBasePool *>(&rBC) != nullptr) + else if (nId == SfxHintId::StyleSheetModified && dynamic_cast<const SfxStyleSheetBasePool *>(&rBC) != nullptr) { const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint); - - if(pExtendedHint - && SfxHintId::StyleSheetModified == pExtendedHint->GetId()) + if (pExtendedHint) { const OUString& aOldName(pExtendedHint->GetOldName()); OUString aNewName(pExtendedHint->GetStyleSheet()->GetName());