diff options
author | Eike Rathke <erack@redhat.com> | 2015-05-04 20:45:45 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-05-07 14:06:05 +0000 |
commit | 88ea6b734a2a87a41196370cc1d66476e2a19514 (patch) | |
tree | d5b133a3a863a0ddcc42cf037b82fca673ded10f | |
parent | 73eb60c8f958c6e33cde897194711111e31b45c2 (diff) |
Resolves tdf#90757 ensure start row / end row order makes sense
... in case the header is the only row.
Change-Id: I5e6046007a8d668f9834e108aaf8af0072629fc8
(cherry picked from commit 46fa99f61aff88f1697959a9d3c41a5c3c3c05e9)
Reviewed-on: https://gerrit.libreoffice.org/15631
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/source/core/data/table3.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 13 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index f02a4b6c6f02..46d38c83039e 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1702,11 +1702,10 @@ void ScTable::Sort( SCROW nLastRow = 0; for (SCCOL nCol = rSortParam.nCol1; nCol <= rSortParam.nCol2; nCol++) nLastRow = std::max(nLastRow, aCol[nCol].GetLastDataPos()); - rSortParam.nRow2 = nLastRow = std::min(nLastRow, rSortParam.nRow2); - SCROW nRow1 = (rSortParam.bHasHeader ? - rSortParam.nRow1 + 1 : rSortParam.nRow1); + rSortParam.nRow2 = nLastRow = std::max( std::min(nLastRow, rSortParam.nRow2), rSortParam.nRow1); + SCROW nRow1 = (rSortParam.bHasHeader ? rSortParam.nRow1 + 1 : rSortParam.nRow1); aSortParam = rSortParam; // must be assigned before calling IsSorted() - if (!IsSorted(nRow1, nLastRow)) + if (nRow1 < nLastRow && !IsSorted(nRow1, nLastRow)) { if(pProgress) pProgress->SetState( 0, nLastRow-nRow1 ); @@ -1735,7 +1734,7 @@ void ScTable::Sort( SCCOL nCol1 = (rSortParam.bHasHeader ? rSortParam.nCol1 + 1 : rSortParam.nCol1); aSortParam = rSortParam; // must be assigned before calling IsSorted() - if (!IsSorted(nCol1, nLastCol)) + if (nCol1 < nLastCol && !IsSorted(nCol1, nLastCol)) { if(pProgress) pProgress->SetState( 0, nLastCol-nCol1 ); diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index bb974630a333..b2ab0106b03b 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -569,10 +569,13 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam, pDBData->SetSortParam(rSortParam); - ScRange aDirtyRange( - aLocalParam.nCol1, nStartRow, nTab, - aLocalParam.nCol2, aLocalParam.nRow2, nTab); - rDoc.SetDirty( aDirtyRange, true ); + if (nStartRow <= aLocalParam.nRow2) + { + ScRange aDirtyRange( + aLocalParam.nCol1, nStartRow, nTab, + aLocalParam.nCol2, aLocalParam.nRow2, nTab); + rDoc.SetDirty( aDirtyRange, true ); + } if (bPaint) { @@ -590,7 +593,7 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam, rDocShell.PostPaint(ScRange(nStartX, nStartY, nTab, nEndX, nEndY, nTab), nPaint); } - if (!bUniformRowHeight) + if (!bUniformRowHeight && nStartRow <= aLocalParam.nRow2) rDocShell.AdjustRowHeight(nStartRow, aLocalParam.nRow2, nTab); aModificator.SetDocumentModified(); |