diff options
author | Abhilash Singh <abhilash300singh@gmail.com> | 2016-10-21 02:14:07 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-11-11 19:35:45 +0000 |
commit | 453de3473cf6f383c71466a1ed15e28b844ed7e5 (patch) | |
tree | b6f8c82c9f4136667d16e7a1cc827f1be01a7e4c /sc/source/ui/view/cellsh4.cxx | |
parent | 553cfda502a1516673233e409f91372766da6c4d (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>
Diffstat (limited to 'sc/source/ui/view/cellsh4.cxx')
-rw-r--r-- | sc/source/ui/view/cellsh4.cxx | 72 |
1 files changed, 64 insertions, 8 deletions
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: |