[Libreoffice-commits] core.git: sc/source

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 24 08:59:02 UTC 2019


 sc/source/core/data/document.cxx |    6 ------
 sc/source/core/data/table2.cxx   |    4 ++++
 2 files changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 46c8ebe3d352c39bbba1a8099717fbeba384bd1a
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Sun Jun 23 21:15:18 2019 +0530
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Jun 24 10:58:01 2019 +0200

    tdf#125661 : Move the delayed-grouping logic...
    
    introduced in commit
    
    169a1b542165f3444791fd6e672d56d3fe48bd66
    avoid possible expensive repetitive formula-group
    changes (tdf#102364)
    
    to ScTable::CopyToTable() from ScDocument::CopyToDocument()
    
    Rationale :
    In tdf#125661 a delayed-grouping is needed but
    ScDocument::CopyTab() is directly called which makes it
    skip the delayed-grouping logic in ScDocument::CopyToDocument().
    One option is to clone the delayed-grouping logic to CopyTab() too.
    But doing this triggers the assert
    
    !pDoc->IsDelayedFormulaGrouping() in
    bool ScBroadcastAreaSlot::StartListeningArea()
    
    when running the unit test testCondCopyPasteSheet() in
    ucalc_condformat.cxx. This seems to be due to calling
    ScTable::CopyConditionalFormat() towards the end in
    ScTable::CopyToTable(). So having delayed-grouping
    "block" that contains a call(s) to ScTable::CopyToTable() is
    not safe. So lets move this inside ScTable::CopyToTable()
    covering just the ScColumn::CopyToColumn() calls.
    
    With this patch, sheet copy on the bug-document completes
    in about 1m40s.
    
    Change-Id: I5272f495aadab5f93f2698aba11cf2701a604c23
    Reviewed-on: https://gerrit.libreoffice.org/74607
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 106ca902534e..3a65ae04aad7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2110,11 +2110,6 @@ void ScDocument::CopyToDocument(const ScRange& rRange,
 
     sc::AutoCalcSwitch aACSwitch(rDestDoc, false); // avoid multiple calculations
 
-    // tdf#102364 - in some pathological cases CopyToDocument() replacing cells with new cells
-    // can lead to repetitive splitting and rejoining of the same formula group, which can get
-    // quadratically expensive with large groups. So do the grouping just once at the end.
-    sc::DelayFormulaGroupingSwitch delayGrouping( rDestDoc, true );
-
     sc::CopyToDocContext aCxt(rDestDoc);
     aCxt.setStartListening(false);
 
@@ -2132,7 +2127,6 @@ void ScDocument::CopyToDocument(const ScRange& rRange,
             /*bGlobalNamesToLocal*/false, /*bCopyCaptions*/true);
     }
 
-    delayGrouping.reset(); // groups need to be updated before setting up listeners
     rDestDoc.StartAllListeners(aNewRange);
 }
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 27127d42d08a..2aee672f8ad2 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1128,6 +1128,10 @@ void ScTable::CopyToTable(
     {
         InsertDeleteFlags nTempFlags( nFlags &
                 ~InsertDeleteFlags( InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES));
+        // tdf#102364 - in some pathological cases CopyToTable() replacing cells with new cells
+        // can lead to repetitive splitting and rejoining of the same formula group, which can get
+        // quadratically expensive with large groups. So do the grouping just once at the end.
+        sc::DelayFormulaGroupingSwitch delayGrouping( *pDestTab->pDocument, true );
         for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++)
             aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bIsUndoDoc ? nFlags : nTempFlags, bMarked,
                                  pDestTab->CreateColumnIfNotExists(i), pMarkData, bAsLink, bGlobalNamesToLocal);


More information about the Libreoffice-commits mailing list