sw/source/core/layout/fly.cxx                 |    4 ++--
 sw/source/uibase/docvw/UnfloatTableButton.cxx |    5 ++++-
 sw/source/uibase/inc/FrameControl.hxx         |    1 +
 sw/source/uibase/inc/UnfloatTableButton.hxx   |    4 ++--
 4 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 2f42d8acd2d06f848c9e680c42a0f7834a9a641f
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Nov 16 08:29:26 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 16 10:09:06 2023 +0100

    sw floattable, delete UI: fix unfloat button for cant-split frames
    
    Open sw/qa/extras/uiwriter/data/unfloatable_floating_table.odt, select
    the TextFrame, click on the "unfloat" button that appears, then nothing
    happens.
    
    This is a problem since commit 51379fb3d46e5891bdaea0122bd62b0753663da3
    (weld writer's FrameControl MenuButtons, 2020-12-03), the old
    MouseButtonDown() callback is never invoked.
    
    Fix the problem similar to what SwHeaderFooterWin does, which works:
    instead of overriding the dead MouseButtonDown(), explicitly connect the
    click handler to the weld::Button widget.
    
    Also adjust SwFlyFrame::ActiveUnfloatButton() to use the welded
    callback, this way CppunitTest_sw_uiwriter2's testUnfloating covers the
    fix.
    
    Change-Id: I1180fc6a0ae2df7c01c273a5ef92dd8915ca70a9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159493
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 78aa7f604b20..33880623a481 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2105,9 +2105,9 @@ void SwFlyFrame::ActiveUnfloatButton(SwWrtShell* pWrtSh)
     SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
     SwFrameControlsManager& rMngr = rEditWin.GetFrameControlsManager();
     SwFrameControlPtr pControl = 
rMngr.GetControl(FrameControlType::FloatingTable, this);
-    if (pControl && pControl->GetWindow())
+    if (pControl && pControl->GetIFacePtr())
     {
-        pControl->GetWindow()->MouseButtonDown(MouseEvent());
+        pControl->GetIFacePtr()->GetButton()->clicked();
     }
 }
 
diff --git a/sw/source/uibase/docvw/UnfloatTableButton.cxx 
b/sw/source/uibase/docvw/UnfloatTableButton.cxx
index e1cdf8c7aad9..30d1d97aaacc 100644
--- a/sw/source/uibase/docvw/UnfloatTableButton.cxx
+++ b/sw/source/uibase/docvw/UnfloatTableButton.cxx
@@ -53,9 +53,12 @@ UnfloatTableButton::UnfloatTableButton(SwEditWin* pEditWin, 
const SwFrame* pFram
 {
     m_xPushButton->set_accessible_name(m_sLabel);
     m_xVirDev = m_xPushButton->create_virtual_device();
+    m_xPushButton->connect_clicked(LINK(this, UnfloatTableButton, ClickHdl));
     SetVirDevFont();
 }
 
+weld::Button* UnfloatTableButton::GetButton() { return m_xPushButton.get(); }
+
 UnfloatTableButton::~UnfloatTableButton() { disposeOnce(); }
 
 void UnfloatTableButton::dispose()
@@ -89,7 +92,7 @@ void UnfloatTableButton::SetOffset(Point aTopRightPixel)
     PaintButton();
 }
 
-void UnfloatTableButton::MouseButtonDown(const MouseEvent& /*rMEvt*/)
+IMPL_LINK_NOARG(UnfloatTableButton, ClickHdl, weld::Button&, void)
 {
     assert(GetFrame()->IsFlyFrame());
     // const_cast is needed because of bad design of ISwFrameControl and 
derived classes
diff --git a/sw/source/uibase/inc/FrameControl.hxx 
b/sw/source/uibase/inc/FrameControl.hxx
index 7bdc9ff6bb8b..4043f834f94b 100644
--- a/sw/source/uibase/inc/FrameControl.hxx
+++ b/sw/source/uibase/inc/FrameControl.hxx
@@ -32,6 +32,7 @@ public:
 
     virtual const SwFrame* GetFrame() = 0;
     virtual SwEditWin*   GetEditWin() = 0;
+    virtual weld::Button* GetButton() { return nullptr; };
 };
 
 class SwFrameControl final
diff --git a/sw/source/uibase/inc/UnfloatTableButton.hxx 
b/sw/source/uibase/inc/UnfloatTableButton.hxx
index 164b240f28b1..8803b5169173 100644
--- a/sw/source/uibase/inc/UnfloatTableButton.hxx
+++ b/sw/source/uibase/inc/UnfloatTableButton.hxx
@@ -34,14 +34,14 @@ public:
 
     void SetOffset(Point aTopRightPixel);
 
-    virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
-
     virtual void ShowAll(bool bShow) override;
     virtual bool Contains(const Point& rDocPt) const override;
 
     virtual void SetReadonly(bool bReadonly) override;
+    weld::Button* GetButton() override;
 
 private:
+    DECL_LINK(ClickHdl, weld::Button&, void);
     void PaintButton();
 };
 

Reply via email to