/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/. */ #pragma once #include #include #include #include #include #include #include #include struct CurrentEntry final { OUString m_aCommandURL; OUString m_aTooltip; CurrentEntry(OUString const& rCommandURL, OUString const& rTooltip) : m_aCommandURL(rCommandURL) , m_aTooltip(rTooltip) { } }; struct MenuContent final { OUString m_aCommandURL; OUString m_aMenuLabel; OUString m_aSearchableMenuLabel; OUString m_aFullLabelWithPath; OUString m_aTooltip; std::vector m_aSubMenuContent; }; class MenuContentHandler final { private: css::uno::Reference m_xContext; css::uno::Reference m_xFrame; css::uno::Reference m_xCharacterClassification; css::uno::Reference m_xURLTransformer; MenuContent m_aMenuContent; OUString m_sModuleLongName; OUString toLower(OUString const& rString); std::unordered_set m_aAdded; public: MenuContentHandler(css::uno::Reference const& xFrame); void gatherMenuContent(css::uno::Reference const& xIndexAccess, MenuContent& rMenuContent); void findInMenu(OUString const& rText, std::unique_ptr& rpCommandTreeView, std::vector& rCommandList); private: void findInMenuRecursive( MenuContent const& rMenuContent, OUString const& rText, std::unique_ptr& rpCommandTreeView, std::vector& rCommandList, std::function const& rSearchCriterium); void addCommandIfPossible(MenuContent const& rMenuContent, const std::unique_ptr& rpCommandTreeView, std::vector& rCommandList); }; class CommandListBox final { private: std::unique_ptr mxBuilder; std::unique_ptr mxPopover; std::unique_ptr mpEntry; std::unique_ptr mpCommandTreeView; std::vector maCommandList; std::unique_ptr mpMenuContentHandler; DECL_LINK(QueryTooltip, const weld::TreeIter&, OUString); DECL_LINK(RowActivated, weld::TreeView&, bool); DECL_LINK(ModifyHdl, weld::Entry&, void); DECL_LINK(TreeViewKeyPress, const KeyEvent&, bool); void dispatchCommandAndClose(OUString const& rCommand); public: CommandListBox(weld::Window* pParent, css::uno::Reference const& xFrame); void connect_closed(const Link& rLink) { mxPopover->connect_closed(rLink); } }; class CommandPopupHandler final { private: std::unique_ptr mpListBox; public: void showPopup(weld::Window* pParent, css::uno::Reference const& xFrame); DECL_LINK(PopupModeEnd, weld::Popover&, void); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */