diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-30 16:06:39 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-30 20:43:54 +0100 |
commit | c946abb704c9f72c1fdc696ac72c6a9381d95f16 (patch) | |
tree | 650ab180f9692667cbbfd3815ebe7967057900d4 /sc | |
parent | a499b4eb2ac1bd557dfcd1b00d1bf5916572e6d6 (diff) |
tdf#137620 add explicit SurroundingText support to ScGridWindow
Change-Id: I51cf18d635c7a32e88c4afd4c59756ef93fc9c4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105076
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 48 | ||||
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/inputhdl.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 42 |
4 files changed, 98 insertions, 0 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 075e012f00a5..fef75313ca04 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3831,6 +3831,54 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, bool bStartEdit /* = false return bUsed; } +OUString ScInputHandler::GetSurroundingText() +{ + if (eMode != SC_INPUT_NONE) + { + UpdateActiveView(); + if (pTableView || pTopView) + { + if (pTableView) + return pTableView->GetSurroundingText(); + else if (pTopView) // call only once + return pTopView->GetSurroundingText(); + } + } + return OUString(); +} + +Selection ScInputHandler::GetSurroundingTextSelection() +{ + if (eMode != SC_INPUT_NONE) + { + UpdateActiveView(); + if (pTableView || pTopView) + { + if (pTableView) + return pTableView->GetSurroundingTextSelection(); + else if (pTopView) // call only once + return pTopView->GetSurroundingTextSelection(); + } + } + return Selection(0, 0); +} + +bool ScInputHandler::DeleteSurroundingText(const Selection& rSelection) +{ + if (eMode != SC_INPUT_NONE) + { + UpdateActiveView(); + if (pTableView || pTopView) + { + if (pTableView) + return pTableView->DeleteSurroundingText(rSelection); + else if (pTopView) // call only once + return pTopView->DeleteSurroundingText(rSelection); + } + } + return false; +} + void ScInputHandler::InputCommand( const CommandEvent& rCEvt ) { if ( rCEvt.GetCommand() == CommandEventId::CursorPos ) diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 448c33ba6b10..2202b3647563 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -337,6 +337,10 @@ public: rtl::Reference<sdr::overlay::OverlayManager> getOverlayManager() const; void flushOverlayManager(); + virtual OUString GetSurroundingText() const override; + virtual Selection GetSurroundingTextSelection() const override; + virtual bool DeleteSurroundingText(const Selection& rSelection) override; + virtual void Command( const CommandEvent& rCEvt ) override; virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index c99589fd70dc..ddd3f4f49e8b 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -203,6 +203,10 @@ public: void InputCommand( const CommandEvent& rCEvt ); + OUString GetSurroundingText(); + Selection GetSurroundingTextSelection(); + bool DeleteSurroundingText(const Selection& rSelection); + void InsertFunction( const OUString& rFuncName, bool bAddPar = true ); void ClearText(); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 67b815bfc1c1..c3815041f3eb 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3348,6 +3348,48 @@ void ScGridWindow::KeyInput(const KeyEvent& rKEvt) Window::KeyInput(rKEvt); } +OUString ScGridWindow::GetSurroundingText() const +{ + bool bEditView = mrViewData.HasEditView(eWhich); + if (bEditView) + { + ScModule* pScMod = SC_MOD(); + ScInputHandler* pHdl = pScMod->GetInputHdl(mrViewData.GetViewShell()); + if (pHdl) + return pHdl->GetSurroundingText(); + } + + return Window::GetSurroundingText(); +} + +Selection ScGridWindow::GetSurroundingTextSelection() const +{ + bool bEditView = mrViewData.HasEditView(eWhich); + if (bEditView) + { + ScModule* pScMod = SC_MOD(); + ScInputHandler* pHdl = pScMod->GetInputHdl(mrViewData.GetViewShell()); + if (pHdl) + return pHdl->GetSurroundingTextSelection(); + } + + return Window::GetSurroundingTextSelection(); +} + +bool ScGridWindow::DeleteSurroundingText(const Selection& rSelection) +{ + bool bEditView = mrViewData.HasEditView(eWhich); + if (bEditView) + { + ScModule* pScMod = SC_MOD(); + ScInputHandler* pHdl = pScMod->GetInputHdl(mrViewData.GetViewShell()); + if (pHdl) + return pHdl->DeleteSurroundingText(rSelection); + } + + return Window::DeleteSurroundingText(rSelection); +} + void ScGridWindow::StopMarking() { DrawEndAction(); // Cancel Select/move on Drawing-Layer |