include/sfx2/weldutils.hxx | 4 +++- sw/inc/view.hxx | 2 ++ sw/source/uibase/sidebar/QuickFindPanel.cxx | 21 +++++++++++++++++++++ sw/source/uibase/sidebar/QuickFindPanel.hxx | 1 + 4 files changed, 27 insertions(+), 1 deletion(-)
New commits: commit 9f79c01035fb5851bcba1f8fc646437be84f7194 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Sun Aug 25 12:50:41 2024 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Mon Sep 2 19:45:00 2024 +0200 Related: tdf#162580 When upgrading from Find toolbar search to advanced Find and Replace search dialog, inherit (pre-fill) search field's term from current value of find bar's focused search entry Makes the Writer quick find panel behave as such. Change-Id: I2164f443d6ef120d86b001499f67795eaeaf224d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172375 Reviewed-by: Jim Raykowski <rayk...@gmail.com> Tested-by: Jenkins diff --git a/include/sfx2/weldutils.hxx b/include/sfx2/weldutils.hxx index 8ed6671a66b0..571d8c237c20 100644 --- a/include/sfx2/weldutils.hxx +++ b/include/sfx2/weldutils.hxx @@ -37,7 +37,7 @@ private: weld::Builder* m_pBuilder; bool m_bSideBar; - DECL_DLLPRIVATE_LINK(SelectHdl, const OUString&, void); + DECL_LINK(SelectHdl, const OUString&, void); DECL_DLLPRIVATE_LINK(ToggleMenuHdl, const OUString&, void); DECL_DLLPRIVATE_LINK(ChangedIconSizeHandler, LinkParamNone*, void); @@ -61,6 +61,8 @@ public: void dispose(); ~ToolbarUnoDispatcher(); + + void Select(const OUString& rCommand) { SelectHdl(rCommand); } }; #endif diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 64ad634276a4..9d096d9171d8 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -671,6 +671,8 @@ public: SAL_DLLPRIVATE virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) override; static SvxSearchItem* GetSearchItem() { return s_pSrchItem; } + static void SetSearchItem(SvxSearchItem* pSearchItem) { s_pSrchItem = pSearchItem; } + /// See SfxViewShell::getPart(). int getPart() const override; /// See SfxViewShell::dumpAsXml(). diff --git a/sw/source/uibase/sidebar/QuickFindPanel.cxx b/sw/source/uibase/sidebar/QuickFindPanel.cxx index 0df67a256742..483d6415d121 100644 --- a/sw/source/uibase/sidebar/QuickFindPanel.cxx +++ b/sw/source/uibase/sidebar/QuickFindPanel.cxx @@ -130,6 +130,9 @@ QuickFindPanel::QuickFindPanel(weld::Widget* pParent, const uno::Reference<frame m_xSearchOptionsToolbar->connect_clicked( LINK(this, QuickFindPanel, SearchOptionsToolbarClickedHandler)); + m_xFindAndReplaceToolbar->connect_clicked( + LINK(this, QuickFindPanel, FindAndReplaceToolbarClickedHandler)); + m_xSearchFindsList->connect_custom_get_size( LINK(this, QuickFindPanel, SearchFindsListCustomGetSizeHandler)); m_xSearchFindsList->connect_custom_render(LINK(this, QuickFindPanel, SearchFindsListRender)); @@ -174,6 +177,24 @@ IMPL_LINK_NOARG(QuickFindPanel, SearchOptionsToolbarClickedHandler, const OUStri } } +// tdf#162580 related: When upgrading from Find toolbar search to advanced Find and Replace +// search dialog, inherit (pre-fill) search field's term from current value of find bar's +// focused search entry +IMPL_LINK(QuickFindPanel, FindAndReplaceToolbarClickedHandler, const OUString&, rCommand, void) +{ + if (!SwView::GetSearchDialog()) + { + SvxSearchItem* pSearchItem = SwView::GetSearchItem(); + if (!pSearchItem) + { + pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM); + SwView::SetSearchItem(pSearchItem); + } + pSearchItem->SetSearchString(m_xSearchFindEntry->get_text()); + } + m_xFindAndReplaceToolbarDispatch->Select(rCommand); +} + QuickFindPanel::~QuickFindPanel() { m_xSearchFindEntry.reset(); diff --git a/sw/source/uibase/sidebar/QuickFindPanel.hxx b/sw/source/uibase/sidebar/QuickFindPanel.hxx index 10d3664832cb..2875229bb9c2 100644 --- a/sw/source/uibase/sidebar/QuickFindPanel.hxx +++ b/sw/source/uibase/sidebar/QuickFindPanel.hxx @@ -80,6 +80,7 @@ private: DECL_LINK(SearchFindsListRowActivatedHandler, weld::TreeView&, bool); DECL_LINK(SearchFindsListMousePressHandler, const MouseEvent&, bool); DECL_LINK(SearchOptionsToolbarClickedHandler, const OUString&, void); + DECL_LINK(FindAndReplaceToolbarClickedHandler, const OUString&, void); void FillSearchFindsList(); };