Line data Source code
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 : #ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX
21 : #define INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX
22 : #include <macros/generic.hxx>
23 : #include <macros/xinterface.hxx>
24 : #include <macros/xtypeprovider.hxx>
25 : #include <macros/xserviceinfo.hxx>
26 : #include <stdtypes.h>
27 :
28 : #include <com/sun/star/lang/XServiceInfo.hpp>
29 : #include <com/sun/star/lang/XTypeProvider.hpp>
30 : #include <com/sun/star/container/XContainerListener.hpp>
31 : #include <com/sun/star/container/XNameAccess.hpp>
32 : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
33 :
34 : #include <cppuhelper/implbase1.hxx>
35 : #include <rtl/ustring.hxx>
36 : #include <unordered_map>
37 :
38 : // Namespace
39 :
40 : namespace framework
41 : {
42 :
43 : // Configuration access class for PopupMenuControllerFactory implementation
44 :
45 : class ConfigurationAccess_ControllerFactory : // interfaces
46 : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
47 : {
48 : public:
49 : ConfigurationAccess_ControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const OUString& _sRoot,bool _bAskValue = false );
50 : virtual ~ConfigurationAccess_ControllerFactory();
51 :
52 : void readConfigurationData();
53 : void updateConfigurationData();
54 :
55 : OUString getServiceFromCommandModule( const OUString& rCommandURL, const OUString& rModule ) const;
56 : OUString getValueFromCommandModule( const OUString& rCommandURL, const OUString& rModule ) const;
57 : void addServiceToCommandModule( const OUString& rCommandURL, const OUString& rModule, const OUString& rServiceSpecifier );
58 : void removeServiceFromCommandModule( const OUString& rCommandURL, const OUString& rModule );
59 4151 : inline bool hasValue() const { return m_bAskValue; }
60 :
61 : // container.XContainerListener
62 : virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 : virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 : virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
65 :
66 : // lang.XEventListener
67 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
68 :
69 : private:
70 14473 : struct ControllerInfo
71 : {
72 : OUString m_aImplementationName;
73 : OUString m_aValue;
74 2910 : ControllerInfo(const OUString& _aImplementationName,const OUString& _aValue) : m_aImplementationName(_aImplementationName),m_aValue(_aValue){}
75 0 : ControllerInfo(){}
76 : };
77 636 : class MenuControllerMap : public std::unordered_map< OUString,
78 : ControllerInfo,
79 : OUStringHash,
80 : std::equal_to< OUString > >
81 : {
82 : inline void free()
83 : {
84 : MenuControllerMap().swap( *this );// get rid of reserved capacity
85 : }
86 : };
87 :
88 : bool impl_getElementProps( const ::com::sun::star::uno::Any& aElement, OUString& aCommand, OUString& aModule, OUString& aServiceSpecifier,OUString& aValue ) const;
89 :
90 : mutable osl::Mutex m_mutex;
91 : OUString m_aPropCommand;
92 : OUString m_aPropModule;
93 : OUString m_aPropController;
94 : OUString m_aPropValue;
95 : OUString m_sRoot;
96 : MenuControllerMap m_aMenuControllerMap;
97 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
98 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess;
99 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigAccessListener;
100 : bool m_bConfigAccessInitialized;
101 : bool m_bAskValue;
102 : };
103 :
104 : } // namespace framework
105 : #endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX
106 :
107 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|