sc/source/ui/inc/cellsh.hxx | 8 +++- sc/source/ui/inc/tabview.hxx | 3 + sc/source/ui/view/cellsh.cxx | 5 +- sc/source/ui/view/cellsh4.cxx | 72 ++++++++++++++++++++++++++++++++++++----- sc/source/ui/view/tabvwsh4.cxx | 2 - 5 files changed, 77 insertions(+), 13 deletions(-)
New commits: commit 453de3473cf6f383c71466a1ed15e28b844ed7e5 Author: Abhilash Singh <abhilash300si...@gmail.com> Date: Fri Oct 21 02:14:07 2016 +0530 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 <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx index 2201e03..5b0c7d1 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 cadeb94..948f599 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 a04185d..cb2f799 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 612a674..881593e 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 2f27b5e..f3b4666 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 ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits