svx/source/inc/findtextfield.hxx | 3 ++ svx/source/tbxctrls/tbunosearchcontrollers.cxx | 12 +++++--- sw/qa/uitest/findBar/tdf154269.py | 36 +++++++++++++++++++++++++ vcl/source/uitest/uiobject.cxx | 1 4 files changed, 48 insertions(+), 4 deletions(-)
New commits: commit b8349ca053753bb0dc713933628a1575a70677d3 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Wed Apr 12 12:13:17 2023 +0200 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Sat Apr 15 11:33:08 2023 +0200 tdf#154269 - Respect FindReplaceRememberedSearches expert option in quick find Change-Id: I88c1bed647bf6f77953ccd9921e515c1246fa96f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150273 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> diff --git a/svx/source/inc/findtextfield.hxx b/svx/source/inc/findtextfield.hxx index eb1b6cc11ee5..8cfa98f03242 100644 --- a/svx/source/inc/findtextfield.hxx +++ b/svx/source/inc/findtextfield.hxx @@ -64,6 +64,9 @@ private: void FocusIn(); void ActivateFind(bool bShift); + + // tdf#154269 - respect FindReplaceRememberedSearches expert option + sal_uInt16 m_nRememberSize; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 304eb8123c56..9611f4d686c0 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -24,6 +24,7 @@ #include <vector> #include <config_feature_desktop.h> +#include <officecfg/Office/Common.hxx> #include <svx/strings.hrc> #include <svx/dialmgr.hxx> @@ -73,8 +74,6 @@ constexpr OUStringLiteral COMMAND_FINDALL = u".uno:FindAll"; constexpr OUStringLiteral COMMAND_MATCHCASE = u".uno:MatchCase"; constexpr OUStringLiteral COMMAND_SEARCHFORMATTED = u".uno:SearchFormattedDisplayString"; -const sal_Int32 REMEMBER_SIZE = 10; - class CheckButtonItemWindow final : public InterimItemWindow { public: @@ -214,6 +213,11 @@ FindTextFieldControl::FindTextFieldControl( vcl::Window* pParent, m_xWidget->set_size_request(250, -1); SetSizePixel(m_xWidget->get_preferred_size()); + + // tdf#154269 - respect FindReplaceRememberedSearches expert option + m_nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get(); + if (m_nRememberSize < 1) + m_nRememberSize = 1; } void FindTextFieldControl::Remember_Impl(const OUString& rStr) @@ -226,8 +230,8 @@ void FindTextFieldControl::Remember_Impl(const OUString& rStr) return; } - if (nCount == REMEMBER_SIZE) - m_xWidget->remove(REMEMBER_SIZE-1); + if (nCount == m_nRememberSize) + m_xWidget->remove(m_nRememberSize - 1); m_xWidget->insert_text(0, rStr); } diff --git a/sw/qa/uitest/findBar/tdf154269.py b/sw/qa/uitest/findBar/tdf154269.py new file mode 100755 index 000000000000..d5752093b2b6 --- /dev/null +++ b/sw/qa/uitest/findBar/tdf154269.py @@ -0,0 +1,36 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf154269(UITestCase): + + def test_tdf154269(self): + + with self.ui_test.create_doc_in_start_center("writer"): + # Open quick search + self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar") + xWriterDoc = self.xUITest.getTopFocusWindow() + xFind = xWriterDoc.getChild("find") + + # Generate a search history with more than 10 entries (A to Z) + for searchTerm in map(chr, range(65, 91)): + # Search twice to generate a search history + xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) + xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xFind.executeAction("TYPE", mkPropertyValues({"TEXT": searchTerm})) + xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"})) + self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar") + + # The default value of FindReplaceRememberedSearches has been respected + self.assertEqual("10", get_state_as_dict(xFind)["EntryCount"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx index 38079425a41d..623591e7e218 100644 --- a/vcl/source/uitest/uiobject.cxx +++ b/vcl/source/uitest/uiobject.cxx @@ -1224,6 +1224,7 @@ StringMap ComboBoxUIObject::get_state() { StringMap aMap = WindowUIObject::get_state(); aMap["SelectedText"] = mxComboBox->GetSelected(); + aMap["EntryCount"] = OUString::number(mxComboBox->GetEntryCount()); return aMap; }