[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Mon Apr 16 14:05:57 UTC 2018


 sc/source/core/data/table3.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit f50e370db8f7ae20b12e312ad89a0f9961b7ee7a
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Apr 16 16:02:17 2018 +0200

    Resolves: tdf#116003 check presence of subtotal in group, tdf#107267 follow-up
    
    Change-Id: Ifed6e28926c689dd17914b8b1cbf47b58e2ffcdc

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index a0df3a54c575..08e34805039b 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2161,11 +2161,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;
@@ -2183,10 +2192,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);
             }


More information about the Libreoffice-commits mailing list