sfx2/inc/commandpopup/CommandPopup.hxx | 11 +++++++++- sfx2/source/commandpopup/CommandPopup.cxx | 32 +++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-)
New commits: commit a39947102bac8430b13b10b3f11c34b5ebf576b0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 31 10:36:09 2021 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 31 05:30:19 2021 +0200 tdf#142243 HUD - Use XCharacterClassification to convert case This should use international case conversion, not just ascii one that was used before. Change-Id: Id01d3d0d30a846f02f97d081491b0de2c0d6ffef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116419 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sfx2/inc/commandpopup/CommandPopup.hxx b/sfx2/inc/commandpopup/CommandPopup.hxx index 85208e37608e..5d1d74aff860 100644 --- a/sfx2/inc/commandpopup/CommandPopup.hxx +++ b/sfx2/inc/commandpopup/CommandPopup.hxx @@ -17,8 +17,11 @@ #include <vcl/weld.hxx> #include <vcl/window.hxx> -#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/i18n/XCharacterClassification.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> struct CurrentEntry final { @@ -36,6 +39,7 @@ struct MenuContent final { OUString m_aCommandURL; OUString m_aMenuLabel; + OUString m_aSearchableMenuLabel; OUString m_aFullLabelWithPath; OUString m_aTooltip; std::vector<MenuContent> m_aSubMenuContent; @@ -44,9 +48,14 @@ struct MenuContent final class MenuContentHandler final { private: + css::uno::Reference<css::uno::XComponentContext> m_xContext; css::uno::Reference<css::frame::XFrame> m_xFrame; + css::uno::Reference<css::i18n::XCharacterClassification> m_xCharacterClassification; + css::uno::Reference<css::util::XURLTransformer> m_xURLTransformer; + MenuContent m_aMenuContent; OUString m_sModuleLongName; + OUString toLower(OUString const& rString); public: MenuContentHandler(css::uno::Reference<css::frame::XFrame> const& xFrame); diff --git a/sfx2/source/commandpopup/CommandPopup.cxx b/sfx2/source/commandpopup/CommandPopup.cxx index aa2555252b26..a903a0b12628 100644 --- a/sfx2/source/commandpopup/CommandPopup.cxx +++ b/sfx2/source/commandpopup/CommandPopup.cxx @@ -25,19 +25,23 @@ #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/util/URLTransformer.hpp> +#include <com/sun/star/i18n/CharacterClassification.hpp> #include <vcl/commandinfoprovider.hxx> +#include <vcl/svapp.hxx> +#include <i18nlangtag/languagetag.hxx> using namespace css; MenuContentHandler::MenuContentHandler(uno::Reference<frame::XFrame> const& xFrame) - : m_xFrame(xFrame) + : m_xContext(comphelper::getProcessComponentContext()) + , m_xFrame(xFrame) + , m_xCharacterClassification(i18n::CharacterClassification::create(m_xContext)) + , m_xURLTransformer(util::URLTransformer::create(m_xContext)) , m_sModuleLongName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame)) { - auto xComponentContext = comphelper::getProcessComponentContext(); - uno::Reference<ui::XModuleUIConfigurationManagerSupplier> xModuleConfigSupplier; - xModuleConfigSupplier.set(ui::theModuleUIConfigurationManagerSupplier::get(xComponentContext)); + xModuleConfigSupplier.set(ui::theModuleUIConfigurationManagerSupplier::get(m_xContext)); uno::Reference<ui::XUIConfigurationManager> xConfigurationManager; xConfigurationManager = xModuleConfigSupplier->getUIConfigurationManager(m_sModuleLongName); @@ -83,6 +87,7 @@ void MenuContentHandler::gatherMenuContent( aNewContent.m_aCommandURL, m_sModuleLongName); OUString aLabel = vcl::CommandInfoProvider::GetLabelForCommand(aCommandProperties); aNewContent.m_aMenuLabel = aLabel; + aNewContent.m_aSearchableMenuLabel = toLower(aLabel); if (!rMenuContent.m_aFullLabelWithPath.isEmpty()) aNewContent.m_aFullLabelWithPath = rMenuContent.m_aFullLabelWithPath + " / "; @@ -102,7 +107,7 @@ void MenuContentHandler::findInMenu(OUString const& rText, std::unique_ptr<weld::TreeView>& rpCommandTreeView, std::vector<CurrentEntry>& rCommandList) { - findInMenuRecursive(m_aMenuContent, rText, rpCommandTreeView, rCommandList); + findInMenuRecursive(m_aMenuContent, toLower(rText), rpCommandTreeView, rCommandList); } void MenuContentHandler::findInMenuRecursive(MenuContent const& rMenuContent, OUString const& rText, @@ -111,15 +116,13 @@ void MenuContentHandler::findInMenuRecursive(MenuContent const& rMenuContent, OU { for (MenuContent const& aSubContent : rMenuContent.m_aSubMenuContent) { - if (aSubContent.m_aMenuLabel.toAsciiLowerCase().startsWith(rText)) + if (aSubContent.m_aSearchableMenuLabel.startsWith(rText)) { OUString sCommandURL = aSubContent.m_aCommandURL; util::URL aCommandURL; aCommandURL.Complete = sCommandURL; - uno::Reference<uno::XComponentContext> xContext - = comphelper::getProcessComponentContext(); - uno::Reference<util::XURLTransformer> xParser = util::URLTransformer::create(xContext); - xParser->parseStrict(aCommandURL); + + m_xURLTransformer->parseStrict(aCommandURL); auto* pViewFrame = SfxViewFrame::Current(); @@ -148,6 +151,13 @@ void MenuContentHandler::findInMenuRecursive(MenuContent const& rMenuContent, OU } } +OUString MenuContentHandler::toLower(OUString const& rString) +{ + const css::lang::Locale& rLocale = Application::GetSettings().GetUILanguageTag().getLocale(); + + return m_xCharacterClassification->toUpper(rString, 0, rString.getLength(), rLocale); +} + CommandListBox::CommandListBox(weld::Window* pParent, uno::Reference<frame::XFrame> const& xFrame) : mxBuilder(Application::CreateBuilder(pParent, "sfx/ui/commandpopup.ui")) , mxPopover(mxBuilder->weld_popover("CommandPopup")) @@ -225,7 +235,7 @@ IMPL_LINK_NOARG(CommandListBox, ModifyHdl, weld::Entry&, void) return; mpCommandTreeView->freeze(); - mpMenuContentHandler->findInMenu(sText.toAsciiLowerCase(), mpCommandTreeView, maCommandList); + mpMenuContentHandler->findInMenu(sText, mpCommandTreeView, maCommandList); mpCommandTreeView->thaw(); if (mpCommandTreeView->n_children() > 0) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits