tdf#154818 - Find bar: remember and reuse last search string

If there exists no last search string in the view options and there
exists a search history, preselect the last search item.

Change-Id: Ic6056e02eaf6c0ee7e266e47ba961dff11e9f9da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151072
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index d43222f..1ae8a0b 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -268,9 +268,12 @@ void FindTextFieldControl::SetTextToSelected_Impl()
        {
            css::uno::Any aUserItem = aDlgOpt.GetUserItem("UserItem");
            aUserItem >>= aString;
            // prepopulate with last search word (fdo#84256)
            m_xWidget->set_entry_text(aString);
        }
        else if (get_count() > 0)
            aString = m_xWidget->get_text(0);

        // prepopulate with last search word (fdo#84256)
        m_xWidget->set_entry_text(aString);
    }
}