summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/table3.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index cf96a01a926e..d649e581782f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2164,11 +2164,20 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam )
for (sal_uInt16 nLevel = 0; nLevel<nLevelCount; nLevel++)
{
+ const sal_uInt16 nGroupNo = nLevelCount - nLevel - 1;
+ const ScSubTotalFunc* pResFunc = rParam.pFunctions[nGroupNo];
+ if (!pResFunc)
+ {
+ // No subtotal function given for this group => no formula or
+ // label and do not insert a row.
+ continue;
+ }
+
// increment end row
nGlobalEndRow++;
// add row entry for formula
- aRowEntry.nGroupNo = nLevelCount - nLevel - 1;
+ aRowEntry.nGroupNo = nGroupNo;
aRowEntry.nSubStartRow = nGlobalStartRow;
aRowEntry.nFuncStart = nGlobalStartFunc;
aRowEntry.nDestRow = nGlobalEndRow;
@@ -2186,10 +2195,9 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam )
DBShowRow(aRowEntry.nDestRow, true);
// insert label
- ScSubTotalFunc* eResFunc = rParam.pFunctions[aRowEntry.nGroupNo];
OUString label = ScGlobal::GetRscString(STR_TABLE_GRAND);
label += " ";
- label += ScGlobal::GetRscString(lcl_GetSubTotalStrId(eResFunc[0]));
+ label += ScGlobal::GetRscString(lcl_GetSubTotalStrId(pResFunc[0]));
SetString(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, nTab, label);
ApplyStyle(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, pStyle);
}