tdf#133807 re-present search dialog after a short timeout

Change-Id: Icc6016b3a9e3f25fd4c9e065e9f2d9570ad040c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96524
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx
index 6b45e83..8982e4d3 100644
--- a/include/svx/srchdlg.hxx
+++ b/include/svx/srchdlg.hxx
@@ -25,6 +25,7 @@
#include <svl/srchdefs.hxx>
#include <svl/srchitem.hxx>
#include <svx/svxdllapi.h>
#include <vcl/timer.hxx>
#include <memory>
#include <vector>

@@ -132,8 +133,12 @@ public:

    void SetSearchLabel(const OUString& rStr);

    // bring this window back to the foreground
    void Present();

private:
    SfxBindings&    rBindings;
    Timer           m_aPresentIdle;
    bool            bWriter;
    bool            bSearch;
    bool            bFormat;
@@ -255,6 +260,8 @@ private:
    SVX_DLLPRIVATE bool IsOtherOptionsExpanded() const;

    SVX_DLLPRIVATE short executeSubDialog(VclAbstractDialog * dialog);

    DECL_DLLPRIVATE_LINK(PresentTimeoutHdl_Impl, Timer*, void);
};

#endif
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx
index b1b0e45a..950726a 100644
--- a/sc/source/ui/dialogs/searchresults.cxx
+++ b/sc/source/ui/dialogs/searchresults.cxx
@@ -55,7 +55,7 @@ SearchResultsDlg::~SearchResultsDlg()
    SvxSearchDialog* pSearchDlg = static_cast<SvxSearchDialog*>(pChildWindow->GetController().get());
    if (!pSearchDlg)
        return;
    pSearchDlg->getDialog()->present();
    pSearchDlg->Present();
}

namespace
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index adab6f8..6653be8 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -255,6 +255,7 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi
    : SfxModelessDialogController(&rBind, pChildWin, pParent,
                                  "svx/ui/findreplacedialog.ui", "FindReplaceDialog")
    , rBindings(rBind)
    , m_aPresentIdle("Bring SvxSearchDialog to Foreground")
    , bWriter(false)
    , bSearch(true)
    , bFormat(false)
@@ -312,6 +313,9 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi
    , m_xAllSheetsCB(m_xBuilder->weld_check_button("allsheets"))
    , m_xCalcStrFT(m_xBuilder->weld_label("entirecells"))
{
    m_aPresentIdle.SetTimeout(50);
    m_aPresentIdle.SetInvokeHandler(LINK(this, SvxSearchDialog, PresentTimeoutHdl_Impl));

    m_xSearchTmplLB->make_sorted();
    m_xSearchAttrText->hide();
    m_xSearchLabel->show();
@@ -338,6 +342,18 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi
    Construct_Impl();
}

IMPL_LINK_NOARG(SvxSearchDialog, PresentTimeoutHdl_Impl, Timer*, void)
{
    getDialog()->present();
}

void SvxSearchDialog::Present()
{
    PresentTimeoutHdl_Impl(nullptr);
    // tdf#133807 try again in a short timeout
    m_aPresentIdle.Start();
}

void SvxSearchDialog::ChildWinDispose()
{
    rBindings.EnterRegistrations();
@@ -350,6 +366,7 @@ void SvxSearchDialog::ChildWinDispose()

SvxSearchDialog::~SvxSearchDialog()
{
    m_aPresentIdle.Stop();
}

void SvxSearchDialog::Construct_Impl()