[Libreoffice-commits] .: Branch 'libreoffice-3-3' - 2 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Nov 29 22:05:21 PST 2010
sc/source/ui/inc/tabview.hxx | 3
sc/source/ui/view/tabview2.cxx | 150 +++++++++++++++++++++++++++++++++++++++++
sc/source/ui/view/tabview3.cxx | 82 ----------------------
3 files changed, 155 insertions(+), 80 deletions(-)
New commits:
commit 04608abcf80b8182509a9fc8b5f0d8088c47e045
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Nov 30 00:54:06 2010 -0500
Skip hidden cells while expanding range selection.
This commit happily fixes fdo#31796.
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index b53b3d7..e459c93 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -201,8 +201,8 @@ private:
void GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
- void SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX);
- void SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY);
+ void SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX);
+ void SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY);
protected:
void UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index d875ca7..a42cb46 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -504,7 +504,7 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
rMode = eMode;
}
-void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX)
+void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX)
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
@@ -564,7 +564,7 @@ void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX,
}
}
-void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY)
+void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY)
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
@@ -640,6 +640,32 @@ 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(
SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
{
@@ -661,6 +687,7 @@ void lcl_moveCursorByProtRule(
if (!lcl_isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
break;
++rCol;
+ skipHiddenCols(pDoc, nTab, rCol, true);
}
}
}
@@ -674,6 +701,7 @@ void lcl_moveCursorByProtRule(
if (!lcl_isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
break;
--rCol;
+ skipHiddenCols(pDoc, nTab, rCol, false);
}
}
}
@@ -687,6 +715,7 @@ void lcl_moveCursorByProtRule(
if (!lcl_isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
break;
++rRow;
+ skipHiddenRows(pDoc, nTab, rRow, true);
}
}
}
@@ -700,6 +729,7 @@ void lcl_moveCursorByProtRule(
if (!lcl_isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
break;
--rRow;
+ skipHiddenRows(pDoc, nTab, rRow, false);
}
}
}
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 8ca6279..d5a6f41 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -984,10 +984,10 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
aViewData.ResetOldCursor();
if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
- SkipCursorHorizontal(nCurX, nCurY, nOldX, nOldY, nMovX);
+ SkipCursorHorizontal(nCurX, nCurY, nOldX, nMovX);
if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
- SkipCursorVertical(nCurX, nCurY, nOldX, nOldY, nMovY);
+ SkipCursorVertical(nCurX, nCurY, nOldY, nMovY);
MoveCursorAbs( nCurX, nCurY, eMode, bShift, FALSE, TRUE, bKeepSel );
}
commit 9938610417b58421ec07386406e0604815c77eaa
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Nov 29 22:27:55 2010 -0500
Extracted methods that may be used in another place.
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 365af2c..b53b3d7 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -201,6 +201,9 @@ private:
void GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
+ void SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX);
+ void SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY);
+
protected:
void UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
const SCROW* pPosY = NULL );
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 6b7671b..d875ca7 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -504,6 +504,126 @@ void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode
rMode = eMode;
}
+void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovX)
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ bool bSkipProtected = false, bSkipUnprotected = false;
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect && pProtect->isProtected())
+ {
+ bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ bool bSkipCell = false;
+ bool bHFlip = false;
+ do
+ {
+ SCCOL nLastCol = -1;
+ bSkipCell = pDoc->ColHidden(rCurX, nTab, nLastCol) || pDoc->IsHorOverlapped(rCurX, rCurY, nTab);
+ if (bSkipProtected && !bSkipCell)
+ bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+ if (bSkipUnprotected && !bSkipCell)
+ bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+
+ if (bSkipCell)
+ {
+ if (rCurX <= 0 || rCurX >= MAXCOL)
+ {
+ if (bHFlip)
+ {
+ rCurX = nOldX;
+ bSkipCell = false;
+ }
+ else
+ {
+ nMovX = -nMovX;
+ if (nMovX > 0)
+ ++rCurX;
+ else
+ --rCurX;
+ bHFlip = true;
+ }
+ }
+ else
+ if (nMovX > 0)
+ ++rCurX;
+ else
+ --rCurX;
+ }
+ }
+ while (bSkipCell);
+
+ if (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
+ {
+ aViewData.SetOldCursor(rCurX, rCurY);
+ while (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
+ --rCurY;
+ }
+}
+
+void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nOldY, SCsROW nMovY)
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ bool bSkipProtected = false, bSkipUnprotected = false;
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect && pProtect->isProtected())
+ {
+ bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ bool bSkipCell = false;
+ bool bVFlip = false;
+ do
+ {
+ SCROW nLastRow = -1;
+ bSkipCell = pDoc->RowHidden(rCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( rCurX, rCurY, nTab );
+ if (bSkipProtected && !bSkipCell)
+ bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+ if (bSkipUnprotected && !bSkipCell)
+ bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+
+ if (bSkipCell)
+ {
+ if (rCurY <= 0 || rCurY >= MAXROW)
+ {
+ if (bVFlip)
+ {
+ rCurY = nOldY;
+ bSkipCell = false;
+ }
+ else
+ {
+ nMovY = -nMovY;
+ if (nMovY > 0)
+ ++rCurY;
+ else
+ --rCurY;
+ bVFlip = true;
+ }
+ }
+ else
+ if (nMovY > 0)
+ ++rCurY;
+ else
+ --rCurY;
+ }
+ }
+ while (bSkipCell);
+
+ if (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
+ {
+ aViewData.SetOldCursor(rCurX, rCurY);
+ while (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
+ --rCurX;
+ }
+}
+
namespace {
bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index fdccb1a..8ca6279 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -984,88 +984,10 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
aViewData.ResetOldCursor();
if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
- {
- BOOL bHFlip = FALSE;
- do
- {
- SCCOL nLastCol = -1;
- bSkipCell = pDoc->ColHidden(nCurX, nTab, nLastCol) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab );
- if (bSkipProtected && !bSkipCell)
- bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
- if (bSkipUnprotected && !bSkipCell)
- bSkipCell = !pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
-
- if (bSkipCell)
- {
- if ( nCurX<=0 || nCurX>=MAXCOL )
- {
- if (bHFlip)
- {
- nCurX = nOldX;
- bSkipCell = FALSE;
- }
- else
- {
- nMovX = -nMovX;
- if (nMovX > 0) ++nCurX; else --nCurX; // zuruecknehmen
- bHFlip = TRUE;
- }
- }
- else
- if (nMovX > 0) ++nCurX; else --nCurX;
- }
- }
- while (bSkipCell);
-
- if (pDoc->IsVerOverlapped( nCurX, nCurY, nTab ))
- {
- aViewData.SetOldCursor( nCurX,nCurY );
- while (pDoc->IsVerOverlapped( nCurX, nCurY, nTab ))
- --nCurY;
- }
- }
+ SkipCursorHorizontal(nCurX, nCurY, nOldX, nOldY, nMovX);
if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
- {
- BOOL bVFlip = FALSE;
- do
- {
- SCROW nLastRow = -1;
- bSkipCell = pDoc->RowHidden(nCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab );
- if (bSkipProtected && !bSkipCell)
- bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
- if (bSkipUnprotected && !bSkipCell)
- bSkipCell = !pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
-
- if (bSkipCell)
- {
- if ( nCurY<=0 || nCurY>=MAXROW )
- {
- if (bVFlip)
- {
- nCurY = nOldY;
- bSkipCell = FALSE;
- }
- else
- {
- nMovY = -nMovY;
- if (nMovY > 0) ++nCurY; else --nCurY; // zuruecknehmen
- bVFlip = TRUE;
- }
- }
- else
- if (nMovY > 0) ++nCurY; else --nCurY;
- }
- }
- while (bSkipCell);
-
- if (pDoc->IsHorOverlapped( nCurX, nCurY, nTab ))
- {
- aViewData.SetOldCursor( nCurX,nCurY );
- while (pDoc->IsHorOverlapped( nCurX, nCurY, nTab ))
- --nCurX;
- }
- }
+ SkipCursorVertical(nCurX, nCurY, nOldX, nOldY, nMovY);
MoveCursorAbs( nCurX, nCurY, eMode, bShift, FALSE, TRUE, bKeepSel );
}
More information about the Libreoffice-commits
mailing list