sc/qa/unit/ucalc.hxx | 2 + sc/qa/unit/ucalc_formula.cxx | 37 +++++++++++++++++++++ sc/source/core/data/document.cxx | 67 ++++++++++++++++++++------------------- 3 files changed, 75 insertions(+), 31 deletions(-)
New commits: commit d638ba896f4d52c06a5c452c6a56904a3c6429bb Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jul 23 16:49:35 2013 -0400 Broadcast on recalc-ref-on-move cells for the other 3 directions. Change-Id: I7794bd51c5fedb6c6c75f6910b7743df96d156c3 diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 9cba374..f32fcd5 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1122,6 +1122,36 @@ bool ScDocument::CanInsertRow( const ScRange& rRange ) const return bTest; } +namespace { + +struct StartNeededListenersHandler : std::unary_function<ScTable*, void> +{ + void operator() (ScTable* p) + { + if (p) + p->StartNeededListeners(); + } +}; + +struct SetRelNameDirtyHandler : std::unary_function<ScTable*, void> +{ + void operator() (ScTable* p) + { + if (p) + p->SetRelNameDirty(); + } +}; + +struct BroadcastRecalcOnRefMoveHandler : std::unary_function<ScTable*, void> +{ + void operator() (ScTable* p) + { + if (p) + p->BroadcastRecalcOnRefMove(); + } +}; + +} bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, SCCOL nEndCol, SCTAB nEndTab, @@ -1204,6 +1234,8 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, for (; it != maTabs.end(); ++it) if (*it) (*it)->SetRelNameDirty(); + + std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler()); } bRet = true; } @@ -1297,6 +1329,8 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab, for (; it != maTabs.end(); ++it) if (*it) (*it)->SetRelNameDirty(); + + std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler()); } SetAutoCalc( bOldAutoCalc ); @@ -1334,37 +1368,6 @@ bool ScDocument::CanInsertCol( const ScRange& rRange ) const return bTest; } -namespace { - -struct StartNeededListenersHandler : std::unary_function<ScTable*, void> -{ - void operator() (ScTable* p) - { - if (p) - p->StartNeededListeners(); - } -}; - -struct SetRelNameDirtyHandler : std::unary_function<ScTable*, void> -{ - void operator() (ScTable* p) - { - if (p) - p->SetRelNameDirty(); - } -}; - -struct BroadcastRecalcOnRefMoveHandler : std::unary_function<ScTable*, void> -{ - void operator() (ScTable* p) - { - if (p) - p->BroadcastRecalcOnRefMove(); - } -}; - -} - bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTAB nEndTab, SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc, @@ -1524,6 +1527,8 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA for (; it != maTabs.end(); ++it) if (*it) (*it)->SetRelNameDirty(); + + std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler()); } SetAutoCalc( bOldAutoCalc ); commit 8edaa54f681a58f7266748437fa3c62dec8873cb Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jul 23 16:48:56 2013 -0400 Add test for ROW function. Change-Id: Ie918d3b9d635febe40ac974a37da0743830b65eb diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 71a3268..ac17bd9 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -90,6 +90,7 @@ public: void testFormulaRefUpdateRange(); void testFormulaRefUpdateSheets(); void testFuncCOLUMN(); + void testFuncROW(); void testFuncSUM(); void testFuncPRODUCT(); void testFuncN(); @@ -280,6 +281,7 @@ public: CPPUNIT_TEST(testFormulaRefUpdateRange); CPPUNIT_TEST(testFormulaRefUpdateSheets); CPPUNIT_TEST(testFuncCOLUMN); + CPPUNIT_TEST(testFuncROW); CPPUNIT_TEST(testFuncSUM); CPPUNIT_TEST(testFuncPRODUCT); CPPUNIT_TEST(testFuncN); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 0aee2eb..c651b6d 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -855,6 +855,43 @@ void Test::testFuncCOLUMN() // The cell that references the moved cell should update its value as well. CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(ScAddress(0,1,0))); + // Move the column in the other direction. + m_pDoc->DeleteCol(ScRange(5,0,0,5,MAXROW,0)); + + CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(5,10,0))); + + // The cell that references the moved cell should update its value as well. + CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + m_pDoc->DeleteTab(0); +} + +void Test::testFuncROW() +{ + m_pDoc->InsertTab(0, "Formula"); + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + + m_pDoc->SetString(ScAddress(5,10,0), "=ROW()"); + CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(5,10,0))); + + m_pDoc->SetString(ScAddress(0,1,0), "=F11"); + CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Insert 2 new rows at row 4. + m_pDoc->InsertRow(ScRange(0,3,0,MAXCOL,4,0)); + CPPUNIT_ASSERT_EQUAL(13.0, m_pDoc->GetValue(ScAddress(5,12,0))); + + // The cell that references the moved cell should update its value as well. + CPPUNIT_ASSERT_EQUAL(13.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Delete 2 rows to move it back. + m_pDoc->DeleteRow(ScRange(0,3,0,MAXCOL,4,0)); + + CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(5,10,0))); + + // The cell that references the moved cell should update its value as well. + CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(0,1,0))); + m_pDoc->DeleteTab(0); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits