LibreOffice Module framework (master) 1
factoryconfiguration.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <com/sun/star/container/XContainerListener.hpp>
23#include <com/sun/star/container/XNameAccess.hpp>
24#include <com/sun/star/lang/XMultiServiceFactory.hpp>
25#include <com/sun/star/uno/XComponentContext.hpp>
26
28#include <rtl/ustring.hxx>
29
30#include <mutex>
31#include <string_view>
32#include <unordered_map>
33#include <utility>
34
35// Namespace
36
37namespace framework
38{
39
40// Configuration access class for PopupMenuControllerFactory implementation
41
42class ConfigurationAccess_ControllerFactory final : // interfaces
43 public ::cppu::WeakImplHelper< css::container::XContainerListener>
44{
45public:
46 ConfigurationAccess_ControllerFactory( const css::uno::Reference< css::uno::XComponentContext >& rxContext, OUString _sRoot );
48
50
51 OUString getServiceFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule ) const;
52 OUString getValueFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule ) const;
53 void addServiceToCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule, const OUString& rServiceSpecifier );
54 void removeServiceFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule );
55
56 // container.XContainerListener
57 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
58 virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
59 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
60
61 // lang.XEventListener
62 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
63
64private:
66
68 {
70 OUString m_aValue;
71 ControllerInfo(OUString _aImplementationName, OUString _aValue) : m_aImplementationName(std::move(_aImplementationName)),m_aValue(std::move(_aValue)){}
73 };
74 class MenuControllerMap : public std::unordered_map< OUString,
75 ControllerInfo >
76 {
77 };
78
79 bool impl_getElementProps( const css::uno::Any& aElement, OUString& aCommand, OUString& aModule, OUString& aServiceSpecifier,OUString& aValue ) const;
80
81 mutable std::mutex m_mutex;
83 OUString m_aPropModule;
85 OUString m_aPropValue;
86 OUString m_sRoot;
88 css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider;
89 css::uno::Reference< css::container::XNameAccess > m_xConfigAccess;
90 css::uno::Reference< css::container::XContainerListener > m_xConfigAccessListener;
92};
93
94} // namespace framework
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
ConfigurationAccess_ControllerFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext, OUString _sRoot)
css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider
void removeServiceFromCommandModule(std::u16string_view rCommandURL, std::u16string_view rModule)
css::uno::Reference< css::container::XNameAccess > m_xConfigAccess
OUString getServiceFromCommandModule(std::u16string_view rCommandURL, std::u16string_view rModule) const
void addServiceToCommandModule(std::u16string_view rCommandURL, std::u16string_view rModule, const OUString &rServiceSpecifier)
css::uno::Reference< css::container::XContainerListener > m_xConfigAccessListener
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
OUString getValueFromCommandModule(std::u16string_view rCommandURL, std::u16string_view rModule) const
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
bool impl_getElementProps(const css::uno::Any &aElement, OUString &aCommand, OUString &aModule, OUString &aServiceSpecifier, OUString &aValue) const
ControllerInfo(OUString _aImplementationName, OUString _aValue)
OUString aCommand