Blame SOURCES/0001-Resolves-tdf-90757-ensure-start-row-end-row-order-ma.patch

ebc4bd
From 92ce22450d4a140b368bf95ae6975887f3a30032 Mon Sep 17 00:00:00 2001
ebc4bd
Message-Id: <92ce22450d4a140b368bf95ae6975887f3a30032.1430767502.git.erack@redhat.com>
ebc4bd
From: Eike Rathke <erack@redhat.com>
ebc4bd
Date: Mon, 4 May 2015 20:45:45 +0200
ebc4bd
Subject: [PATCH] Resolves tdf#90757 ensure start row / end row order makes
ebc4bd
 sense
ebc4bd
MIME-Version: 1.0
ebc4bd
Content-Type: multipart/mixed; boundary="------------erAck-patch-parts"
ebc4bd
ebc4bd
This is a multi-part message in MIME format.
ebc4bd
--------------erAck-patch-parts
ebc4bd
Content-Type: text/plain; charset=UTF-8; format=fixed
ebc4bd
Content-Transfer-Encoding: 8bit
ebc4bd
ebc4bd
ebc4bd
... in case the header is the only row.
ebc4bd
ebc4bd
(cherry picked from commit 46fa99f61aff88f1697959a9d3c41a5c3c3c05e9)
ebc4bd
ebc4bd
Conflicts:
ebc4bd
	sc/source/ui/docshell/dbdocfun.cxx
ebc4bd
ebc4bd
Change-Id: I5e6046007a8d668f9834e108aaf8af0072629fc8
ebc4bd
---
ebc4bd
 sc/source/core/data/table3.cxx     |  9 ++++-----
ebc4bd
 sc/source/ui/docshell/dbdocfun.cxx | 13 ++++++++-----
ebc4bd
 2 files changed, 12 insertions(+), 10 deletions(-)
ebc4bd
ebc4bd
ebc4bd
--------------erAck-patch-parts
ebc4bd
Content-Type: text/x-patch; name="0001-Resolves-tdf-90757-ensure-start-row-end-row-order-ma.patch"
ebc4bd
Content-Transfer-Encoding: 8bit
ebc4bd
Content-Disposition: attachment; filename="0001-Resolves-tdf-90757-ensure-start-row-end-row-order-ma.patch"
ebc4bd
ebc4bd
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
ebc4bd
index daf370c..c9e9377 100644
ebc4bd
--- a/sc/source/core/data/table3.cxx
ebc4bd
+++ b/sc/source/core/data/table3.cxx
ebc4bd
@@ -1429,11 +1429,10 @@ void ScTable::Sort(
ebc4bd
         SCROW nLastRow = 0;
ebc4bd
         for (SCCOL nCol = rSortParam.nCol1; nCol <= rSortParam.nCol2; nCol++)
ebc4bd
             nLastRow = std::max(nLastRow, aCol[nCol].GetLastDataPos());
ebc4bd
-        rSortParam.nRow2 = nLastRow = std::min(nLastRow, rSortParam.nRow2);
ebc4bd
-        SCROW nRow1 = (rSortParam.bHasHeader ?
ebc4bd
-            rSortParam.nRow1 + 1 : rSortParam.nRow1);
ebc4bd
+        rSortParam.nRow2 = nLastRow = std::max( std::min(nLastRow, rSortParam.nRow2), rSortParam.nRow1);
ebc4bd
+        SCROW nRow1 = (rSortParam.bHasHeader ? rSortParam.nRow1 + 1 : rSortParam.nRow1);
ebc4bd
         aSortParam = rSortParam;    // must be assigned before calling IsSorted()
ebc4bd
-        if (!IsSorted(nRow1, nLastRow))
ebc4bd
+        if (nRow1 < nLastRow && !IsSorted(nRow1, nLastRow))
ebc4bd
         {
ebc4bd
             if(pProgress)
ebc4bd
                 pProgress->SetState( 0, nLastRow-nRow1 );
ebc4bd
@@ -1459,7 +1458,7 @@ void ScTable::Sort(
ebc4bd
         SCCOL nCol1 = (rSortParam.bHasHeader ?
ebc4bd
             rSortParam.nCol1 + 1 : rSortParam.nCol1);
ebc4bd
         aSortParam = rSortParam;    // must be assigned before calling IsSorted()
ebc4bd
-        if (!IsSorted(nCol1, nLastCol))
ebc4bd
+        if (nCol1 < nLastCol && !IsSorted(nCol1, nLastCol))
ebc4bd
         {
ebc4bd
             if(pProgress)
ebc4bd
                 pProgress->SetState( 0, nLastCol-nCol1 );
ebc4bd
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
ebc4bd
index c4e81bc..cb132b6 100644
ebc4bd
--- a/sc/source/ui/docshell/dbdocfun.cxx
ebc4bd
+++ b/sc/source/ui/docshell/dbdocfun.cxx
ebc4bd
@@ -531,10 +531,13 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
ebc4bd
 
ebc4bd
     pDBData->SetSortParam(rSortParam);
ebc4bd
 
ebc4bd
-    ScRange aDirtyRange(
ebc4bd
-        aLocalParam.nCol1, nStartRow, nTab,
ebc4bd
-        aLocalParam.nCol2, aLocalParam.nRow2, nTab);
ebc4bd
-    pDoc->SetDirty( aDirtyRange, true );
ebc4bd
+    if (nStartRow <= aLocalParam.nRow2)
ebc4bd
+    {
ebc4bd
+        ScRange aDirtyRange(
ebc4bd
+                aLocalParam.nCol1, nStartRow, nTab,
ebc4bd
+                aLocalParam.nCol2, aLocalParam.nRow2, nTab);
ebc4bd
+        pDoc->SetDirty( aDirtyRange, true );
ebc4bd
+    }
ebc4bd
 
ebc4bd
     if (bPaint)
ebc4bd
     {
ebc4bd
@@ -552,7 +555,7 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
ebc4bd
         rDocShell.PostPaint(ScRange(nStartX, nStartY, nTab, nEndX, nEndY, nTab), nPaint);
ebc4bd
     }
ebc4bd
 
ebc4bd
-    if (!bUniformRowHeight)
ebc4bd
+    if (!bUniformRowHeight && nStartRow <= aLocalParam.nRow2)
ebc4bd
         rDocShell.AdjustRowHeight(nStartRow, aLocalParam.nRow2, nTab);
ebc4bd
 
ebc4bd
     aModificator.SetDocumentModified();
ebc4bd
ebc4bd
--------------erAck-patch-parts--
ebc4bd
ebc4bd