diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-08-04 16:17:46 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-04 16:38:48 +0200 |
commit | fc0d2136aee6c1749d780de09df025251703b59e (patch) | |
tree | dfa5749dde5ba4fb5572225a0eb5d6404e3a7d4e /sfx2/inc/commandpopup | |
parent | 5b6f8991d88e75f11811de502b4285aa23cd0d4e (diff) |
tdf#142532 search string at any position not just start
In the first implementation, we check if the search string is at
the start of the command string. Mainly this is done to find the
right command with a better accuracy. The problem with this is
that it discards other hits where the search word occurs at an
other position in the command text.
This change adds the command where the search string doesn't occur
at the start of the command string, but it adds those hits to the
end of the list, so the best matches are still added at the
beginning.
Change-Id: I44a15400c84d45b0c8d3b65ec0e1ffee10686e72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119962
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2/inc/commandpopup')
-rw-r--r-- | sfx2/inc/commandpopup/CommandPopup.hxx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sfx2/inc/commandpopup/CommandPopup.hxx b/sfx2/inc/commandpopup/CommandPopup.hxx index 5d1d74aff860..143f0de25adb 100644 --- a/sfx2/inc/commandpopup/CommandPopup.hxx +++ b/sfx2/inc/commandpopup/CommandPopup.hxx @@ -23,6 +23,9 @@ #include <com/sun/star/i18n/XCharacterClassification.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <functional> +#include <unordered_set> + struct CurrentEntry final { OUString m_aCommandURL; @@ -56,6 +59,7 @@ private: MenuContent m_aMenuContent; OUString m_sModuleLongName; OUString toLower(OUString const& rString); + std::unordered_set<OUString> m_aAdded; public: MenuContentHandler(css::uno::Reference<css::frame::XFrame> const& xFrame); @@ -67,9 +71,14 @@ public: std::vector<CurrentEntry>& rCommandList); private: - void findInMenuRecursive(MenuContent const& rMenuContent, OUString const& rText, - std::unique_ptr<weld::TreeView>& rpCommandTreeView, - std::vector<CurrentEntry>& rCommandList); + void findInMenuRecursive( + MenuContent const& rMenuContent, OUString const& rText, + std::unique_ptr<weld::TreeView>& rpCommandTreeView, std::vector<CurrentEntry>& rCommandList, + std::function<bool(MenuContent const&, OUString const&)> const& rSearchCriterium); + + void addCommandIfPossible(MenuContent const& rMenuContent, + std::unique_ptr<weld::TreeView>& rpCommandTreeView, + std::vector<CurrentEntry>& rCommandList); }; class CommandListBox final |