diff options
author | Eike Rathke <erack@redhat.com> | 2017-11-02 16:59:36 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-11-02 17:17:00 +0100 |
commit | 782f34ae2f214674fc871ece348ba5dd11c4a8d6 (patch) | |
tree | 9adf64e2e48945afad6e1daf501fb1063d540b9a | |
parent | c1917f4cb8ea5e781fe14b0be4c2e2b7e6e65bc2 (diff) |
Unit test for CellStoreEvent::swap() in ScColumn::SwapCol(), tdf#111428
Change-Id: Iaba95e2cfb6b34ab3ad04f96dd2c8e2c12115d95
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 9dae67cc9aa6..ed8bf0c09e0e 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -538,6 +538,7 @@ public: void testProtectedSheetEditByRow(); void testProtectedSheetEditByColumn(); void testFuncRowsHidden(); + void testInsertColCellStoreEventSwap(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testCollator); @@ -816,6 +817,7 @@ public: CPPUNIT_TEST(testProtectedSheetEditByRow); CPPUNIT_TEST(testProtectedSheetEditByColumn); CPPUNIT_TEST(testFuncRowsHidden); + CPPUNIT_TEST(testInsertColCellStoreEventSwap); CPPUNIT_TEST_SUITE_END(); private: diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 3dbeba873d81..22d76cac6c1c 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -8394,4 +8394,32 @@ void Test::testIterations() m_pDoc->SetDocOptions( aDocOpts ); } +// tdf#111428 CellStoreEvent and its counter used for quick "has a column +// formula cells" must point to the correct column. +void Test::testInsertColCellStoreEventSwap() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + m_pDoc->InsertTab(0, "Test"); + + m_pDoc->SetValue( 0,0,0, 1.0 ); // A1 + m_pDoc->SetString( 1,0,0, "=A1" ); // B1 + // Insert column left of B + m_pDoc->InsertCol( ScRange(1,0,0, 1,MAXROW,0)); + ScAddress aPos(2,0,0); // C1, new formula postion + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Should be formula cell having value", 1.0, m_pDoc->GetValue(aPos)); + // After having swapped in an empty column, editing or adding a formula + // cell has to use the correct store context. To test this, + // ScDocument::SetString() can't be used as it doesn't expose the behavior + // in question, use ScDocFunc::SetFormulaCell() instead which actually is + // also called when editing a cell and creating a formula cell. + ScFormulaCell* pCell = new ScFormulaCell( m_pDoc, aPos, "=A1+1"); + ScDocFunc& rDocFunc = getDocShell().GetDocFunc(); + rDocFunc.SetFormulaCell( aPos, pCell, false); // C1, change formula + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Initial calculation failed", 2.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue( 0,0,0, 2.0 ); // A1, change value + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Recalculation failed", 3.0, m_pDoc->GetValue(aPos)); + + m_pDoc->DeleteTab(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |