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