sc/qa/unit/ucalc.hxx | 2 + sc/qa/unit/ucalc_sharedformula.cxx | 36 ++++++++++++++++++++++++++++++++++ sc/source/core/tool/sharedformula.cxx | 7 ++++-- 3 files changed, 43 insertions(+), 2 deletions(-)
New commits: commit 170616e9f2d30c1302bbb5a7a4b588bc05cd5cc9 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Dec 11 20:54:12 2014 -0500 fdo#86572: Write test for this. Change-Id: I00c3eaac473f0464e923e785cc50ad6769c78d41 diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index b233274..0c39d6f 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -327,6 +327,7 @@ public: void testSharedFormulaMoveBlock(); void testSharedFormulaUpdateOnNamedRangeChange(); void testSharedFormulaUpdateOnDBChange(); + void testSharedFormulaAbsCellListener(); void testFormulaPosition(); void testMixData(); @@ -563,6 +564,7 @@ public: CPPUNIT_TEST(testSharedFormulaInsertColumn); CPPUNIT_TEST(testSharedFormulaUpdateOnNamedRangeChange); CPPUNIT_TEST(testSharedFormulaUpdateOnDBChange); + CPPUNIT_TEST(testSharedFormulaAbsCellListener); CPPUNIT_TEST(testFormulaPosition); CPPUNIT_TEST(testMixData); CPPUNIT_TEST(testJumpToPrecedentsDependents); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 677f4ff..aa1d778 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1656,4 +1656,40 @@ void Test::testSharedFormulaUpdateOnDBChange() m_pDoc->DeleteTab(0); } +void Test::testSharedFormulaAbsCellListener() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc. + + m_pDoc->InsertTab(0, "Test"); + + m_pDoc->SetValue(ScAddress(0,0,0), 1.0); + + const char* pData[][1] = { + { "=$A$1" }, + { "=$A$1" }, + { "=$A$1" } + }; + + insertRangeData(m_pDoc, ScAddress(1,0,0), pData, SAL_N_ELEMENTS(pData)); + + // A1 should have 3 listeners listening into it. + const SvtBroadcaster* pBC = m_pDoc->GetBroadcaster(ScAddress(0,0,0)); + CPPUNIT_ASSERT(pBC); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pBC->GetAllListeners().size()); + + // Check the formula results. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,1,0))); + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,2,0))); + + // Change the value of A1 and make sure B1:B3 follows. + m_pDoc->SetValue(ScAddress(0,0,0), 2.5); + + CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc->GetValue(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc->GetValue(ScAddress(1,1,0))); + CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc->GetValue(ScAddress(1,2,0))); + + m_pDoc->DeleteTab(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 52781a55441cb270ffecc2522d1e069141a21607 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Dec 11 20:52:53 2014 -0500 fdo#86572: Increment row position *only when* the row ref is relative. This is just a simple oversight. Change-Id: I024777c46641cce3410a20f40c48f47ad6a5dade diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 67a40c2..b1cd80d 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -362,15 +362,18 @@ void SharedFormulaUtil::startListeningAsGroup( sc::StartListeningContext& rCxt, { case formula::svSingleRef: { - ScAddress aPos = t->GetSingleRef()->toAbs(rTopCell.aPos); + const ScSingleRefData* pRef = t->GetSingleRef(); + ScAddress aPos = pRef->toAbs(rTopCell.aPos); ScFormulaCell** pp = ppSharedTop; ScFormulaCell** ppEnd = ppSharedTop + xGroup->mnLength; - for (; pp != ppEnd; ++pp, aPos.IncRow()) + for (; pp != ppEnd; ++pp) { if (!aPos.IsValid()) break; rDoc.StartListeningCell(rCxt, aPos, **pp); + if (pRef->IsRowRel()) + aPos.IncRow(); } } break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits