diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-01-26 23:48:12 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-01-27 09:58:00 -0500 |
commit | 86ec0c8201d89d472cd8b826c5265eccab62b96e (patch) | |
tree | 92b6eb6ecf0ca76b35682ac9a8a6e862bc8b4be4 /sc | |
parent | 452d86c9cbfb6b4b7e86426931a0d982dd8bb180 (diff) |
Unit test for updating formula cells that references into the pivot table.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index e83f50033548..a7bfe2cef5b4 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1259,6 +1259,22 @@ ScDPObject* createDPFromRange( return createDPFromSourceDesc(pDoc, aSheetDesc, aFields, nFieldCount, bFilterButton); } +class AutoCalcSwitch +{ + ScDocument* mpDoc; + bool mbOldValue; +public: + AutoCalcSwitch(ScDocument* pDoc, bool bAutoCalc) : mpDoc(pDoc), mbOldValue(pDoc->GetAutoCalc()) + { + mpDoc->SetAutoCalc(bAutoCalc); + } + + ~AutoCalcSwitch() + { + mpDoc->SetAutoCalc(mbOldValue); + } +}; + } void Test::testPivotTable() @@ -1655,6 +1671,15 @@ void Test::testPivotTableFilters() CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); } + AutoCalcSwitch aACSwitch(m_pDoc, true); // turn on auto calculation. + + ScAddress aFormulaAddr = aOutRange.aEnd; + aFormulaAddr.IncRow(2); + m_pDoc->SetString(aFormulaAddr.Col(), aFormulaAddr.Row(), aFormulaAddr.Tab(), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=B8"))); + double fTest = m_pDoc->GetValue(aFormulaAddr); + CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 80.0); + // Set current page of 'Group2' to 'A'. ScDPSaveData aSaveData(*pDPObj->GetSaveData()); ScDPSaveDimension* pDim = aSaveData.GetDimensionByName( @@ -1682,6 +1707,9 @@ void Test::testPivotTableFilters() CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); } + fTest = m_pDoc->GetValue(aFormulaAddr); + CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 40.0); + // Set query filter. ScSheetSourceDesc aDesc(*pDPObj->GetSheetDesc()); ScQueryParam aQueryParam(aDesc.GetQueryParam()); @@ -1711,6 +1739,9 @@ void Test::testPivotTableFilters() CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); } + fTest = m_pDoc->GetValue(aFormulaAddr); + CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 20.0); + pDPs->FreeTable(pDPObj); CPPUNIT_ASSERT_MESSAGE("There shouldn't be any data pilot table stored with the document.", pDPs->GetCount() == 0); |