Resolves tdf#122322 - Modifying max number of saved word searches

Expert configuration Common::Misc::FindReplaceRememberedSearches
defaulting to 10 introduced

Change-Id: Id51bb78ee1f5ad9e73fa56e5f2d07773c528f9a7
Reviewed-on: https://gerrit.libreoffice.org/67614
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <tietze.heiko@gmail.com>
diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx
index 4b82db8..5b202ae 100644
--- a/include/svx/srchdlg.hxx
+++ b/include/svx/srchdlg.hxx
@@ -200,6 +200,7 @@ private:
    VclPtr<RadioButton>    m_pColumnsBtn;
    VclPtr<CheckBox>       m_pAllSheetsCB;


    SfxBindings&    rBindings;
    bool            bWriter;
    bool            bSearch;
@@ -214,6 +215,7 @@ private:
    OUString        aLayoutWriterStr;
    OUString        aLayoutCalcStr;
    OUString        aCalcStr;
    sal_uInt16      nRememberSize;

    std::vector<OUString> aSearchStrings;
    std::vector<OUString> aReplaceStrings;
diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu
index 6c80882..3e3223a 100644
--- a/officecfg/registry/data/org/openoffice/Office/Common.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu
@@ -492,6 +492,9 @@
        <it>--------------------</it>
      </value>
    </prop>
    <prop oor:name="FindReplaceRememberedSearches">
     <value>10</value>
    </prop>
  </node>
  <node oor:name="Save">
    <node oor:name="Document">
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index d39e494..324f220 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5641,6 +5641,11 @@
          <desc>Contains the Personas installed through extensions</desc>
        </info>
      </set>
      <prop oor:name="FindReplaceRememberedSearches" oor:type="xs:int" oor:nillable="false">
        <info>
          <desc>Number of saved searches in the Find and Replace dialog.</desc>
        </info>
      </prop>
    </group>
    <group oor:name="Forms">
      <info>
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 425210c..d23071a 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -17,7 +17,6 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#include <sal/macros.h>
#include <vcl/wrkwin.hxx>
#include <vcl/timer.hxx>
@@ -74,6 +73,7 @@
#include <memory>

#include <svx/xdef.hxx>
#include <officecfg/Office/Common.hxx>

using namespace com::sun::star::i18n;
using namespace com::sun::star::uno;
@@ -81,9 +81,6 @@ using namespace com::sun::star::accessibility;
using namespace com::sun::star;
using namespace comphelper;


#define REMEMBER_SIZE       10

enum class ModifyFlags {
    NONE         = 0x000000,
    Search       = 0x000001,
@@ -336,6 +333,9 @@ SvxSearchDialog::SvxSearchDialog( vcl::Window* pParent, SfxChildWindow* pChildWi
    // m_pSimilarityBtn->set_height_request(m_pSimilarityBox->get_preferred_size().Height());
    // m_pJapOptionsBtn->set_height_request(m_pJapOptionsCB->get_preferred_size().Height());

    //tdf#122322
    nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();

    long nTermWidth = approximate_char_width() * 32;
    m_pSearchLB->set_width_request(nTermWidth);
    m_pSearchTmplLB->set_width_request(nTermWidth);
@@ -1633,11 +1633,11 @@ void SvxSearchDialog::Remember_Impl( const OUString &rStr, bool _bSearch )
        return;

    // delete oldest entry at maximum occupancy (ListBox and Array)
    if(REMEMBER_SIZE < pArr->size())
    if(nRememberSize < pArr->size())
    {
        pListBox->RemoveEntryAt(static_cast<sal_uInt16>(REMEMBER_SIZE - 1));
        (*pArr)[REMEMBER_SIZE - 1] = rStr;
        pArr->erase(pArr->begin() + REMEMBER_SIZE - 1);
        pListBox->RemoveEntryAt(static_cast<sal_uInt16>(nRememberSize - 1));
        (*pArr)[nRememberSize - 1] = rStr;
        pArr->erase(pArr->begin() + nRememberSize - 1);
    }

    pArr->insert(pArr->begin(), rStr);