diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-09 10:15:01 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-09 13:29:57 +0200 |
commit | 65fb647b3b95ebc6023b6e02c5fc2a130842eac7 (patch) | |
tree | 98748163f9b5e7fa02d334b026eebde85a73f566 | |
parent | ec23228a3a2fc4e8868f7f04b838313be59ad719 (diff) |
Resolves: tdf#144376 focus into protected ScTextWnd shouldn't be possible
the expectations are that this isn't possible and if it happens then
under windows there is a QueryCharPosition which will trigger the
deletion of the ScTextWnd EditView due to that expectation before it is
then unconditionally dereferenced
Change-Id: Ied5d8031ae7d74669a2958dbcdec87843a26d384
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121841
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | include/svx/weldeditview.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/inc/inputwin.hxx | 1 | ||||
-rw-r--r-- | svx/source/dialog/weldeditview.cxx | 4 |
4 files changed, 11 insertions, 2 deletions
diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx index 11f35c2e7164..821ae205ae67 100644 --- a/include/svx/weldeditview.hxx +++ b/include/svx/weldeditview.hxx @@ -74,6 +74,7 @@ protected: virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; virtual bool KeyInput(const KeyEvent& rKEvt) override; virtual bool Command(const CommandEvent& rCEvt) override; + virtual bool CanFocus() const; virtual void GetFocus() override; virtual void LoseFocus() override; virtual void Resize() override; diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index fadce637d2c5..1643d212e8ac 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1575,12 +1575,17 @@ bool ScTextWnd::MouseMove( const MouseEvent& rMEvt ) return m_xEditView && m_xEditView->MouseMove(rMEvt); } +bool ScTextWnd::CanFocus() const +{ + return SC_MOD()->IsEditMode(); +} + bool ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt ) { if (!HasFocus()) { StartEditEngine(); - if ( SC_MOD()->IsEditMode() ) + if (CanFocus()) TextGrabFocus(); } diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx index ab806987b78c..92ecbfcd990d 100644 --- a/sc/source/ui/inc/inputwin.hxx +++ b/sc/source/ui/inc/inputwin.hxx @@ -125,6 +125,7 @@ protected: virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; virtual bool Command( const CommandEvent& rCEvt ) override; virtual bool KeyInput(const KeyEvent& rKEvt) override; + virtual bool CanFocus() const override; virtual void GetFocus() override; virtual bool StartDrag() override; diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index 48819345fa55..a987ef2a4c33 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -136,7 +136,7 @@ bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt) if (!IsMouseCaptured()) CaptureMouse(); - if (!HasFocus()) + if (!HasFocus() && CanFocus()) { GrabFocus(); GetFocus(); @@ -1483,6 +1483,8 @@ void WeldEditView::LoseFocus() } } +bool WeldEditView::CanFocus() const { return true; } + namespace { class WeldEditViewUIObject final : public DrawingAreaUIObject |