sc/qa/unit/ucalc_sharedformula.cxx | 18 ++++++++++++++++++ sc/source/core/data/column4.cxx | 35 +++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 16 deletions(-)
New commits: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Apr 11 00:55:10 2014 -0400 fdo#77300: Do the same for the shared formula case as well. Change-Id: I560b0beabe81907e3f85d8845041a9df25d2200d diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 7d87177..ec938d8 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -637,23 +637,26 @@ public: ScFormulaCell* pTop = *rEntry.mpCells; OUString aFormula = pTop->GetHybridFormula(); - // Create a new token array from the hybrid formula string, and - // set it to the group. - ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos); - ScTokenArray* pNewCode = aComp.CompileString(aFormula); - ScFormulaCellGroupRef xGroup = pTop->GetCellGroup(); - assert(xGroup); - xGroup->setCode(pNewCode); - xGroup->compileCode(*mpDoc, pTop->aPos, mpDoc->GetGrammar()); - - // Propagate the new token array to all formula cells in the group. - ScFormulaCell** pp = rEntry.mpCells; - ScFormulaCell** ppEnd = pp + rEntry.mnLength; - for (; pp != ppEnd; ++pp) + if (!aFormula.isEmpty()) { - ScFormulaCell* p = *pp; - p->SyncSharedCode(); - p->SetDirty(); + // Create a new token array from the hybrid formula string, and + // set it to the group. + ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos); + ScTokenArray* pNewCode = aComp.CompileString(aFormula); + ScFormulaCellGroupRef xGroup = pTop->GetCellGroup(); + assert(xGroup); + xGroup->setCode(pNewCode); + xGroup->compileCode(*mpDoc, pTop->aPos, mpDoc->GetGrammar()); + + // Propagate the new token array to all formula cells in the group. + ScFormulaCell** pp = rEntry.mpCells; + ScFormulaCell** ppEnd = pp + rEntry.mnLength; + for (; pp != ppEnd; ++pp) + { + ScFormulaCell* p = *pp; + p->SyncSharedCode(); + p->SetDirty(); + } } } else commit ed9d606306cc66ec89e9a6696494b6cdefd9b208 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Apr 11 00:53:49 2014 -0400 fdo#77300: Add more test to cover the shared formula case. Change-Id: I076cb7b8d5f9b51e7337a512bb86efbabee021a8 diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 603e26e..d482216 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1225,17 +1225,29 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() // Set single formula with no named range to B5. m_pDoc->SetString(ScAddress(1,4,0), "=ROW()"); + // Set shared formula with no named range to B7:B8. + m_pDoc->SetString(ScAddress(1,6,0), "=ROW()"); + m_pDoc->SetString(ScAddress(1,7,0), "=ROW()"); + // B1:B3 should be grouped. ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT(pFC); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength()); + // B7:B8 should be grouped. + pFC = m_pDoc->GetFormulaCell(ScAddress(1,6,0)); + CPPUNIT_ASSERT(pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength()); + CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,0,0))); 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))); + CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(ScAddress(1,6,0))); + CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(1,7,0))); // Set a single formula to C1. m_pDoc->SetString(ScAddress(2,0,0), "=AVERAGE(MyRange)"); @@ -1267,6 +1279,10 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() CPPUNIT_FAIL("Wrong formula!"); if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()")) CPPUNIT_FAIL("Wrong formula!"); + if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "ROW()")) + CPPUNIT_FAIL("Wrong formula!"); + if (!checkFormula(*m_pDoc, ScAddress(1,7,0), "ROW()")) + CPPUNIT_FAIL("Wrong formula!"); if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)")) CPPUNIT_FAIL("Wrong formula!"); @@ -1275,6 +1291,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() 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(7.0, m_pDoc->GetValue(ScAddress(1,6,0))); + CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(1,7,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