summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhilash Singh <abhilash300singh@gmail.com>2016-10-21 02:14:07 +0530
committerEike Rathke <erack@redhat.com>2016-11-11 19:35:45 +0000
commit453de3473cf6f383c71466a1ed15e28b844ed7e5 (patch)
treeb6f8c82c9f4136667d16e7a1cc827f1be01a7e4c
parent553cfda502a1516673233e409f91372766da6c4d (diff)
tdf#46200 Use the Scroll Lock key as a toggling lock key like Excel
Change-Id: I153522a90674f3f3c4db4ff300ef5cf4075704e3 Reviewed-on: https://gerrit.libreoffice.org/30117 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/ui/inc/cellsh.hxx8
-rw-r--r--sc/source/ui/inc/tabview.hxx3
-rw-r--r--sc/source/ui/view/cellsh.cxx5
-rw-r--r--sc/source/ui/view/cellsh4.cxx72
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx2
5 files changed, 77 insertions, 13 deletions
diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
index 2201e03f0bf5..5b0c7d1a4ddd 100644
--- a/sc/source/ui/inc/cellsh.hxx
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -29,6 +29,7 @@
#include <memory>
#include "formatsh.hxx"
#include "address.hxx"
+#include <vcl/window.hxx>
class SvxClipboardFormatItem;
class TransferableDataHelper;
@@ -71,6 +72,8 @@ private:
RotateTransliteration m_aRotateCase;
+ VclPtr<vcl::Window> pFrameWin;
+
public:
SFX_DECL_INTERFACE(SCID_CELL_SHELL)
@@ -79,7 +82,7 @@ private:
static void InitInterface_Impl();
public:
- ScCellShell(ScViewData* pData);
+ ScCellShell( ScViewData* pData, VclPtr<vcl::Window> pFrameWin );
virtual ~ScCellShell() override;
void Execute(SfxRequest &);
@@ -103,6 +106,9 @@ public:
void ExecutePage( SfxRequest& rReq );
void ExecutePageSel( SfxRequest& rReq );
void ExecuteMove( SfxRequest& rReq );
+
+ VclPtr<vcl::Window> GetFrameWin();
+
static void GetStateCursor( SfxItemSet& rSet );
};
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index cadeb94e9cc1..948f599a30df 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -222,7 +222,6 @@ private:
static void SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, bool bLayoutRTL );
static long GetScrollBarPos( ScrollBar& rScroll );
- void GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY);
void GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
@@ -427,6 +426,8 @@ public:
void FindNextUnprot( bool bShift, bool bInSelection );
+ void GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY);
+
SC_DLLPUBLIC void SetTabNo( SCTAB nTab, bool bNew = false, bool bExtendSelection = false, bool bSameTabButMoved = false );
void SelectNextTab( short nDir, bool bExtendSelection );
void SelectTabPage( const sal_uInt16 nTab );
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index a04185d37a87..cb2f79995cde 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -73,10 +73,11 @@ void ScCellShell::InitInterface_Impl()
GetStaticInterface()->RegisterPopupMenu("cell");
}
-ScCellShell::ScCellShell(ScViewData* pData) :
+ScCellShell::ScCellShell(ScViewData* pData, VclPtr<vcl::Window> frameWin) :
ScFormatShell(pData),
pImpl( new CellShell_Impl() ),
- bPastePossible(false)
+ bPastePossible(false),
+ pFrameWin(frameWin)
{
SetHelpId(HID_SCSHELL_CELLSH);
SetName("Cell");
diff --git a/sc/source/ui/view/cellsh4.cxx b/sc/source/ui/view/cellsh4.cxx
index 612a6749fc28..881593ee9019 100644
--- a/sc/source/ui/view/cellsh4.cxx
+++ b/sc/source/ui/view/cellsh4.cxx
@@ -31,6 +31,11 @@
#include <vcl/svapp.hxx>
+VclPtr<vcl::Window> ScCellShell::GetFrameWin()
+{
+ return pFrameWin;
+}
+
void ScCellShell::ExecuteCursor( SfxRequest& rReq )
{
ScViewData* pData = GetViewData();
@@ -120,12 +125,22 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
else
pTabViewShell->SetForceFocusOnCurCell(false);
+ // If ScrollLock key is active, cell cursor stays on the current cell while
+ // scrolling the grid.
+ bool bScrollLock = true;
+ KeyIndicatorState eState = GetFrameWin()->GetIndicatorState();
+ if (eState & KeyIndicatorState::SCROLLLOCK)
+ bScrollLock = true;
+
//OS: once for all should do, however!
pTabViewShell->ExecuteInputDirect();
switch ( nSlotId )
{
case SID_CURSORDOWN:
- pTabViewShell->MoveCursorRel( 0, nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
+ if (bScrollLock)
+ pTabViewShell->ScrollY( nRepeat, SC_SPLIT_BOTTOM );
+ else
+ pTabViewShell->MoveCursorRel( 0, nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
break;
case SID_CURSORBLKDOWN:
@@ -133,7 +148,10 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
break;
case SID_CURSORUP:
- pTabViewShell->MoveCursorRel( 0, -nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
+ if (bScrollLock)
+ pTabViewShell->ScrollY( -nRepeat, SC_SPLIT_BOTTOM);
+ else
+ pTabViewShell->MoveCursorRel( 0, -nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
break;
case SID_CURSORBLKUP:
@@ -141,7 +159,10 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
break;
case SID_CURSORLEFT:
- pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(-nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
+ if (bScrollLock)
+ pTabViewShell->ScrollX( static_cast<SCsCOL>(-nRepeat * nRTLSign), SC_SPLIT_LEFT);
+ else
+ pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(-nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
break;
case SID_CURSORBLKLEFT:
@@ -149,7 +170,10 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
break;
case SID_CURSORRIGHT:
- pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
+ if (bScrollLock)
+ pTabViewShell->ScrollX( static_cast<SCsCOL>(nRepeat * nRTLSign), SC_SPLIT_LEFT);
+ else
+ pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
break;
case SID_CURSORBLKRIGHT:
@@ -157,19 +181,51 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
break;
case SID_CURSORPAGEDOWN:
- pTabViewShell->MoveCursorPage( 0, nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
+ if (bScrollLock)
+ {
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ pTabViewShell->GetPageMoveEndPosition( 0, nRepeat, nPageX, nPageY);
+ pTabViewShell->ScrollY( nPageY, SC_SPLIT_BOTTOM);
+ }
+ else
+ pTabViewShell->MoveCursorPage( 0, nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
break;
case SID_CURSORPAGEUP:
- pTabViewShell->MoveCursorPage( 0, -nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
+ if (bScrollLock)
+ {
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ pTabViewShell->GetPageMoveEndPosition( 0, nRepeat, nPageX, nPageY);
+ pTabViewShell->ScrollY( -nPageY, SC_SPLIT_BOTTOM);
+ }
+ else
+ pTabViewShell->MoveCursorPage( 0, -nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
break;
case SID_CURSORPAGERIGHT_: //XXX !!!
- pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
+ if (bScrollLock)
+ {
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ pTabViewShell->GetPageMoveEndPosition( static_cast<SCsCOL>(nRepeat), 0, nPageX, nPageY);
+ pTabViewShell->ScrollX( nPageX, SC_SPLIT_LEFT);
+ }
+ else
+ pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
break;
case SID_CURSORPAGELEFT_: //XXX !!!
- pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(-nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
+ if (bScrollLock)
+ {
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ pTabViewShell->GetPageMoveEndPosition( static_cast<SCsCOL>(nRepeat), 0, nPageX, nPageY);
+ pTabViewShell->ScrollX( -nPageX, SC_SPLIT_LEFT);
+ }
+ else
+ pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(-nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
break;
default:
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 2f27b5ee769b..f3b4666653f1 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -776,7 +776,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if(!pCellShell) // is anyway always used
{
- pCellShell = new ScCellShell( &GetViewData() );
+ pCellShell = new ScCellShell( &GetViewData(), GetFrameWin() );
pCellShell->SetRepeatTarget( &aTarget );
}