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