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 <raykowj@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user