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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Nov 4 07:56:34 PST 2012


 sc/source/core/data/table2.cxx |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

New commits:
commit d7e30b7745ad14a4d0d17b279bb020af06463604
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Nov 2 13:27:31 2012 -0400

    Correctly handle cell note shifting when immediate row/column is deleted.
    
    Currently, having a note e.g. at D5, and deleting cell D4 and shifting
    the cells below upward will remove the note at D5.  But the correct behavior
    is to shift that note up to D4.  This change fixes it.
    
    Change-Id: Ia37f1ce67a003deab424f2b805a2ce333fc10ed4
    (cherry picked from commit d3344dd85ee31b195a3709d16e734245e1d0a4b6)
    
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index afafa10..e8df882 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -270,7 +270,8 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
 
         if (nStartRow <= nRow && nStartCol <= nCol && nCol <= nEndCol)
         {
-            if(nRow - nStartRow > static_cast<SCROW>(nSize))
+            SCROW nEndRow = nStartRow + nSize - 1; // last row of deleted region
+            if (nEndRow < nRow)
             {
                 // This note will get shifted.
                 aNotes.insert(nCol, nRow - nSize, pPostIt);
@@ -377,6 +378,7 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
             aCol[MAXCOL - nSize - i].MoveTo(nStartRow, nEndRow, aCol[MAXCOL - i]);
     }
 
+    // Transfer those notes that will get shifted into another container.
     ScNotes aNotes(pDocument);
     ScNotes::iterator itr = maNotes.begin();
     while( itr != maNotes.end() )
@@ -386,13 +388,14 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
         ScPostIt* pPostIt = itr->second;
         ++itr;
 
-        if (nCol >= nStartCol)
+        if (nStartCol <= nCol && nStartRow <= nRow && nRow <= nEndRow)
         {
             aNotes.insert(nCol + nSize, nRow, pPostIt);
             maNotes.ReleaseNote(nCol, nRow);
         }
     }
 
+    // Re-insert the shifted notes.
     itr = aNotes.begin();
     while( itr != aNotes.end() )
     {
@@ -486,6 +489,7 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
             aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]);
     }
 
+    // Transfer those notes that will get shifted into another container.
     ScNotes aNotes(pDocument);
     ScNotes::iterator itr = maNotes.begin();
     while( itr != maNotes.end() )
@@ -495,18 +499,22 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
         ScPostIt* pPostIt = itr->second;
         ++itr;
 
-        if (nCol >= nStartCol)
+        if (nStartCol <= nCol && nStartRow <= nRow && nRow <= nEndRow)
         {
-            if(nCol - nStartCol > static_cast<SCCOL>(nSize))
+            SCCOL nEndCol = nStartCol + nSize - 1;
+            if (nEndCol < nCol)
             {
+                // This note will get shifted.
                 aNotes.insert(nCol - nSize, nRow, pPostIt);
                 maNotes.ReleaseNote(nCol, nRow);
             }
             else
+                // The note is in the deleted region. Remove it.
                 maNotes.erase(nCol, nRow);
         }
     }
 
+    // Re-insert the shifted notes.
     itr = aNotes.begin();
     while( itr != aNotes.end() )
     {
commit 9a328cc53ccae9a7d0c0770dd7072f18e66592b0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Nov 2 11:01:15 2012 -0400

    Fix incorrect shifting of cell notes upon cell insertion / deletion.
    
    Steps to reproduce:
    
    1) Insert a comment at D5.
    2) Move cursor to C4.
    3) Right-click and select Insert.
    4) Choose shift cells down.
    5) The comment gets shifted down but it shouldn't.
    
    The same thing happens when deleting a cell and shifting content.
    
    Change-Id: I5a71845cca6abde6b7c940e152e155da26343cef
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index cd193c1..afafa10 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -176,6 +176,7 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
     for (SCCOL j=nStartCol; j<=nEndCol; j++)
         aCol[j].InsertRow( nStartRow, nSize );
 
+    // Transfer those notes that will get shifted into another container.
     ScNotes aNotes(pDocument);
     ScNotes::iterator itr = maNotes.begin();
     while( itr != maNotes.end() )
@@ -185,13 +186,14 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
         ScPostIt* pPostIt = itr->second;
         ++itr;
 
-        if (nRow >= nStartRow)
+        if (nStartRow <= nRow && nStartCol <= nCol && nCol <= nEndCol)
         {
             aNotes.insert(nCol, nRow + nSize, pPostIt);
             maNotes.ReleaseNote(nCol, nRow);
         }
     }
 
+    // Re-insert the shifted notes.
     itr = aNotes.begin();
     while( itr != aNotes.end() )
     {
@@ -256,6 +258,7 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
         }
     }
 
+    // Transfer those notes that will get shifted into another container.
     ScNotes aNotes(pDocument);
     ScNotes::iterator itr = maNotes.begin();
     while( itr != maNotes.end() )
@@ -265,18 +268,21 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
         ScPostIt* pPostIt = itr->second;
         ++itr;
 
-        if (nRow >= nStartRow)
+        if (nStartRow <= nRow && nStartCol <= nCol && nCol <= nEndCol)
         {
             if(nRow - nStartRow > static_cast<SCROW>(nSize))
             {
+                // This note will get shifted.
                 aNotes.insert(nCol, nRow - nSize, pPostIt);
                 maNotes.ReleaseNote(nCol, nRow);
             }
             else
+                // Note is in the deleted area. Remove it.
                 maNotes.erase(nCol, nRow);
         }
     }
 
+    // Re-insert the shifted notes.
     itr = aNotes.begin();
     while( itr != aNotes.end() )
     {


More information about the Libreoffice-commits mailing list