sw/source/core/table/swtable.cxx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
New commits: commit 55746997bafdd270158f40800ac515a36b9056c2 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Sep 4 20:02:14 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Sep 9 12:35:54 2024 +0200 use less GetItemSurrogates in SwTable::UpdateFields which speeds up loading a large document with lots of nested tables from several minutes to under 15s Regression from commit ae7807c889c19145f89cec40afac82eee191837c Author: Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de> Date: Wed Jan 10 20:07:47 2024 +0100 ITEM: No longer register Items at Pool Change-Id: If44bbc50074fc324e9458a4ac498f402500981e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172937 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172944 diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 0e7a24a6dd64..179792a682e9 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1720,21 +1720,26 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags) break; } } + // process all table box formulas - ItemSurrogates aSurrogates; - pDoc->GetAttrPool().GetItemSurrogates(aSurrogates, RES_BOXATR_FORMULA); - for(const SfxPoolItem* pItem : aSurrogates) + SwTableLines& rTableLines = GetTabLines(); + for (SwTableLine* pTableLine : rTableLines) { - // SwTableBoxFormula is non-shareable, so const_cast is somewhat OK - auto & rBoxFormula = const_cast<SwTableBoxFormula&>(static_cast<const SwTableBoxFormula&>(*pItem)); - if(rBoxFormula.GetDefinedIn()) + SwTableBoxes& rTableBoxes = pTableLine->GetTabBoxes(); + for (SwTableBox* pTableBox : rTableBoxes) { - if(eFlags == TBL_BOXPTR) - rBoxFormula.TryBoxNmToPtr(); - else if(eFlags == TBL_RELBOXNAME) - rBoxFormula.TryRelBoxNm(); - else - rBoxFormula.ChangeState(); + SwTableBoxFormat* pTableBoxFormat = static_cast<SwTableBoxFormat*>(pTableBox->GetFrameFormat()); + if (const SwTableBoxFormula* pItem = pTableBoxFormat->GetItemIfSet( RES_BOXATR_FORMULA, false )) + { + // SwTableBoxFormula is non-shareable, so const_cast is somewhat OK + auto & rBoxFormula = const_cast<SwTableBoxFormula&>(*pItem); + if(eFlags == TBL_BOXPTR) + rBoxFormula.TryBoxNmToPtr(); + else if(eFlags == TBL_RELBOXNAME) + rBoxFormula.TryRelBoxNm(); + else + rBoxFormula.ChangeState(); + } } } }