summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-24 10:51:30 -0400
committerEike Rathke <erack@redhat.com>2013-07-24 15:30:28 +0000
commitf446ad2e2fdfaadafdd74b395a6dd252a17a4015 (patch)
tree06129570f26c0a6180d2987f73e0e2313b2ba0af
parent143ed4754f77e634954c662ab3972b24bd2d5d52 (diff)
fdo#67206: Don't forget to swap the broadcaster storage when swapping columns.
And a new unit test case to catch this in the future. Change-Id: Ife7d0579849a769c23ace8bfd86a39892253a121 Reviewed-on: https://gerrit.libreoffice.org/5070 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/qa/unit/ucalc.cxx52
-rw-r--r--sc/source/core/data/column.cxx1
2 files changed, 45 insertions, 8 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3f306d08dcbe..93d8dd56c240 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2072,15 +2072,17 @@ void Test::testCellBroadcaster()
// Clear everything again
clearRange(m_pDoc, ScRange(0,0,0,10,100,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]");
+ // 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]");
+ }
}
// Ensure that the formula cells show correct values, and the referenced
@@ -2104,6 +2106,40 @@ void Test::testCellBroadcaster()
CPPUNIT_ASSERT_MESSAGE("Broadcaster should have been deleted.", !pBC);
}
+ // Clear everything again
+ clearRange(m_pDoc, ScRange(0,0,0,10,100,0));
+
+ m_pDoc->SetValue(ScAddress(0,0,0), 2.0);
+ m_pDoc->SetString(ScAddress(1,0,0), "=A1");
+ m_pDoc->SetString(ScAddress(2,0,0), "=B1");
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1,0,0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2,0,0));
+
+ pBC = m_pDoc->GetBroadcaster(ScAddress(0,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+ pBC = m_pDoc->GetBroadcaster(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+
+ // Change the value of A1 and make sure everyone follows suit.
+ m_pDoc->SetValue(ScAddress(0,0,0), 3.5);
+ CPPUNIT_ASSERT_EQUAL(3.5, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(3.5, m_pDoc->GetValue(1,0,0));
+ CPPUNIT_ASSERT_EQUAL(3.5, m_pDoc->GetValue(2,0,0));
+
+ // Insert a column at column B.
+ m_pDoc->InsertCol(ScRange(1,0,0,1,MAXROW,0));
+ pBC = m_pDoc->GetBroadcaster(ScAddress(0,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+ pBC = m_pDoc->GetBroadcaster(ScAddress(2,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+
+ // Change the value of A1 again.
+ m_pDoc->SetValue(ScAddress(0,0,0), 5.5);
+ CPPUNIT_ASSERT_EQUAL(5.5, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(5.5, m_pDoc->GetValue(2,0,0));
+ CPPUNIT_ASSERT_EQUAL(5.5, m_pDoc->GetValue(3,0,0));
+
m_pDoc->DeleteTab(0);
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 878255296911..88cb65dcd8d6 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1613,6 +1613,7 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const
void ScColumn::SwapCol(ScColumn& rCol)
{
+ maBroadcasters.swap(rCol.maBroadcasters);
maItems.swap(rCol.maItems);
maCellTextAttrs.swap(rCol.maCellTextAttrs);