desktop/source/lib/init.cxx | 3 ++- sc/inc/inputopt.hxx | 3 +++ sc/inc/sc.hrc | 1 + sc/sdi/cellsh.sdi | 2 ++ sc/sdi/scalc.sdi | 15 +++++++++++++++ sc/source/ui/app/inputhdl.cxx | 14 ++++++++++++++ sc/source/ui/inc/tabvwsh.hxx | 5 +++++ sc/source/ui/view/cellsh3.cxx | 20 ++++++++++++++++++++ 8 files changed, 62 insertions(+), 1 deletion(-)
New commits: commit 284f2759dedbc2375abdbaab5258efda4a52b8f5 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Mon Dec 4 14:08:09 2023 +0000 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Dec 18 16:33:43 2023 +0100 calc: Add option to keep edit mode on enter/tab This change makes it so that, rather than leaving edit mode, enter and tab keep editing the new cell when they have moved. This is important on devices with an onscreen keyboard (e.g. iPads, Android tablets, Convertible Laptops, etc.), particularly in Collabora Online, as exiting edit mode hides the onscreen keyboard. It is not desirable to enable this by default, as arrow keys cannot move around the document when we are in edit mode (they move within the cell). Therefore, this commit also adds an .uno command so that we can activate or deactivate the option. In LibreOfficeKit we want to make sure not to share this setting among different users, so we also add this option in the view shell and switch which one we care about based on whether Kit is active. Change-Id: I5e6c93c64af0d201a8ec045fea5546e189baca74 Signed-off-by: Skyler Grey <skyler.g...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160313 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 13fcfad60f1f..8855e9a60ed2 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3852,7 +3852,8 @@ static void doc_iniUnoCommands () OUString(".uno:InsertPlainTextContentControl"), OUString(".uno:InsertPictureContentControl"), OUString(".uno:DataFilterAutoFilter"), - OUString(".uno:CellProtection") + OUString(".uno:CellProtection"), + OUString(".uno:MoveKeepInsertMode") }; util::URL aCommandURL; diff --git a/sc/inc/inputopt.hxx b/sc/inc/inputopt.hxx index 05e59aad5716..aa4b4078e5df 100644 --- a/sc/inc/inputopt.hxx +++ b/sc/inc/inputopt.hxx @@ -26,6 +26,7 @@ class ScInputOptions private: sal_uInt16 nMoveDir; // enum ScDirection bool bMoveSelection; + bool bMoveKeepEdit; bool bEnterEdit; bool bExtendFormat; bool bRangeFinder; @@ -47,6 +48,8 @@ public: bool GetMoveSelection() const { return bMoveSelection; } void SetEnterEdit(bool bSet) { bEnterEdit = bSet; } bool GetEnterEdit() const { return bEnterEdit; } + void SetMoveKeepEdit(bool bSet) { bMoveKeepEdit = bSet; } + bool GetMoveKeepEdit() const { return bMoveKeepEdit; } void SetExtendFormat(bool bSet) { bExtendFormat = bSet; } bool GetExtendFormat() const { return bExtendFormat; } void SetRangeFinder(bool bSet) { bRangeFinder = bSet; } diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 7d8e02aeed0d..89fa9058070c 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -247,6 +247,7 @@ class SvxZoomSliderItem; #define SID_OPEN_CALC (SC_FUNCTION_START + 4) #define SID_CONVERT_FORMULA_TO_VALUE (SC_FUNCTION_START + 5) +#define FID_MOVE_KEEP_INSERT_MODE (SC_FUNCTION_START + 6) #ifndef FILE_MENU_END // duplicated in sfx2/sfxsids.hrc #define FILE_MENU_END (SC_FUNCTION_START + 20) #endif diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 84217c63c949..7370d142607e 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -446,6 +446,8 @@ interface CellMovement ] SID_DATA_SELECT [ ExecMethod = Execute; StateMethod = GetState; ] SID_DETECTIVE_FILLMODE [ ExecMethod = Execute; StateMethod = GetState; ] // api: + + FID_MOVE_KEEP_INSERT_MODE [ ExecMethod = Execute; ] } diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 614293cc90bb..c62c8c549d10 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -6667,3 +6667,18 @@ SfxVoidItem AutoSum SID_AUTO_SUM ToolBoxConfig = TRUE, GroupId = SfxGroupId::Intern; ] + + +SfxVoidItem MoveKeepInsertMode FID_MOVE_KEEP_INSERT_MODE +(SfxBoolItem Enable FID_MOVE_KEEP_INSERT_MODE) +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + GroupId = SfxGroupId::Application; +] diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 1153a7dc03d4..0f7a2afc858f 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3816,6 +3816,14 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, bool bStartEdit /* = false if (pActiveViewSh) pActiveViewSh->FindNextUnprot( bShift, true ); + + ScModule* pScMod = SC_MOD(); + const ScInputOptions& rOpt = pScMod->GetInputOptions(); + + if ( (rOpt.GetMoveKeepEdit() && !comphelper::LibreOfficeKit::isActive()) + || (pActiveViewSh->GetMoveKeepEdit() && comphelper::LibreOfficeKit::isActive()) ) + pScMod->SetInputMode( SC_INPUT_TABLE ); + return true; } @@ -3856,6 +3864,12 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, bool bStartEdit /* = false if (pActiveViewSh) pActiveViewSh->MoveCursorEnter( bShift && !bControl ); + ScModule* pScMod = SC_MOD(); + const ScInputOptions& rOpt = pScMod->GetInputOptions(); + if ( (rOpt.GetMoveKeepEdit() && !comphelper::LibreOfficeKit::isActive()) + || (pActiveViewSh->GetMoveKeepEdit() && comphelper::LibreOfficeKit::isActive()) ) + pScMod->SetInputMode( SC_INPUT_TABLE ); + bUsed = true; } break; diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 54998f57db6d..734906e50176 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -174,6 +174,8 @@ private: bool bInPrepareClose; bool bInDispose; + bool bMoveKeepEdit; + sal_uInt16 nCurRefDlgId; std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster; @@ -441,6 +443,9 @@ public: void ResetDragObject(); void SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea); void SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText); + + void SetMoveKeepEdit(bool value) { bMoveKeepEdit = value; }; + bool GetMoveKeepEdit() { return bMoveKeepEdit; }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index dab2ee7b6a3f..89e411952ec9 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -40,6 +40,7 @@ #include <autoform.hxx> #include <cellsh.hxx> #include <inputhdl.hxx> +#include <inputopt.hxx> #include <editable.hxx> #include <funcdesc.hxx> #include <markdata.hxx> @@ -1088,6 +1089,25 @@ void ScCellShell::Execute( SfxRequest& rReq ) OSL_FAIL("old slot SID_MARKAREA"); break; + case FID_MOVE_KEEP_INSERT_MODE: + { + const SfxBoolItem* pEnabledArg = rReq.GetArg<SfxBoolItem>(FID_MOVE_KEEP_INSERT_MODE); + if (!pEnabledArg) { + SAL_WARN("sfx.appl", "FID_MOVE_KEEP_INSERT_MODE: must specify if you would like this to be enabled"); + break; + } + + ScInputOptions aInputOptions = pScMod->GetInputOptions(); + + aInputOptions.SetMoveKeepEdit(pEnabledArg->GetValue()); + pScMod->SetInputOptions(aInputOptions); + + if (comphelper::LibreOfficeKit::isActive()) + pTabViewShell->SetMoveKeepEdit(pEnabledArg->GetValue()); + + break; + } + default: OSL_FAIL("ScCellShell::Execute: unknown slot"); break;