diff options
author | Eike Rathke <erack@redhat.com> | 2013-12-19 16:07:53 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-12-19 16:16:36 +0100 |
commit | 585b25194bb7c24dde6d21f3674b26decffe5ed7 (patch) | |
tree | 0d6d8fcbb4b4f4dd351cf2ae3c9884013a8ae70b | |
parent | 2b77788dab88ac0960537b76c42e4f30e68c5a6e (diff) |
fixed crash when invoking sort on an empty sheet's entire column, fdo#72874
Change-Id: Ifc4a08069a42ca18a056c509575a4080094aa07e
(cherry picked from commit efb0412eda9eb33e45b27d9d7d6cc94e4211a82c)
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 71c92825ca1a..5a0720c1123c 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -122,10 +122,15 @@ static sal_Bool lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortPar if( rSortParam.nRow1 != rSortParam.nRow2 ) eFillDir = DIR_TOP; - SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir ); - if( rSortParam.nRow2 == MAXROW ) - aExternalRange = ScRange( rSortParam.nCol1,sal::static_int_cast<SCROW>( nCount ), nTab ); + { + // Assume that user selected entire column(s), but cater for the + // possibility that the start row is not the first row. + SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, + rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir ); + aExternalRange = ScRange( rSortParam.nCol1, + ::std::min( rSortParam.nRow1 + sal::static_int_cast<SCROW>( nCount ), MAXROW), nTab ); + } else aExternalRange = ScRange( pData->GetCurX(), pData->GetCurY(), nTab ); |