[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Feb 11 17:44:51 PST 2011


 sc/source/ui/view/tabview2.cxx |   62 +++++++++--------------------------------
 1 file changed, 15 insertions(+), 47 deletions(-)

New commits:
commit 63f695b8cf3572c2697abcfe99e2e7d5da923e9b
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Feb 11 19:31:30 2011 -0500

    Fixed incorrect cursor navigation. (fdo#33756)
    
    Block selection with keyboard was incorrect when the selected range
    included hidden cells.  This also fixes one crasher on block
    selection during formula reference mode i.e. type '=SUM(' and select
    range via keyboard afterward.

diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 01d5d0e..674ccd6 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -401,8 +401,9 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
 {
     SCCOL nNewX = -1;
     SCROW nNewY = -1;
-    SCCOL nCurX = -1;
-    SCROW nCurY = -1;
+    // current cursor position.
+    SCCOL nCurX = aViewData.GetCurX();
+    SCROW nCurY = aViewData.GetCurY();
 
     if (aViewData.IsRefMode())
     {
@@ -414,14 +415,11 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
         // block end position.
         nNewX = nBlockEndX;
         nNewY = nBlockEndY;
-        // cursor position - diagonally opposite of the block end position.
-        nCurX = aViewData.GetCurX();
-        nCurY = aViewData.GetCurY();
     }
     else
     {
-        nNewX = nCurX = aViewData.GetCurX();
-        nNewY = nCurY = aViewData.GetCurY();
+        nNewX = nCurX;
+        nNewY = nCurY;
     }
 
     ScDocument* pDoc = aViewData.GetDocument();
@@ -591,7 +589,7 @@ void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, S
 
 namespace {
 
-bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
+bool isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
 {
     bool bCellProtected = pDoc->HasAttrib(
         nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED);
@@ -605,33 +603,7 @@ bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, b
     return true;
 }
 
-void skipHiddenRows(ScDocument* pDoc, SCTAB nTab, SCROW& rRow, bool bForward)
-{
-    SCROW nFirst, nLast;
-    if (!pDoc->RowHidden(rRow, nTab, &nFirst, &nLast))
-        // This row is visible.  Nothing to do.
-        return;
-
-    if (bForward)
-        rRow = nLast < MAXROW ? nLast + 1 : MAXROW;
-    else
-        rRow = nFirst > 0 ? nFirst - 1 : 0;
-}
-
-void skipHiddenCols(ScDocument* pDoc, SCTAB nTab, SCCOL& rCol, bool bForward)
-{
-    SCCOL nFirst, nLast;
-    if (!pDoc->ColHidden(rCol, nTab, &nFirst, &nLast))
-        // This row is visible.  Nothing to do.
-        return;
-
-    if (bForward)
-        rCol = nLast < MAXCOL ? nLast + 1 : MAXCOL;
-    else
-        rCol = nFirst > 0 ? nFirst - 1 : 0;
-}
-
-void lcl_moveCursorByProtRule(
+void moveCursorByProtRule(
     SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
 {
     bool bSelectLocked = true;
@@ -649,10 +621,9 @@ void lcl_moveCursorByProtRule(
         {
             for (SCCOL i = 0; i < nMovX; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 ++rCol;
-                skipHiddenCols(pDoc, nTab, rCol, true);
             }
         }
     }
@@ -663,10 +634,9 @@ void lcl_moveCursorByProtRule(
             nMovX = -nMovX;
             for (SCCOL i = 0; i < nMovX; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 --rCol;
-                skipHiddenCols(pDoc, nTab, rCol, false);
             }
         }
     }
@@ -677,10 +647,9 @@ void lcl_moveCursorByProtRule(
         {
             for (SCROW i = 0; i < nMovY; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 ++rRow;
-                skipHiddenRows(pDoc, nTab, rRow, true);
             }
         }
     }
@@ -691,10 +660,9 @@ void lcl_moveCursorByProtRule(
             nMovY = -nMovY;
             for (SCROW i = 0; i < nMovY; ++i)
             {
-                if (!lcl_isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
+                if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
                     break;
                 --rRow;
-                skipHiddenRows(pDoc, nTab, rRow, false);
             }
         }
     }
@@ -733,7 +701,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
             bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
         }
 
-        lcl_moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
+        moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
 
         if (nMovX)
         {
@@ -745,7 +713,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
                 else
                     --nTempX;
             }
-            if (lcl_isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
+            if (isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
                 nNewX = nTempX;
         }
 
@@ -759,7 +727,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
                 else
                     --nTempY;
             }
-            if (lcl_isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
+            if (isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
                 nNewY = nTempY;
         }
 
@@ -776,7 +744,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
         if (!IsBlockMode())
             InitBlockMode(aViewData.GetCurX(), aViewData.GetCurY(), nTab, true);
 
-        lcl_moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
+        moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
 
         if (nBlockEndX < 0)
             nBlockEndX = 0;


More information about the Libreoffice-commits mailing list