diff options
author | Eike Rathke <erack@redhat.com> | 2018-03-06 21:26:23 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-26 08:31:42 +0200 |
commit | 75d3a15d1187cbbe9f04c18d4f9ed7597fe1b356 (patch) | |
tree | 50f22577dc42ca251b5ecca54a90ae24e8c4c20a /sc | |
parent | f12023c185b0dff258c871b9f026906bb53edee3 (diff) |
Resolves: tdf#116215 separate column sums and row sums, tdf#71339 related
Change-Id: Ifc7ab0c460f521ad3be4aa2785d54a1e4ed304e5
(cherry picked from commit 9d8dcec608dde63c68b34450a95a3b168121e289)
Reviewed-on: https://gerrit.libreoffice.org/50845
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
(cherry picked from commit 2f504da556cb091db0ad7c47f1bb90220d890c66)
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index aaac0138287f..ebf5d9032c88 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -631,7 +631,10 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor SCCOL nMarkEndCol = nEndCol; SCROW nMarkEndRow = nEndRow; ScAutoSum eSum = ScAutoSumNone; - ScRangeList aSumRangeList; + SCROW nColSums = 0; + SCCOL nRowSums = 0; + SCROW nColSumsStartRow = 0; + SCCOL nRowSumsStartCol = 0; if ( bRow ) { @@ -655,12 +658,15 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor { if ( !pDoc->IsBlockEmpty( nTab, nCol, nStartRow, nCol, nSumEndRow ) ) { + ScRangeList aRangeList; // Include the originally selected start row. const ScRange aRange( nCol, rRange.aStart.Row(), nTab, nCol, nSumEndRow, nTab ); - if ( (eSum = lcl_GetAutoSumForColumnRange( pDoc, aSumRangeList, aRange )) != ScAutoSumNone ) + if ( (eSum = lcl_GetAutoSumForColumnRange( pDoc, aRangeList, aRange )) != ScAutoSumNone ) { + if (++nRowSums == 1) + nRowSumsStartCol = aRangeList[0]->aStart.Col(); const OUString aFormula = GetAutoSumFormula( - aSumRangeList, bSubTotal, ScAddress(nCol, nInsRow, nTab)); + aRangeList, bSubTotal, ScAddress(nCol, nInsRow, nTab)); EnterData( nCol, nInsRow, nTab, aFormula ); } } @@ -689,11 +695,14 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor { if ( !pDoc->IsBlockEmpty( nTab, nStartCol, nRow, nSumEndCol, nRow ) ) { + ScRangeList aRangeList; // Include the originally selected start column. const ScRange aRange( rRange.aStart.Col(), nRow, nTab, nSumEndCol, nRow, nTab ); - if ( (eSum = lcl_GetAutoSumForRowRange( pDoc, aSumRangeList, aRange )) != ScAutoSumNone ) + if ( (eSum = lcl_GetAutoSumForRowRange( pDoc, aRangeList, aRange )) != ScAutoSumNone ) { - const OUString aFormula = GetAutoSumFormula( aSumRangeList, bSubTotal, ScAddress(nInsCol, nRow, nTab) ); + if (++nColSums == 1) + nColSumsStartRow = aRangeList[0]->aStart.Row(); + const OUString aFormula = GetAutoSumFormula( aRangeList, bSubTotal, ScAddress(nInsCol, nRow, nTab) ); EnterData( nInsCol, nRow, nTab, aFormula ); } } @@ -706,10 +715,10 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor // original selection. All extended by end column/row where the sum is put. const ScRange aMarkRange( (eSum == ScAutoSumSum ? - (aSumRangeList.size() == 1 ? aSumRangeList[0]->aStart.Col() : nStartCol) : + (nRowSums == 1 ? nRowSumsStartCol : nStartCol) : rRange.aStart.Col()), (eSum == ScAutoSumSum ? - (aSumRangeList.size() == 1 ? aSumRangeList[0]->aStart.Row() : nStartRow) : + (nColSums == 1 ? nColSumsStartRow : nStartRow) : rRange.aStart.Row()), nTab, nMarkEndCol, nMarkEndRow, nTab ); MarkRange( aMarkRange, false, bContinue ); |