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

Kohei Yoshida kohei.yoshida at collabora.com
Fri Oct 17 18:56:56 PDT 2014


 sc/qa/unit/ucalc.hxx           |    3 +
 sc/qa/unit/ucalc_formula.cxx   |  114 +++++++++++++++++++++++++++++++++++++++++
 sc/source/core/data/table2.cxx |    7 --
 3 files changed, 119 insertions(+), 5 deletions(-)

New commits:
commit 7fef943114b9184e69c8c714bf158116b8d9caf7
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Oct 17 21:48:31 2014 -0400

    fdo#80284: Avoid broadcasting during cell delete & shift.
    
    Broadcasting it here and marking formula cells dirty prevents them
    from being entered into the formula tree at the end.  They get marked
    "postponed dirty" during reference update, and are supposed to be
    set dirty at the end.
    
    Change-Id: I65977300ee4ee26b6166d170acd2145abcbbf288

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2aa91d0..fdbc463 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -383,11 +383,8 @@ void ScTable::DeleteCol(
         }
     }
 
-    {   // scope for bulk broadcast
-        ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
-        for (SCSIZE i = 0; i < nSize; i++)
-            aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, IDF_ALL);
-    }
+    for (SCSIZE i = 0; i < nSize; i++)
+        aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, IDF_ALL, false);
 
     if ((nStartRow == 0) && (nEndRow == MAXROW))
     {
commit f961771e31be34065d210574866c6811fc0288fd
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Oct 17 19:50:26 2014 -0400

    fdo#80284: Write test for this first.
    
    Change-Id: I2fe455fc627e4b358507b58f08a3198ac62edad0

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d7f85f0..0053646 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -184,6 +184,8 @@ public:
 
     void testFormulaDepTrackingDeleteRow();
 
+    void testFormulaDepTrackingDeleteCol();
+
     void testFormulaMatrixResultUpdate();
 
     /**
@@ -461,6 +463,7 @@ public:
     CPPUNIT_TEST(testFormulaDepTracking);
     CPPUNIT_TEST(testFormulaDepTracking2);
     CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
+    CPPUNIT_TEST(testFormulaDepTrackingDeleteCol);
     CPPUNIT_TEST(testFormulaMatrixResultUpdate);
     CPPUNIT_TEST(testCellBroadcaster);
     CPPUNIT_TEST(testFuncParam);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 713abe3..84d34e0 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -4001,6 +4001,120 @@ void Test::testFormulaDepTrackingDeleteRow()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaDepTrackingDeleteCol()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+    m_pDoc->InsertTab(0, "Formula");
+
+    const char* aData[][3] = {
+        { "2", "=A1", "=B1" }, // not grouped
+        { 0, 0, 0 },           // empty row to separate the formula groups.
+        { "3", "=A3", "=B3" }, // grouped
+        { "4", "=A4", "=B4" }, // grouped
+    };
+
+    ScAddress aPos(0,0,0);
+    ScRange aRange = insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
+    CPPUNIT_ASSERT(aRange.aStart == aPos);
+
+    // Check the initial values.
+    for (SCCOL i = 0; i <= 2; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(i,0,0)));
+        CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(i,2,0)));
+        CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(i,3,0)));
+    }
+
+    // Make sure B3:B4 and C3:C4 are grouped.
+    const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,0));
+    CPPUNIT_ASSERT(pFC);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedTopRow());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
+
+    pFC = m_pDoc->GetFormulaCell(ScAddress(2,2,0));
+    CPPUNIT_ASSERT(pFC);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedTopRow());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
+
+    // Delete column A.  A1, B1, A3:A4 and B3:B4 should all show #REF!.
+    ScDocFunc& rFunc = getDocShell().GetDocFunc();
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    rFunc.DeleteCells(ScRange(0,0,0,0,MAXROW,0), &aMark, DEL_CELLSLEFT, true, true);
+
+    {
+        // Expected output table content.  0 = empty cell
+        const char* aOutputCheck[][2] = {
+            { "#REF!", "#REF!" },
+            { 0,  0 },
+            { "#REF!", "#REF!" },
+            { "#REF!", "#REF!" },
+        };
+
+        ScRange aCheckRange(0,0,0,1,3,0);
+        bool bSuccess = checkOutput<2>(m_pDoc, aCheckRange, aOutputCheck, "Check after deleting column A");
+        CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+    }
+
+    // Undo and check the result.
+    SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+    CPPUNIT_ASSERT(pUndoMgr);
+    pUndoMgr->Undo();
+
+    {
+        // Expected output table content.  0 = empty cell
+        const char* aOutputCheck[][3] = {
+            { "2", "2", "2" },
+            { 0,  0, 0 },
+            { "3", "3", "3" },
+            { "4", "4", "4" },
+        };
+
+        ScRange aCheckRange(0,0,0,2,3,0);
+        bool bSuccess = checkOutput<3>(m_pDoc, aCheckRange, aOutputCheck, "Check after undo");
+        CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+    }
+
+    // Redo and check.
+    pUndoMgr->Redo();
+    {
+        // Expected output table content.  0 = empty cell
+        const char* aOutputCheck[][2] = {
+            { "#REF!", "#REF!" },
+            { 0, 0 },
+            { "#REF!", "#REF!" },
+            { "#REF!", "#REF!" },
+        };
+
+        ScRange aCheckRange(0,0,0,1,3,0);
+        bool bSuccess = checkOutput<2>(m_pDoc, aCheckRange, aOutputCheck, "Check after redo");
+        CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+    }
+
+    // Undo and change the values in column A.
+    pUndoMgr->Undo();
+    m_pDoc->SetValue(ScAddress(0,0,0), 22.0);
+    m_pDoc->SetValue(ScAddress(0,2,0), 23.0);
+    m_pDoc->SetValue(ScAddress(0,3,0), 24.0);
+
+    {
+        // Expected output table content.  0 = empty cell
+        const char* aOutputCheck[][3] = {
+            { "22", "22", "22" },
+            { 0, 0, 0 },
+            { "23", "23", "23" },
+            { "24", "24", "24" },
+        };
+
+        ScRange aCheckRange(0,0,0,2,3,0);
+        bool bSuccess = checkOutput<3>(m_pDoc, aCheckRange, aOutputCheck, "Check after undo & value change in column A");
+        CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+    }
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFormulaMatrixResultUpdate()
 {
     m_pDoc->InsertTab(0, "Test");


More information about the Libreoffice-commits mailing list