include/svx/srchdlg.hxx                        |    2 
 svx/source/dialog/srchdlg.cxx                  |    6 ++
 svx/source/tbxctrls/tbunosearchcontrollers.cxx |   66 ++++++++++++++++++++++++-
 3 files changed, 73 insertions(+), 1 deletion(-)

New commits:
commit ef503a4abf51b6eeac26d80444b5d69a98674db5
Author:     Jim Raykowski <[email protected]>
AuthorDate: Tue Nov 11 22:40:11 2025 -0900
Commit:     Jim Raykowski <[email protected]>
CommitDate: Sat Nov 15 06:52:15 2025 +0100

    tdf#162580 copy query text from Find toolbar to Find&Replace dialog
    
    This patch copies the query text to the Find&Replace dialog when Ctrl+H
    is pressed in the Find toolbar find text field control. Normally Ctrl+H
    toggles the Find&Replace dialog on and off. This patch makes the dialog
    not toggle off when pressed in the Find toolbar find text field control,
    it either opens the Find&Replace dialog and copies the query text or
    copies the query text to the already open Find&Replace dialog.
    
    Change-Id: I6aa28f9e47431bdc75d63c7f68469203bc3b59df
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193837
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <[email protected]>

diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx
index 7b874bd9027a..34d82fbb9d28 100644
--- a/include/svx/srchdlg.hxx
+++ b/include/svx/srchdlg.hxx
@@ -143,6 +143,8 @@ public:
     // bring this window back to the foreground
     void Present();
 
+    void SetSearchLBEntryTextAndGrabFocus(const OUString& rStr);
+
 private:
     SfxBindings& m_rBindings;
     Timer           m_aPresentIdle;
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 6841fe36a0f5..73fb1f3a7472 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -359,6 +359,12 @@ void SvxSearchDialog::Present()
     m_aPresentIdle.Start();
 }
 
+void SvxSearchDialog::SetSearchLBEntryTextAndGrabFocus(const OUString& rStr)
+{
+    m_xSearchLB->set_entry_text(rStr);
+    m_xSearchLB->grab_focus();
+}
+
 void SvxSearchDialog::ChildWinDispose()
 {
     m_rBindings.EnterRegistrations();
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx 
b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index 7f24d173cd3d..59f8c4389a70 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -63,6 +63,10 @@
 
 #include <findtextfield.hxx>
 
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+
 using namespace css;
 
 namespace {
@@ -352,8 +356,68 @@ IMPL_LINK(FindTextFieldControl, KeyInputHdl, const 
KeyEvent&, rKeyEvent, bool)
             bRet = true;
         }
         else if (aCommand == ".uno:SearchDialog")
+        {
+#if HAVE_FEATURE_DESKTOP
+            const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
+            SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+            if (pViewFrm)
+            {
+                SvxSearchDialogWrapper* pWrp
+                    = 
static_cast<SvxSearchDialogWrapper*>(pViewFrm->GetChildWindow(nId));
+                if (pWrp) // if the search dialog wrapper window exists
+                {
+                    SvxSearchDialog* pSearchDialog = pWrp->getDialog();
+                    assert(pSearchDialog);
+                    if (pSearchDialog) // if we have the wrapper window this 
should be good, shouldn't it?
+                    {
+                        pSearchDialog->SetSearchLBEntryTextAndGrabFocus(
+                            m_xWidget->get_active_text());
+                        pSearchDialog->Present();
+                        bRet = true;
+                    }
+                    else // likely not needed
+                    {
+                        
pViewFrm->GetBindings().ExecuteSynchron(SID_SEARCH_DLG);
+                        pWrp = 
static_cast<SvxSearchDialogWrapper*>(pViewFrm->GetChildWindow(nId));
+                        if (pWrp)
+                        {
+                            pSearchDialog = pWrp->getDialog();
+                            assert(pSearchDialog);
+                            if (pSearchDialog)
+                            {
+                                
pSearchDialog->SetSearchLBEntryTextAndGrabFocus(
+                                    m_xWidget->get_active_text());
+                                pSearchDialog->Present();
+                                bRet = true;
+                            }
+                        }
+                    }
+                }
+                else // the search dialog wrapper window does not exist so try 
to make it exist
+                {
+                    pViewFrm->GetBindings().ExecuteSynchron(SID_SEARCH_DLG);
+                    pWrp = 
static_cast<SvxSearchDialogWrapper*>(pViewFrm->GetChildWindow(nId));
+                    if (pWrp)
+                    {
+                        SvxSearchDialog* pSearchDialog = pWrp->getDialog();
+                        assert(pSearchDialog);
+                        if (pSearchDialog)
+                        {
+                            pSearchDialog->SetSearchLBEntryTextAndGrabFocus(
+                                m_xWidget->get_active_text());
+                            pSearchDialog->Present();
+                            bRet = true;
+                        }
+                    }
+                }
+            }
+            else // probably shouldn't happen, be safe anyway
+                bRet = m_pAcc->execute(awtKey);
+        }
+#else
             bRet = m_pAcc->execute(awtKey);
-
+        }
+#endif
         // find-shortcut called with focus already in find
         if (aCommand == "vnd.sun.star.findbar:FocusToFindbar")
         {

Reply via email to