sw/source/core/table/swtable.cxx |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

New commits:
commit 7b16c7db04affde593bfaf75965c4271e4c3ea58
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Sep 4 20:02:14 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Sep 6 12:55:48 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>

diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index ce9025ef1b7a..5225af1c0dd9 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1713,21 +1713,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();
+            }
         }
     }
 }

Reply via email to