1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __FRAMEWORK_UIFACTORY_FACTORYCONFIGURATION_HXX_ 25 #define __FRAMEWORK_UIFACTORY_FACTORYCONFIGURATION_HXX_ 26 #include <threadhelp/threadhelpbase.hxx> 27 #include <macros/generic.hxx> 28 #include <macros/xinterface.hxx> 29 #include <macros/xtypeprovider.hxx> 30 #include <macros/xserviceinfo.hxx> 31 #include <stdtypes.h> 32 33 //_________________________________________________________________________________________________________________ 34 // interface includes 35 //_________________________________________________________________________________________________________________ 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 #include <com/sun/star/lang/XTypeProvider.hpp> 38 #include <com/sun/star/container/XContainerListener.hpp> 39 #include <com/sun/star/container/XNameAccess.hpp> 40 #include <com/sun/star/lang/XMultiComponentFactory.hpp> 41 42 //_________________________________________________________________________________________________________________ 43 // other includes 44 //_________________________________________________________________________________________________________________ 45 #include <cppuhelper/implbase1.hxx> 46 #include <rtl/ustring.hxx> 47 48 //_________________________________________________________________________________________________________________ 49 // Namespace 50 //_________________________________________________________________________________________________________________ 51 // 52 53 namespace framework 54 { 55 56 //***************************************************************************************************************** 57 // Configuration access class for PopupMenuControllerFactory implementation 58 //***************************************************************************************************************** 59 class ConfigurationAccess_ControllerFactory : // interfaces 60 private ThreadHelpBase, 61 public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener> 62 { 63 public: 64 ConfigurationAccess_ControllerFactory( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot,bool _bAskValue = false ); 65 virtual ~ConfigurationAccess_ControllerFactory(); 66 67 void readConfigurationData(); 68 void updateConfigurationData(); 69 70 rtl::OUString getServiceFromCommandModule( const rtl::OUString& rCommandURL, const rtl::OUString& rModule ) const; 71 rtl::OUString getValueFromCommandModule( const rtl::OUString& rCommandURL, const rtl::OUString& rModule ) const; 72 void addServiceToCommandModule( const rtl::OUString& rCommandURL, const rtl::OUString& rModule, const rtl::OUString& rServiceSpecifier ); 73 void removeServiceFromCommandModule( const rtl::OUString& rCommandURL, const rtl::OUString& rModule ); hasValue() const74 inline bool hasValue() const { return m_bAskValue; } 75 76 // container.XContainerListener 77 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 78 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 79 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 80 81 // lang.XEventListener 82 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 83 84 private: 85 struct ControllerInfo 86 { 87 rtl::OUString m_aImplementationName; 88 rtl::OUString m_aValue; ControllerInfoframework::ConfigurationAccess_ControllerFactory::ControllerInfo89 ControllerInfo(const ::rtl::OUString& _aImplementationName,const ::rtl::OUString& _aValue) : m_aImplementationName(_aImplementationName),m_aValue(_aValue){} ControllerInfoframework::ConfigurationAccess_ControllerFactory::ControllerInfo90 ControllerInfo(){} 91 }; 92 class MenuControllerMap : public std::hash_map< rtl::OUString, 93 ControllerInfo, 94 rtl::OUStringHash, 95 ::std::equal_to< ::rtl::OUString > > 96 { free()97 inline void free() 98 { 99 MenuControllerMap().swap( *this ); 100 } 101 }; 102 103 sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& aElement, rtl::OUString& aCommand, rtl::OUString& aModule, rtl::OUString& aServiceSpecifier,rtl::OUString& aValue ) const; 104 105 rtl::OUString m_aPropCommand; 106 rtl::OUString m_aPropModule; 107 rtl::OUString m_aPropController; 108 rtl::OUString m_aPropValue; 109 rtl::OUString m_sRoot; 110 MenuControllerMap m_aMenuControllerMap; 111 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 112 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider; 113 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess; 114 sal_Bool m_bConfigAccessInitialized; 115 bool m_bAskValue; 116 }; 117 118 } // namespace framework 119 #endif // __FRAMEWORK_UIFACTORY_FACTORYCONFIGURATION_HXX_ 120