sc/qa/unit/ucalc_sharedformula.cxx | 8 ++++++++ sc/source/core/data/column4.cxx | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-)
New commits: commit 66c6a3bfc9cd89c562107d3d369b3d82bae94d68 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Apr 11 00:43:18 2014 -0400 fdo#77300: Don't re-compile formulas when the hybrid formula is not there. Change-Id: I9b0f8d031fec08bb8d92333ff67074fdc739e034 diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index c658124..7d87177 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -661,16 +661,19 @@ public: ScFormulaCell* pCell = rEntry.mpCell; OUString aFormula = pCell->GetHybridFormula(); - // Create token array from formula string. - ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos); - ScTokenArray* pNewCode = aComp.CompileString(aFormula); + if (!aFormula.isEmpty()) + { + // Create token array from formula string. + ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos); + ScTokenArray* pNewCode = aComp.CompileString(aFormula); - // Generate RPN tokens. - ScCompiler aComp2(mpDoc, pCell->aPos, *pNewCode); - aComp2.CompileTokenArray(); + // Generate RPN tokens. + ScCompiler aComp2(mpDoc, pCell->aPos, *pNewCode); + aComp2.CompileTokenArray(); - pCell->SetCode(pNewCode); - pCell->SetDirty(); + pCell->SetCode(pNewCode); + pCell->SetDirty(); + } } } }; commit bdc8d5f9e712fce35098352b8c1d9028f4095d8c Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Apr 11 00:34:37 2014 -0400 fdo#77300: Add test for this. Change-Id: Ib870d8f115b074a4ad80ee6910f92ba8d4b0c01e diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index acb249a..603e26e 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1222,6 +1222,9 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() m_pDoc->SetString(ScAddress(1,1,0), "=SUM(MyRange)"); m_pDoc->SetString(ScAddress(1,2,0), "=SUM(MyRange)"); + // Set single formula with no named range to B5. + m_pDoc->SetString(ScAddress(1,4,0), "=ROW()"); + // B1:B3 should be grouped. ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT(pFC); @@ -1232,6 +1235,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,1,0))); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,2,0))); + CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,4,0))); + // Set a single formula to C1. m_pDoc->SetString(ScAddress(2,0,0), "=AVERAGE(MyRange)"); pFC = m_pDoc->GetFormulaCell(ScAddress(2,0,0)); @@ -1260,6 +1265,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() CPPUNIT_FAIL("Wrong formula!"); if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(MyRange)")) CPPUNIT_FAIL("Wrong formula!"); + if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()")) + CPPUNIT_FAIL("Wrong formula!"); if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)")) CPPUNIT_FAIL("Wrong formula!"); @@ -1267,6 +1274,7 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,0,0))); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,1,0))); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,2,0))); + CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,4,0))); CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc->GetValue(ScAddress(2,0,0))); m_pDoc->DeleteTab(0); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits