sc/source/core/data/column.cxx |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 27825fca1dd04b71ade7709fa06eca71a123cc36
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon May 26 10:43:47 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon May 26 13:27:54 2025 +0200

    tdf#161372 Spreadsheets with comments are unreasonably slow
    
    no need to instantiate invisible comments in this case,
    reduces column deelete time down to a couple of seconds
    
    Change-Id: I79cca144918d2ac36d902e2cda3ed8f962c2198a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185784
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5efe9da8a1af..4ef8dff3d01c 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1832,8 +1832,24 @@ void ScColumn::SwapCol(ScColumn& rCol)
     std::swap(mnBlkCountCellNotes, rCol.mnBlkCountCellNotes);
 
     // notes update caption
-    UpdateNoteCaptions(0, GetDoc().MaxRow());
-    rCol.UpdateNoteCaptions(0, GetDoc().MaxRow());
+    auto lclUpdateNoteCaptions = [](ScColumn& rColumn)
+    {
+        auto aFunc = [&rColumn]( size_t nRow, ScPostIt* p )
+        {
+            // We only need to update position if this note has been 
instantiated i.e. made visible.
+            if (p->GetCaption())
+            {
+                ScAddress aAddr(rColumn.nCol, nRow, rColumn.nTab);
+                p->UpdateCaptionPos(aAddr);
+                // Notify our LOK clients
+                
ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Modify, 
rColumn.GetDoc(), aAddr, p);
+            }
+        };
+        sc::ProcessNote(rColumn.maCellNotes.begin(), rColumn.maCellNotes, 0, 
rColumn.GetDoc().MaxRow(), aFunc);
+    };
+
+    lclUpdateNoteCaptions(*this);
+    lclUpdateNoteCaptions(rCol);
 
     std::swap(pAttrArray, rCol.pAttrArray);
 

Reply via email to