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 c879d43af18c3b4318d5299d3179c8bd741ac80e Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Nov 16 08:29:26 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Fri Nov 17 11:35:07 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. (cherry picked from commit 2f42d8acd2d06f848c9e680c42a0f7834a9a641f) Change-Id: I1180fc6a0ae2df7c01c273a5ef92dd8915ca70a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159552 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index e0b9d1837e67..bfc36bcef62b 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2106,9 +2106,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 a52194e39a62..3673d82e312f 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 4ab1d61b0303..4dd61c1494eb 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(); };