sc/inc/subtotalparam.hxx | 4 ++-- sc/source/core/data/subtotalparam.cxx | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-)
New commits: commit 924dc031f9fa669c43361c72185ef9f76fbd8232 Author: Balazs Varga <[email protected]> AuthorDate: Mon Feb 16 11:45:43 2026 +0100 Commit: Balazs Varga <[email protected]> CommitDate: Tue Feb 17 09:24:16 2026 +0100 Table Styles: make the SetCustFuncs and SetSubLabels consistent Since these two functions are index based we should check nGroupIdx >= MAXSUBTOTAL even if we only pass '0' in nGroupIdx, because later maybe can be used multiple (3) groups in Table Styles Total rows. Follow-up: d5c36d5e775fa48c011570eb876317c21727baa0 (Table Styles: fix not removed total function in case of) Change-Id: Iad2981d2c82bd58f16b7bea72faeb5c51bc77635 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199472 Tested-by: Jenkins Reviewed-by: Balazs Varga <[email protected]> (cherry picked from commit ed43e7866c963d081678d80055234159129f540f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199504 Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/inc/subtotalparam.hxx b/sc/inc/subtotalparam.hxx index fcfc8ef04244..3f2d904c1b8b 100644 --- a/sc/inc/subtotalparam.hxx +++ b/sc/inc/subtotalparam.hxx @@ -98,10 +98,10 @@ struct SC_DLLPUBLIC ScSubTotalParam const SCCOL* ptrSubTotals, const ScSubTotalFunc* ptrFunctions, sal_uInt16 nCount ); - void SetCustFuncs( sal_uInt16 nGroup, + void SetCustFuncs( sal_uInt16 nGroupIdx, std::vector<std::pair<SCCOL, std::unique_ptr<ScTokenArray>>>& rColFuncs, sal_uInt16 nCount ); - void SetSubLabels( sal_uInt16 nGroup, + void SetSubLabels( sal_uInt16 nGroupIdx, std::vector<std::pair<SCCOL, rtl::OUString>>& rColLabels, sal_uInt16 nCount ); }; diff --git a/sc/source/core/data/subtotalparam.cxx b/sc/source/core/data/subtotalparam.cxx index 448968d81efb..e2bcf48cedb8 100644 --- a/sc/source/core/data/subtotalparam.cxx +++ b/sc/source/core/data/subtotalparam.cxx @@ -166,30 +166,30 @@ void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup, aGroups[nGroup].pSubTotals[i] = { ptrSubTotals[i], ptrFunctions[i] }; } -void ScSubTotalParam::SetCustFuncs(sal_uInt16 nGroup, +void ScSubTotalParam::SetCustFuncs(sal_uInt16 nGroupIdx, std::vector<std::pair<SCCOL, std::unique_ptr<ScTokenArray>>>& rColFuncs, sal_uInt16 nCount ) { - OSL_ENSURE((nGroup <= MAXSUBTOTAL), "ScSubTotalParam::SetCustFuncs(): nGroup > MAXSUBTOTAL!"); - if (nGroup > MAXSUBTOTAL) + OSL_ENSURE((nGroupIdx < MAXSUBTOTAL), "ScSubTotalParam::SetCustFuncs(): nGroupIdx >= MAXSUBTOTAL!"); + if (nGroupIdx >= MAXSUBTOTAL) return; - aGroups[nGroup].AllocCustFuncs(nCount); + aGroups[nGroupIdx].AllocCustFuncs(nCount); for (sal_uInt16 i = 0; i < nCount; i++) - aGroups[nGroup].pCustFuncs[i] = std::make_pair(rColFuncs[i].first, std::move(rColFuncs[i].second)); + aGroups[nGroupIdx].pCustFuncs[i] = std::make_pair(rColFuncs[i].first, std::move(rColFuncs[i].second)); } -void ScSubTotalParam::SetSubLabels(sal_uInt16 nGroup, +void ScSubTotalParam::SetSubLabels(sal_uInt16 nGroupIdx, std::vector<std::pair<SCCOL, rtl::OUString>>& rColLabels, sal_uInt16 nCount ) { - OSL_ENSURE((nGroup <= MAXSUBTOTAL), "ScSubTotalParam::SetSubLabels(): nGroup > MAXSUBTOTAL!"); - if (nGroup > MAXSUBTOTAL) + OSL_ENSURE((nGroupIdx < MAXSUBTOTAL), "ScSubTotalParam::SetSubLabels(): nGroupIdx > MAXSUBTOTAL!"); + if (nGroupIdx >= MAXSUBTOTAL) return; - aGroups[nGroup].AllocSubLabels(nCount); + aGroups[nGroupIdx].AllocSubLabels(nCount); for (sal_uInt16 i = 0; i < nCount; i++) - aGroups[nGroup].pSubLabels[i] = std::make_pair(rColLabels[i].first, std::move(rColLabels[i].second)); + aGroups[nGroupIdx].pSubLabels[i] = std::make_pair(rColLabels[i].first, std::move(rColLabels[i].second)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
