summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-11-29 22:27:55 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-11-29 22:27:55 -0500
commitc1ba7793226bf70a15e2dca4141abb91d916f028 (patch)
tree140dd1dc2460bc7c18f064ffc6ffb2ebd265718a /sc
parenta3bcf5be4cb45441b0a95324e3e64593a28f1f9a (diff)
Extracted methods that may be used in another place.
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/tabview.hxx3
-rw-r--r--sc/source/ui/view/tabview2.cxx120
-rw-r--r--sc/source/ui/view/tabview3.cxx82
3 files changed, 125 insertions, 80 deletions
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 5ff45c883668..afe4fd03df06 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 91e5cc3cc96a..b6aaa5be6a9b 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 e963dca31f2d..1c4c02868f22 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 );
}