[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - include/svx sc/source svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 9 11:30:03 UTC 2021


 include/svx/weldeditview.hxx       |    1 +
 sc/source/ui/app/inputwin.cxx      |    7 ++++++-
 sc/source/ui/inc/inputwin.hxx      |    1 +
 svx/source/dialog/weldeditview.cxx |    4 +++-
 4 files changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 76bb5cb8578bdfe50ce6bef307e628037d938a94
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 9 10:15:01 2021 +0100
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Sep 9 13:29:27 2021 +0200

    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/+/121769
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index 4593d0ecf26a..004be7b609fb 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -68,6 +68,7 @@ public:
     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 52de56543a80..862d729edffd 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1596,12 +1596,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 20991ac85908..86cc6594910c 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -120,6 +120,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 7dd58d31275f..2f24c0cc8dfa 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -260,7 +260,7 @@ bool WeldEditView::MouseButtonDown(const MouseEvent& rMEvt)
     if (!IsMouseCaptured())
         CaptureMouse();
 
-    if (!HasFocus())
+    if (!HasFocus() && CanFocus())
     {
         GrabFocus();
         GetFocus();
@@ -1630,6 +1630,8 @@ void WeldEditView::LoseFocus()
     }
 }
 
+bool WeldEditView::CanFocus() const { return true; }
+
 css::uno::Reference<css::datatransfer::dnd::XDropTarget> WeldEditView::GetDropTarget()
 {
     if (!m_xDropTarget)


More information about the Libreoffice-commits mailing list