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 470d96d4e0becff7d1cd23365d94e459086c0675 Author: Kohei Yoshida <[email protected]> Date: Thu Dec 11 20:54:12 2014 -0500 fdo#86572: Write test for this. Change-Id: I00c3eaac473f0464e923e785cc50ad6769c78d41 (cherry picked from commit 170616e9f2d30c1302bbb5a7a4b588bc05cd5cc9) diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 72ecaa0..8f6c7d3 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -325,6 +325,7 @@ public: void testSharedFormulaMoveBlock(); void testSharedFormulaUpdateOnNamedRangeChange(); void testSharedFormulaUpdateOnDBChange(); + void testSharedFormulaAbsCellListener(); void testFormulaPosition(); void testMixData(); @@ -557,6 +558,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 2ef7d88..a88ec21 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1605,4 +1605,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 38e2a276859792f0b7f5d1667555217b3b451544 Author: Kohei Yoshida <[email protected]> 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 (cherry picked from commit 52781a55441cb270ffecc2522d1e069141a21607) 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 [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
