Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sfx2/inc/commandpopup/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 3 kB image not shown  

Quelle  CommandPopup.hxx   Sprache: C

 
/* -*- 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 <utility>
#include <vcl/weld.hxx>

#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>

#include <functional>
#include <unordered_set>

struct CurrentEntry final
{
    OUString m_aCommandURL;
    OUString m_aTooltip;

    CurrentEntry(OUString aCommandURL, OUString aTooltip)
        : m_aCommandURL(std::move(aCommandURL))
        , m_aTooltip(std::move(aTooltip))
    {
    }
};

struct MenuContent final
{
    OUString m_aCommandURL;
    OUString m_aMenuLabel;
    OUString m_aSearchableMenuLabel;
    OUString m_aFullLabelWithPath;
    OUString m_aTooltip;
    std::vector<MenuContent> m_aSubMenuContent;
};

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);
    std::unordered_set<OUString> m_aAdded;

public:
    MenuContentHandler(css::uno::Reference<css::frame::XFrame> const& xFrame);

    void gatherMenuContent(css::uno::Reference<css::container::XIndexAccess> const& xIndexAccess,
                           MenuContent& rMenuContent);

    void findInMenu(OUString const& rText, std::unique_ptr<weld::TreeView>& rpCommandTreeView,
                    std::vector<CurrentEntry>& rCommandList);

private:
    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,
                              const std::unique_ptr<weld::TreeView>& rpCommandTreeView,
                              std::vector<CurrentEntry>& rCommandList);
};

class CommandListBox final
{
private:
    std::unique_ptr<weld::Builder> mxBuilder;
    std::unique_ptr<weld::Popover> mxPopover;
    std::unique_ptr<weld::Entry> mpEntry;
    std::unique_ptr<weld::TreeView> mpCommandTreeView;

    std::vector<CurrentEntry> maCommandList;
    std::unique_ptr<MenuContentHandler> 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<css::frame::XFrame> const&&nbsp;xFrame);
    void connect_closed(const Link<weld::Popover&, void>& rLink)
    {
        mxPopover->connect_closed(rLink);
    }
};

class CommandPopupHandler final
{
private:
    std::unique_ptr<CommandListBox> mpListBox;

public:
    void showPopup(weld::Window* pParent, css::uno::Reference<css::frame::XFrame> const&&nbsp;xFrame);
    DECL_LINK(PopupModeEnd, weld::Popover&, void);
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5
C=96 H=92 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.