1f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f8e07b45SAndrew Rist * distributed with this work for additional information 6f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17f8e07b45SAndrew Rist * specific language governing permissions and limitations 18f8e07b45SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f8e07b45SAndrew Rist *************************************************************/ 21f8e07b45SAndrew Rist 22f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_ 25cdf0e10cSrcweir #define __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble 29cdf0e10cSrcweir with solaris headers ... 30cdf0e10cSrcweir */ 31cdf0e10cSrcweir #include <vector> 32cdf0e10cSrcweir #include <list> 33cdf0e10cSrcweir #include <hash_map> 34cdf0e10cSrcweir 35cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36cdf0e10cSrcweir // my own includes 37cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 38cdf0e10cSrcweir #include <accelerators/presethandler.hxx> 39cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 40cdf0e10cSrcweir #include <macros/generic.hxx> 41cdf0e10cSrcweir #include <macros/xinterface.hxx> 42cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 43cdf0e10cSrcweir #include <macros/xserviceinfo.hxx> 44cdf0e10cSrcweir #include <stdtypes.h> 45cdf0e10cSrcweir #include <uiconfiguration/moduleimagemanager.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 48cdf0e10cSrcweir // interface includes 49cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 50cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 51cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 52cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 53cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationPersistence.hpp> 54cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfiguration.hpp> 55cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManager.hpp> 56cdf0e10cSrcweir #include <com/sun/star/ui/XModuleUIConfigurationManager.hpp> 57cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.hpp> 58cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 59cdf0e10cSrcweir #include <com/sun/star/ui/ConfigurationEvent.hpp> 60cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp> 61cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 62cdf0e10cSrcweir 63cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 64cdf0e10cSrcweir // other includes 65cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 66cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 67cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 68cdf0e10cSrcweir #include <rtl/ustring.hxx> 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir namespace framework 72cdf0e10cSrcweir { 73cdf0e10cSrcweir class ModuleUIConfigurationManager : public com::sun::star::lang::XTypeProvider , 74cdf0e10cSrcweir public com::sun::star::lang::XServiceInfo , 75cdf0e10cSrcweir public com::sun::star::lang::XComponent , 76cdf0e10cSrcweir public com::sun::star::lang::XInitialization , 77cdf0e10cSrcweir public ::com::sun::star::ui::XUIConfiguration , 78cdf0e10cSrcweir public ::com::sun::star::ui::XUIConfigurationManager , 79cdf0e10cSrcweir public ::com::sun::star::ui::XModuleUIConfigurationManager , 80cdf0e10cSrcweir public ::com::sun::star::ui::XUIConfigurationPersistence , 81cdf0e10cSrcweir private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. 82cdf0e10cSrcweir public ::cppu::OWeakObject 83cdf0e10cSrcweir { 84cdf0e10cSrcweir public: 85cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 86cdf0e10cSrcweir FWK_DECLARE_XINTERFACE 87cdf0e10cSrcweir FWK_DECLARE_XTYPEPROVIDER 88cdf0e10cSrcweir DECLARE_XSERVICEINFO 89cdf0e10cSrcweir 90cdf0e10cSrcweir ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ); 91cdf0e10cSrcweir virtual ~ModuleUIConfigurationManager(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir // XComponent 94cdf0e10cSrcweir virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 96cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // XInitialization 99cdf0e10cSrcweir virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir 101cdf0e10cSrcweir // XUIConfiguration 102cdf0e10cSrcweir virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 104cdf0e10cSrcweir 105cdf0e10cSrcweir // XUIConfigurationManager 106cdf0e10cSrcweir virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException); 107cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getUIElementsInfo( sal_Int16 ElementType ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 108cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings( ) throw (::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 110cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir virtual void SAL_CALL replaceSettings( const ::rtl::OUString& ResourceURL, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); 112cdf0e10cSrcweir virtual void SAL_CALL removeSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir virtual void SAL_CALL insertSettings( const ::rtl::OUString& NewResourceURL, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); 114cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException); 115cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException); 116cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir 118cdf0e10cSrcweir // XModuleUIConfigurationManager 119cdf0e10cSrcweir virtual sal_Bool SAL_CALL isDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 120cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // XUIConfigurationPersistence 123cdf0e10cSrcweir virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 125cdf0e10cSrcweir virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 126cdf0e10cSrcweir virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException); 128cdf0e10cSrcweir 129cdf0e10cSrcweir private: 130cdf0e10cSrcweir // private data types 131cdf0e10cSrcweir enum Layer 132cdf0e10cSrcweir { 133cdf0e10cSrcweir LAYER_DEFAULT, 134cdf0e10cSrcweir LAYER_USERDEFINED, 135cdf0e10cSrcweir LAYER_COUNT 136cdf0e10cSrcweir }; 137cdf0e10cSrcweir 138cdf0e10cSrcweir enum NotifyOp 139cdf0e10cSrcweir { 140cdf0e10cSrcweir NotifyOp_Remove, 141cdf0e10cSrcweir NotifyOp_Insert, 142cdf0e10cSrcweir NotifyOp_Replace 143cdf0e10cSrcweir }; 144cdf0e10cSrcweir 145cdf0e10cSrcweir struct UIElementInfo 146cdf0e10cSrcweir { UIElementInfoframework::ModuleUIConfigurationManager::UIElementInfo147cdf0e10cSrcweir UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) : 148cdf0e10cSrcweir aResourceURL( rResourceURL), aUIName( rUIName ) {} 149cdf0e10cSrcweir rtl::OUString aResourceURL; 150cdf0e10cSrcweir rtl::OUString aUIName; 151cdf0e10cSrcweir }; 152cdf0e10cSrcweir 153cdf0e10cSrcweir struct UIElementData 154cdf0e10cSrcweir { UIElementDataframework::ModuleUIConfigurationManager::UIElementData155cdf0e10cSrcweir UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {}; 156cdf0e10cSrcweir 157cdf0e10cSrcweir rtl::OUString aResourceURL; 158cdf0e10cSrcweir rtl::OUString aName; 159cdf0e10cSrcweir bool bModified; // has been changed since last storing 160cdf0e10cSrcweir bool bDefault; // default settings 161cdf0e10cSrcweir bool bDefaultNode; // this is a default layer element data 162cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings; 163cdf0e10cSrcweir }; 164cdf0e10cSrcweir 165cdf0e10cSrcweir struct UIElementType; 166cdf0e10cSrcweir friend struct UIElementType; 167*5758ad8cSAriel Constenla-Haile typedef ::std::hash_map< rtl::OUString, UIElementData, rtl::OUStringHash, ::std::equal_to< rtl::OUString > > UIElementDataHashMap; 168cdf0e10cSrcweir 169cdf0e10cSrcweir struct UIElementType 170cdf0e10cSrcweir { UIElementTypeframework::ModuleUIConfigurationManager::UIElementType171cdf0e10cSrcweir UIElementType() : bModified( false ), 172cdf0e10cSrcweir bLoaded( false ), 173cdf0e10cSrcweir bDefaultLayer( false ), 174cdf0e10cSrcweir nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {} 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir bool bModified; 178cdf0e10cSrcweir bool bLoaded; 179cdf0e10cSrcweir bool bDefaultLayer; 180cdf0e10cSrcweir sal_Int16 nElementType; 181cdf0e10cSrcweir UIElementDataHashMap aElementsHashMap; 182cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage; 183cdf0e10cSrcweir }; 184cdf0e10cSrcweir 185cdf0e10cSrcweir typedef ::std::vector< UIElementType > UIElementTypesVector; 186cdf0e10cSrcweir typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer; 187*5758ad8cSAriel Constenla-Haile typedef ::std::hash_map< rtl::OUString, UIElementInfo, rtl::OUStringHash, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap; 188cdf0e10cSrcweir 189cdf0e10cSrcweir // private methods 190cdf0e10cSrcweir void impl_Initialize(); 191cdf0e10cSrcweir void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp ); 192cdf0e10cSrcweir void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType ); 193cdf0e10cSrcweir void impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType ); 194cdf0e10cSrcweir UIElementData* impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true ); 195cdf0e10cSrcweir void impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData ); 196cdf0e10cSrcweir void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState = true ); 197cdf0e10cSrcweir void impl_resetElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer ); 198cdf0e10cSrcweir void impl_reloadElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir UIElementTypesVector m_aUIElements[LAYER_COUNT]; 201cdf0e10cSrcweir PresetHandler* m_pStorageHandler[::com::sun::star::ui::UIElementType::COUNT]; 202cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDefaultConfigStorage; 203cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserConfigStorage; 204cdf0e10cSrcweir bool m_bReadOnly; 205cdf0e10cSrcweir bool m_bInitialized; 206cdf0e10cSrcweir bool m_bModified; 207cdf0e10cSrcweir bool m_bConfigRead; 208cdf0e10cSrcweir bool m_bDisposed; 209cdf0e10cSrcweir rtl::OUString m_aXMLPostfix; 210cdf0e10cSrcweir rtl::OUString m_aPropUIName; 211cdf0e10cSrcweir rtl::OUString m_aPropResourceURL; 212cdf0e10cSrcweir rtl::OUString m_aModuleIdentifier; 213cdf0e10cSrcweir rtl::OUString m_aModuleShortName; 214cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit; 215cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 216cdf0e10cSrcweir ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener 217cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xModuleImageManager; 218cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xModuleAcceleratorManager; 219cdf0e10cSrcweir }; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir #endif // __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_ 223