1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
34 #include <cppuhelper/implbase1.hxx>
35 #include <rtl/ustring.hxx>
36 #include <unordered_map>
43 // Configuration access class for PopupMenuControllerFactory implementation
45 class ConfigurationAccess_ControllerFactory
: // interfaces
46 public ::cppu::WeakImplHelper1
< ::com::sun::star::container::XContainerListener
>
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();
52 void readConfigurationData();
53 void updateConfigurationData();
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 inline bool hasValue() const { return m_bAskValue
; }
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
;
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
;
72 OUString m_aImplementationName
;
74 ControllerInfo(const OUString
& _aImplementationName
,const OUString
& _aValue
) : m_aImplementationName(_aImplementationName
),m_aValue(_aValue
){}
77 class MenuControllerMap
: public std::unordered_map
< OUString
,
80 std::equal_to
< OUString
> >
84 MenuControllerMap().swap( *this );// get rid of reserved capacity
88 bool impl_getElementProps( const ::com::sun::star::uno::Any
& aElement
, OUString
& aCommand
, OUString
& aModule
, OUString
& aServiceSpecifier
,OUString
& aValue
) const;
90 mutable osl::Mutex m_mutex
;
91 OUString m_aPropCommand
;
92 OUString m_aPropModule
;
93 OUString m_aPropController
;
94 OUString m_aPropValue
;
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
;
104 } // namespace framework
105 #endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */