diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-25 00:42:02 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-25 00:45:43 -0500 |
commit | 1fb5aea16f11c90aaac23486e584a17e0655b621 (patch) | |
tree | e0026f0846c344d3b0c05c01fbe0069b4f35f068 | |
parent | 778a6993b971f13f4008491f54296e57b9026238 (diff) |
Show column/row grand totals only when at least one column/row field exists.
Otherwise the grand total would be just a duplicate of the data field
area.
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/dptabsrc.cxx | 11 |
2 files changed, 13 insertions, 12 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 37a8ee71193a..89bc980ad9fc 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1662,9 +1662,7 @@ void Test::testPivotTableFilters() { 0, 0 }, { "Data", 0 }, { "Sum - Val1", "8" }, - { "Sum - Val2", "80" }, - { "Total Sum - Val1", "8" }, - { "Total Sum - Val2", "80" } + { "Sum - Val2", "80" } }; bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "DataPilot table output (unfiltered)"); @@ -1676,7 +1674,7 @@ void Test::testPivotTableFilters() ScAddress aFormulaAddr = aOutRange.aEnd; aFormulaAddr.IncRow(2); m_pDoc->SetString(aFormulaAddr.Col(), aFormulaAddr.Row(), aFormulaAddr.Tab(), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=B8"))); + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=B6"))); double fTest = m_pDoc->GetValue(aFormulaAddr); CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 80.0); @@ -1698,9 +1696,7 @@ void Test::testPivotTableFilters() { 0, 0 }, { "Data", 0 }, { "Sum - Val1", "4" }, - { "Sum - Val2", "40" }, - { "Total Sum - Val1", "4" }, - { "Total Sum - Val2", "40" } + { "Sum - Val2", "40" } }; bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "DataPilot table output (filtered by page)"); @@ -1730,9 +1726,7 @@ void Test::testPivotTableFilters() { 0, 0 }, { "Data", 0 }, { "Sum - Val1", "2" }, - { "Sum - Val2", "20" }, - { "Total Sum - Val1", "2" }, - { "Total Sum - Val2", "20" } + { "Sum - Val2", "20" } }; bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "DataPilot table output (filtered by query)"); diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 22f17effa857..24dc55f4cfa0 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -863,8 +863,15 @@ void ScDPSource::CreateRes_Impl() aInitState.AddMember( nPageDims[i], GetMemberId( nPageDims[i], pDim->GetSelectedData() ) ); } - pColResRoot = new ScDPResultMember( pResData, bColumnGrand ); - pRowResRoot = new ScDPResultMember( pResData, bRowGrand ); + // Show grand total columns only when the option is set *and* there is at + // least one column field. Same for the grand total rows. + sal_uInt16 nDataLayoutOrient = GetDataLayoutOrientation(); + long nColDimCount2 = nColDimCount - (nDataLayoutOrient == sheet::DataPilotFieldOrientation_COLUMN ? 1 : 0); + long nRowDimCount2 = nRowDimCount - (nDataLayoutOrient == sheet::DataPilotFieldOrientation_ROW ? 1 : 0); + bool bShowColGrand = bColumnGrand && nColDimCount2 > 0; + bool bShowRowGrand = bRowGrand && nRowDimCount2 > 0; + pColResRoot = new ScDPResultMember(pResData, bShowColGrand); + pRowResRoot = new ScDPResultMember(pResData, bShowRowGrand); FillCalcInfo(false, aInfo, bHasAutoShow); long nColLevelCount = aInfo.aColLevels.size(); |