sc/qa/unit/ucalc.cxx | 28 ++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 3 +++ sc/source/core/tool/token.cxx | 3 +++ 3 files changed, 34 insertions(+)
New commits: commit 9bf907a8278cecd816368db7b8c4ab745a914a59 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Feb 14 20:39:18 2014 -0500 fdo#72691: Allow overwriting of string value with numeric one. This can legitimately happen when you have a matrix with a reference to another cell inside, and the referenced cell originally contained a string value then later overwritten by a numeric value. Example. Put a "Text" in A1, and in B1 put a 1x1 matrix {=A1}. It displays "Text" in B1. Then put 11 in A1. Prior to this change, B1 would become blank. With this change, B1 will display 11. Change-Id: I3feba3a8658e1a5ebf6f9e5ac34de2d579464ddb diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 6bb060b..769b886 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1146,6 +1146,9 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f ) case svDouble: const_cast<FormulaToken*>(xUpperLeft.get())->GetDoubleAsReference() = f; break; + case svString: + xUpperLeft = new FormulaDoubleToken( f); + break; case svUnknown: if (!xUpperLeft) { commit 1ffec457c86df0906b358ac431ffdb5d1d47de8c Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Feb 14 15:15:45 2014 -0500 fdo#72691: Write unit test for this. One tricky bit was that in order to reproduce the bug in the unit test, formula cell's bChanged flag needed to be cleared after each update, because that's what happens when you display updated formula on screen. Each time an updated formula cell gets drawn, the UI code clears this flag. That same flag was used to control the code path during interpretation... Change-Id: I2eedea3c9294f4f545422b8611840c81f8c2304f diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index c06f82d..7176312 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1360,6 +1360,34 @@ void Test::testFormulaDepTracking2() m_pDoc->DeleteTab(0); } +void Test::testFormulaDepTrackingMatrix() +{ + m_pDoc->InsertTab(0, "Test"); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation. + + // Set a numeric value to A1. + m_pDoc->SetValue(ScAddress(0,0,0), 11.0); + + ScMarkData aMark; + aMark.SelectOneTable(0); + m_pDoc->InsertMatrixFormula(1, 0, 1, 0, aMark, "=A1", NULL); + CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0))); + ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); + CPPUNIT_ASSERT_MESSAGE("Failed to get formula cell.", pFC); + pFC->SetChanged(false); // Clear this flag to simulate displaying of formula cell value on screen. + + m_pDoc->SetString(ScAddress(0,0,0), "ABC"); + CPPUNIT_ASSERT_EQUAL(OUString("ABC"), m_pDoc->GetString(ScAddress(1,0,0))); + pFC->SetChanged(false); + + // Put a new value into A1. The formula should update. + m_pDoc->SetValue(ScAddress(0,0,0), 13.0); + CPPUNIT_ASSERT_EQUAL(13.0, m_pDoc->GetValue(ScAddress(1,0,0))); + + m_pDoc->DeleteTab(0); +} + namespace { bool broadcasterShifted(const ScDocument& rDoc, const ScAddress& rFrom, const ScAddress& rTo) diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index f94ac91..9f6dc32 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -150,6 +150,8 @@ public: */ void testFormulaDepTracking2(); + void testFormulaDepTrackingMatrix(); + /** * More direct test for cell broadcaster management, used to track formula * dependencies. @@ -370,6 +372,7 @@ public: CPPUNIT_TEST(testValueIterator); CPPUNIT_TEST(testFormulaDepTracking); CPPUNIT_TEST(testFormulaDepTracking2); + CPPUNIT_TEST(testFormulaDepTrackingMatrix); CPPUNIT_TEST(testCellBroadcaster); CPPUNIT_TEST(testFuncParam); CPPUNIT_TEST(testNamedRange); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits