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

Eike Rathke erack at redhat.com
Mon May 4 11:57:31 PDT 2015


 sc/source/core/data/table1.cxx     |    4 ++++
 sc/source/core/data/table3.cxx     |    9 ++++-----
 sc/source/ui/docshell/dbdocfun.cxx |   13 ++++++++-----
 3 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit c4ed1eb3ab4480092b21d95edebc10ea010b67e8
Author: Eike Rathke <erack at redhat.com>
Date:   Mon May 4 20:55:40 2015 +0200

    assert(nStartRow <= nEndRow)
    
    Zero or negative count is unhealthy..
    
    Change-Id: I4cce6c896e73e8e964518cbe4a29eb03ed481251

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 2d45dab..e2beed5 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -84,6 +84,8 @@ void GetOptimalHeightsInColumn(
     sc::RowHeightContext& rCxt, ScColumn* pCol, SCROW nStartRow, SCROW nEndRow,
     ScProgress* pProgress, sal_uInt32 nProgressStart )
 {
+    assert(nStartRow <= nEndRow);
+
     SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
 
     //  first, one time over the whole range
@@ -460,6 +462,8 @@ bool ScTable::SetOptimalHeight(
     sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
     ScProgress* pOuterProgress, sal_uLong nProgressStart )
 {
+    assert(nStartRow <= nEndRow);
+
     OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(),
         "automatic OptimalHeight with Extra" );
 
commit 46fa99f61aff88f1697959a9d3c41a5c3c3c05e9
Author: Eike Rathke <erack at redhat.com>
Date:   Mon May 4 20:45:45 2015 +0200

    Resolves tdf#90757 ensure start row / end row order makes sense
    
    ... in case the header is the only row.
    
    Change-Id: I5e6046007a8d668f9834e108aaf8af0072629fc8

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 931fc61..49ecc0f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1704,11 +1704,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 );
@@ -1737,7 +1736,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 d8e6381..170a76e 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();


More information about the Libreoffice-commits mailing list