[Libreoffice-commits] core.git: Branch 'feature/perfwork5' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Nov 21 08:59:33 PST 2014


 sc/inc/document.hxx                |    1 
 sc/source/core/data/document.cxx   |   39 ++++++++++++++++++++-----------------
 sc/source/core/data/document10.cxx |   22 ++++++++++++++++++++
 3 files changed, 45 insertions(+), 17 deletions(-)

New commits:
commit 15bf6a424836cc1acb927371047ec65807e59039
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 21 11:57:23 2014 -0500

    Handle group area listeners correctly when deleting cells.
    
    Change-Id: Ic37084ed670f53e0354056f7bef54229971dd7c2

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e746d1d..acf0f67 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1914,6 +1914,7 @@ public:
     bool                GetHardRecalcState() { return bHardRecalcState; }
     void                SetHardRecalcState( bool bVal ) { bHardRecalcState = bVal; }
     void                StartAllListeners();
+    void StartNeededListeners();
     const ScFormulaCell*    GetFormulaTree() const { return pFormulaTree; }
     bool                HasForcedFormulas() const { return bHasForcedFormulas; }
     void                SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 4fb535d..4e3fd9d 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1154,19 +1154,6 @@ bool ScDocument::CanInsertRow( const ScRange& rRange ) const
 
 namespace {
 
-class StartNeededListenersHandler : std::unary_function<ScTable*, void>
-{
-    boost::shared_ptr<sc::StartListeningContext> mpCxt;
-public:
-    StartNeededListenersHandler( ScDocument& rDoc ) : mpCxt(new sc::StartListeningContext(rDoc)) {}
-
-    void operator() (ScTable* p)
-    {
-        if (p)
-            p->StartListeners(*mpCxt, false);
-    }
-};
-
 struct SetDirtyIfPostponedHandler : std::unary_function<ScTable*, void>
 {
     void operator() (ScTable* p)
@@ -1276,7 +1263,7 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab,
         }
         else
         {   // Listeners have been removed in UpdateReference
-            std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+            StartNeededListeners();
 
             // At least all cells using range names pointing relative to the
             // moved range must be recalculated, and all cells marked postponed
@@ -1369,7 +1356,7 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
     if ( ValidRow(nStartRow+nSize) )
     {
         // Listeners have been removed in UpdateReference
-        std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+        StartNeededListeners();
 
         // At least all cells using range names pointing relative to the moved
         // range must be recalculated, and all cells marked postponed dirty.
@@ -1475,7 +1462,7 @@ bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
         else
         {
             // Listeners have been removed in UpdateReference
-            std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+            StartNeededListeners();
             // At least all cells using range names pointing relative to the
             // moved range must be recalculated, and all cells marked postponed
             // dirty.
@@ -1564,7 +1551,7 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA
     if ( ValidCol(sal::static_int_cast<SCCOL>(nStartCol+nSize)) )
     {
         // Listeners have been removed in UpdateReference
-        std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+        StartNeededListeners();
 
         // At least all cells using range names pointing relative to the moved
         // range must be recalculated, and all cells marked postponed dirty.
@@ -1777,11 +1764,29 @@ void ScDocument::DeleteArea(
 
     PutInOrder( nCol1, nCol2 );
     PutInOrder( nRow1, nRow2 );
+
+    // Record the positions of top and/or bottom formula groups that intersect
+    // the area borders.
+    std::vector<ScAddress> aGroupPos;
+    sc::EndListeningContext aCxt(*this);
+    ScRange aRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
+    for (size_t i = 0; i < maTabs.size(); ++i)
+    {
+        aRange.aStart.SetTab(i);
+        aRange.aEnd.SetTab(i);
+
+        EndListeningIntersectedGroups(aCxt, aRange, &aGroupPos);
+    }
+    aCxt.purgeEmptyBroadcasters();
+
     for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
         if (maTabs[i])
             if ( rMark.GetTableSelect(i) || bIsUndo )
                 maTabs[i]->DeleteArea(nCol1, nRow1, nCol2, nRow2, nDelFlag, bBroadcast, pBroadcastSpans);
 
+    // Re-start listeners on those top bottom groups that have been split.
+    SetNeedsListeningGroups(aGroupPos);
+    StartNeededListeners();
 }
 
 void ScDocument::DeleteAreaTab(SCCOL nCol1, SCROW nRow1,
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index c426a19..48e933c 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -384,4 +384,26 @@ void ScDocument::SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArra
     }
 }
 
+namespace {
+
+class StartNeededListenersHandler : std::unary_function<ScTable*, void>
+{
+    boost::shared_ptr<sc::StartListeningContext> mpCxt;
+public:
+    StartNeededListenersHandler( ScDocument& rDoc ) : mpCxt(new sc::StartListeningContext(rDoc)) {}
+
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->StartListeners(*mpCxt, false);
+    }
+};
+
+}
+
+void ScDocument::StartNeededListeners()
+{
+    std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list