sc/inc/column.hxx    |    1 +
 sc/qa/unit/ucalc.cxx |   36 ++++++++++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)

New commits:
commit 33f20f466af9c2a73f9048d64a3516f1602198ba
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Tue May 14 14:20:08 2013 -0400

    Unit test for range deletion of broadcasters.
    
    Change-Id: I615c9f9e95a44149c8079754e9aa6497f34c76cf

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9ee830b..b7539c6 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -39,6 +39,7 @@
 #ifdef NDEBUG
 #undef NDEBUG
 #endif
+#define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
 #endif
 
 #include <mdds/multi_type_vector.hpp>
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3e881c9..d051908 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1776,13 +1776,37 @@ void Test::testCellBroadcaster()
     // Clear everything again
     clearRange(m_pDoc, ScRange(0,0,0,10,100,0));
 
-    m_pDoc->SetString(ScAddress(1,0,0), "=A1"); // B1 references A1.
-    m_pDoc->SetValue(ScAddress(0,0,0), 12.3);
-    CPPUNIT_ASSERT_EQUAL(12.3, m_pDoc->GetValue(ScAddress(1,0,0)));
+    // Switch to R1C1 to make it easier to input relative references in 
multiple cells.
+    FormulaGrammarSwitch aFGSwitch(m_pDoc, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+    // Have B1:B20 reference A1:A20.
+    val = 0.0;
+    for (SCROW i = 0; i < 20; ++i)
+    {
+        m_pDoc->SetValue(ScAddress(0,i,0), val++);
+        m_pDoc->SetString(ScAddress(1,i,0), "=RC[-1]");
+    }
 
-    // Clear the entire column A.
-    clearRange(m_pDoc, ScRange(0,0,0,0,MAXROW,0));
-    CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+    // Ensure that the formula cells show correct values, and the referenced
+    // cells have broadcasters.
+    val = 0.0;
+    for (SCROW i = 0; i < 20; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(val++, m_pDoc->GetValue(ScAddress(1,i,0)));
+        pBC = m_pDoc->GetBroadcaster(ScAddress(0,i,0));
+        CPPUNIT_ASSERT_MESSAGE("Broadcast should exist here.", pBC);
+    }
+
+    // Delete formula cells in B2:B19.
+    clearRange(m_pDoc, ScRange(1,1,0,1,18,0));
+    // Ensure that A2:A19 no longer have broadcasters, but A1 and A20 still do.
+    CPPUNIT_ASSERT_MESSAGE("A1 should still have broadcaster.", 
m_pDoc->GetBroadcaster(ScAddress(0,0,0)));
+    CPPUNIT_ASSERT_MESSAGE("A20 should still have broadcaster.", 
m_pDoc->GetBroadcaster(ScAddress(0,19,0)));
+    for (SCROW i = 1; i <= 18; ++i)
+    {
+        pBC = m_pDoc->GetBroadcaster(ScAddress(0,i,0));
+        CPPUNIT_ASSERT_MESSAGE("Broadcaster should have been deleted.", !pBC);
+    }
 
     m_pDoc->DeleteTab(0);
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to