[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Aug 10 20:15:03 PDT 2011


 sc/source/ui/view/tabview2.cxx |   46 ++++++++++++++---------------------------
 1 file changed, 16 insertions(+), 30 deletions(-)

New commits:
commit 2b3a4d52ad63a8b388763c7c01a095e0b33db930
Author: Eike Rathke <ooo at erack.de>
Date:   Wed Aug 10 21:40:56 2011 -0400

    Prevent crash at column row boundaries.
    
    Modified from the original patch submitted by Olivier Hallot.
    
    Signed-off-by: Kohei Yoshida <kohei.yoshida at suse.com>

diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 0ad18a4..622a6e1 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -86,53 +86,39 @@ void moveCursorByProtRule(
 
     if (nMovX > 0)
     {
-        if (rCol < MAXCOL)
+        for (SCCOL i = 0; i < nMovX && rCol < MAXCOL; ++i)
         {
-            for (SCCOL i = 0; i < nMovX; ++i)
-            {
-                if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
-                    break;
-                ++rCol;
-            }
+            if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                break;
+            ++rCol;
         }
     }
     else if (nMovX < 0)
     {
-        if (rCol > 0)
+        for (SCCOL i = 0; i > nMovX && rCol > 0; --i)
         {
-            nMovX = -nMovX;
-            for (SCCOL i = 0; i < nMovX; ++i)
-            {
-                if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
-                    break;
-                --rCol;
-            }
+            if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                break;
+            --rCol;
         }
     }
 
     if (nMovY > 0)
     {
-        if (rRow < MAXROW)
+        for (SCROW i = 0; i < nMovY && rRow < MAXROW; ++i)
         {
-            for (SCROW i = 0; i < nMovY; ++i)
-            {
-                if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
-                    break;
-                ++rRow;
-            }
+            if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
+                break;
+            ++rRow;
         }
     }
     else if (nMovY < 0)
     {
-        if (rRow > 0)
+        for (SCROW i = 0; i > nMovY && rRow > 0; --i)
         {
-            nMovY = -nMovY;
-            for (SCROW i = 0; i < nMovY; ++i)
-            {
-                if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
-                    break;
-                --rRow;
-            }
+            if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
+                break;
+            --rRow;
         }
     }
 }


More information about the Libreoffice-commits mailing list