[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 27 07:36:28 PDT 2012


 sc/source/core/data/table3.cxx |   49 +++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 19 deletions(-)

New commits:
commit 2c1d36c575399fcd8743cfe3b96e107e821cbe65
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Aug 26 14:04:37 2012 +0200

    when swaping cols or rows insert notes at the right place, fdo#53979
    
    Change-Id: I1228b3a064623e810265b47776e33f81f4bf0e51
    Signed-off-by: Kohei Yoshida <kohei.yoshida at gmail.com>

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index ea49b05..15087c5 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -563,7 +563,9 @@ void ScTable::QuickSort( ScSortInfoArray* pArray, SCsCOLROW nLo, SCsCOLROW nHi )
 
 void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
 {
-    for (SCROW nRow = aSortParam.nRow1; nRow <= aSortParam.nRow2; nRow++)
+    SCROW nRowStart = aSortParam.nRow1;
+    SCROW nRowEnd = aSortParam.nRow2;
+    for (SCROW nRow = nRowStart; nRow <= nRowEnd; nRow++)
     {
         aCol[nCol1].SwapCell(nRow, aCol[nCol2]);
         if (aSortParam.bIncludePattern)
@@ -589,16 +591,19 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
         ScPostIt* pPostIt = itr->second;
         ++itr;
 
-        if (nCol == nCol1)
+        if(nRow >= nRowStart && nRow <= nRowEnd)
         {
-            aNoteMap.insert(nCol, nRow, pPostIt);
-            maNotes.ReleaseNote(nCol2, nRow);
-        }
-        else if (nCol == nCol2)
-        {
-            aNoteMap.insert(nCol, nRow, pPostIt);
-            maNotes.ReleaseNote(nCol1, nRow);
+            if (nCol == nCol1)
+            {
+                aNoteMap.insert(nCol2, nRow, pPostIt);
+                maNotes.ReleaseNote(nCol, nRow);
+            }
+            else if (nCol == nCol2)
+            {
+                aNoteMap.insert(nCol1, nRow, pPostIt);
+                maNotes.ReleaseNote(nCol, nRow);
 
+            }
         }
     }
 
@@ -609,6 +614,7 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
         SCCOL nCol = itr->first.first;
         SCROW nRow = itr->first.second;
         ScPostIt* pPostIt = itr->second;
+        ++itr;
 
         maNotes.insert(nCol, nRow, pPostIt);
         aNoteMap.ReleaseNote(nCol, nRow);
@@ -617,7 +623,9 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2)
 
 void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
 {
-    for (SCCOL nCol = aSortParam.nCol1; nCol <= aSortParam.nCol2; nCol++)
+    SCCOL nColStart = aSortParam.nCol1;
+    SCCOL nColEnd = aSortParam.nCol2;
+    for (SCCOL nCol = nColStart; nCol <= nColEnd; nCol++)
     {
         aCol[nCol].SwapRow(nRow1, nRow2);
         if (aSortParam.bIncludePattern)
@@ -655,16 +663,18 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
         ScPostIt* pPostIt = itr->second;
         ++itr;
 
-        if (nRow == nRow1)
+        if( nCol >= nColStart && nCol <= nColEnd )
         {
-            aNoteMap.insert(nCol, nRow, pPostIt);
-            maNotes.ReleaseNote(nCol, nRow2);
-        }
-        else if (nRow == nRow2)
-        {
-            aNoteMap.insert(nCol, nRow, pPostIt);
-            maNotes.ReleaseNote(nCol, nRow1);
-
+            if (nRow == nRow1)
+            {
+                aNoteMap.insert(nCol, nRow2, pPostIt);
+                maNotes.ReleaseNote(nCol, nRow);
+            }
+            else if (nRow == nRow2)
+            {
+                aNoteMap.insert(nCol, nRow1, pPostIt);
+                maNotes.ReleaseNote(nCol, nRow);
+            }
         }
     }
 
@@ -675,6 +685,7 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
         SCCOL nCol = itr->first.first;
         SCROW nRow = itr->first.second;
         ScPostIt* pPostIt = itr->second;
+        ++itr;
 
         maNotes.insert(nCol, nRow, pPostIt);
         aNoteMap.ReleaseNote(nCol, nRow);


More information about the Libreoffice-commits mailing list