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

Eike Rathke erack at redhat.com
Tue Jul 7 14:47:31 PDT 2015


 sc/source/core/data/document.cxx |   63 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

New commits:
commit a49b8af4cf03ae08cb7a28f66e24368a7b08ae3f
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Jul 7 23:36:02 2015 +0200

    end/restart group listening in DeleteSelection(), similar to DeleteArea()
    
    Reproducer:
    * in A1 enter =SUM(B1:C4)
    * copy A1 to clipboard
    * paste to A2 and A3
    * formula in A2 is =SUM(B2:C5)  A3 is =SUM(B3:C6)
    * select A2:A3
    * hit Del key to delete the two cells
    * enter any numeric value in B2
      => formula result in A1 is not updated
      Shift+Ctrl+F9 hard recalc updates
    
    Change-Id: I55e55b8cfe69e9273170ceaea4e6c046b3d4f7b7

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9abc1af..c8e9a0e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5647,18 +5647,81 @@ void ScDocument::ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData
 
 void ScDocument::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast )
 {
+    sc::AutoCalcSwitch aACSwitch(*this, false);
+
+    std::vector<ScAddress> aGroupPos;
+    // Destroy and reconstruct listeners only if content is affected.
+    bool bDelContent = ((nDelFlag & ~IDF_CONTENTS) != nDelFlag);
+    if (bDelContent)
+    {
+        // Record the positions of top and/or bottom formula groups that
+        // intersect the area borders.
+        sc::EndListeningContext aCxt(*this);
+        ScRangeList aRangeList;
+        rMark.FillRangeListWithMarks( &aRangeList, false);
+        for (size_t i = 0; i < aRangeList.size(); ++i)
+        {
+            const ScRange* pRange = aRangeList[i];
+            if (pRange)
+                EndListeningIntersectedGroups( aCxt, *pRange, &aGroupPos);
+        }
+        aCxt.purgeEmptyBroadcasters();
+    }
+
     SCTAB nMax = static_cast<SCTAB>(maTabs.size());
     ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
     for (; itr != itrEnd && *itr < nMax; ++itr)
         if (maTabs[*itr])
             maTabs[*itr]->DeleteSelection(nDelFlag, rMark, bBroadcast);
+
+    if (bDelContent)
+    {
+        // Re-start listeners on those top bottom groups that have been split.
+        SetNeedsListeningGroups(aGroupPos);
+        StartNeededListeners();
+    }
 }
 
 void ScDocument::DeleteSelectionTab(
     SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast )
 {
     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
+    {
+        sc::AutoCalcSwitch aACSwitch(*this, false);
+
+        std::vector<ScAddress> aGroupPos;
+        // Destroy and reconstruct listeners only if content is affected.
+        bool bDelContent = ((nDelFlag & ~IDF_CONTENTS) != nDelFlag);
+        if (bDelContent)
+        {
+            // Record the positions of top and/or bottom formula groups that
+            // intersect the area borders.
+            sc::EndListeningContext aCxt(*this);
+            ScRangeList aRangeList;
+            rMark.FillRangeListWithMarks( &aRangeList, false);
+            for (size_t i = 0; i < aRangeList.size(); ++i)
+            {
+                const ScRange* pRange = aRangeList[i];
+                if (pRange && pRange->aStart.Tab() <= nTab && nTab <= pRange->aEnd.Tab())
+                {
+                    ScRange aRange( *pRange);
+                    aRange.aStart.SetTab( nTab);
+                    aRange.aEnd.SetTab( nTab);
+                    EndListeningIntersectedGroups( aCxt, aRange, &aGroupPos);
+                }
+            }
+            aCxt.purgeEmptyBroadcasters();
+        }
+
         maTabs[nTab]->DeleteSelection(nDelFlag, rMark, bBroadcast);
+
+        if (bDelContent)
+        {
+            // Re-start listeners on those top bottom groups that have been split.
+            SetNeedsListeningGroups(aGroupPos);
+            StartNeededListeners();
+        }
+    }
     else
     {
         OSL_FAIL("wrong table");


More information about the Libreoffice-commits mailing list