[Libreoffice-commits] core.git: sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 30 19:44:40 UTC 2020
sc/source/ui/app/inputhdl.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++
sc/source/ui/inc/gridwin.hxx | 4 +++
sc/source/ui/inc/inputhdl.hxx | 4 +++
sc/source/ui/view/gridwin.cxx | 42 ++++++++++++++++++++++++++++++++++++
4 files changed, 98 insertions(+)
New commits:
commit c946abb704c9f72c1fdc696ac72c6a9381d95f16
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Oct 30 16:06:39 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Oct 30 20:43:54 2020 +0100
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 at redhat.com>
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
More information about the Libreoffice-commits
mailing list