xref: /AOO41X/main/framework/inc/uiconfiguration/uiconfigurationmanager.hxx (revision 5758ad8ce74c9f4c352d679950be760456f756ea)
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_UICONFIGMANAGER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_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 <threadhelp/threadhelpbase.hxx>
39cdf0e10cSrcweir #include <macros/generic.hxx>
40cdf0e10cSrcweir #include <macros/xinterface.hxx>
41cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
42cdf0e10cSrcweir #include <macros/xserviceinfo.hxx>
43cdf0e10cSrcweir #include <stdtypes.h>
44cdf0e10cSrcweir #include <uiconfiguration/imagemanager.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47cdf0e10cSrcweir //	interface includes
48cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
50cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
51cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
52cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfiguration.hpp>
53cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONSTORGAE_HPP_
56cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManager.hpp>
59cdf0e10cSrcweir #include <com/sun/star/ui/ConfigurationEvent.hpp>
60cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.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 UIConfigurationManager :   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::ui::XUIConfiguration             ,
77cdf0e10cSrcweir                                      public ::com::sun::star::ui::XUIConfigurationManager      ,
78cdf0e10cSrcweir                                      public ::com::sun::star::ui::XUIConfigurationPersistence  ,
79cdf0e10cSrcweir                                      public ::com::sun::star::ui::XUIConfigurationStorage      ,
80cdf0e10cSrcweir                                      private ThreadHelpBase						,	// Struct for right initalization of mutex member! Must be first of baseclasses.
81cdf0e10cSrcweir 							         public ::cppu::OWeakObject
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir         public:
84cdf0e10cSrcweir             //  XInterface, XTypeProvider, XServiceInfo
85cdf0e10cSrcweir             FWK_DECLARE_XINTERFACE
86cdf0e10cSrcweir             FWK_DECLARE_XTYPEPROVIDER
87cdf0e10cSrcweir             DECLARE_XSERVICEINFO
88cdf0e10cSrcweir 
89cdf0e10cSrcweir             UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager );
90cdf0e10cSrcweir             virtual ~UIConfigurationManager();
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             // XComponent
93cdf0e10cSrcweir             virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir             virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir             virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir             // XUIConfiguration
98cdf0e10cSrcweir             virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir             virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir             // XUIConfigurationManager
102cdf0e10cSrcweir             virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException);
103cdf0e10cSrcweir             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);
104cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings(  ) throw (::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir             virtual sal_Bool SAL_CALL hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir             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);
107cdf0e10cSrcweir             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);
108cdf0e10cSrcweir             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);
109cdf0e10cSrcweir             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);
110cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
112cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir             // XUIConfigurationPersistence
115cdf0e10cSrcweir             virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir             virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir             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);
118cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir             // XUIConfigurationStorage
122cdf0e10cSrcweir             virtual void SAL_CALL setStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir             virtual sal_Bool SAL_CALL hasStorage() throw (::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         private:
126cdf0e10cSrcweir             // private data types
127cdf0e10cSrcweir             enum NotifyOp
128cdf0e10cSrcweir             {
129cdf0e10cSrcweir                 NotifyOp_Remove,
130cdf0e10cSrcweir                 NotifyOp_Insert,
131cdf0e10cSrcweir                 NotifyOp_Replace
132cdf0e10cSrcweir             };
133cdf0e10cSrcweir 
134cdf0e10cSrcweir             struct UIElementInfo
135cdf0e10cSrcweir             {
UIElementInfoframework::UIConfigurationManager::UIElementInfo136cdf0e10cSrcweir                 UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) :
137cdf0e10cSrcweir                     aResourceURL( rResourceURL), aUIName( rUIName ) {}
138cdf0e10cSrcweir                 rtl::OUString   aResourceURL;
139cdf0e10cSrcweir                 rtl::OUString   aUIName;
140cdf0e10cSrcweir             };
141cdf0e10cSrcweir 
142cdf0e10cSrcweir             struct UIElementData
143cdf0e10cSrcweir             {
UIElementDataframework::UIConfigurationManager::UIElementData144cdf0e10cSrcweir                 UIElementData() : bModified( false ), bDefault( true ) {};
145cdf0e10cSrcweir 
146cdf0e10cSrcweir                 rtl::OUString aResourceURL;
147cdf0e10cSrcweir                 rtl::OUString aName;
148cdf0e10cSrcweir                 bool          bModified;        // has been changed since last storing
149cdf0e10cSrcweir                 bool          bDefault;         // default settings
150cdf0e10cSrcweir                 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
151cdf0e10cSrcweir             };
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 		    struct UIElementType;
154cdf0e10cSrcweir             friend struct UIElementType;
155*5758ad8cSAriel Constenla-Haile 		    typedef ::std::hash_map< rtl::OUString, UIElementData, rtl::OUStringHash, ::std::equal_to< rtl::OUString > > UIElementDataHashMap;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir             struct UIElementType
158cdf0e10cSrcweir             {
UIElementTypeframework::UIConfigurationManager::UIElementType159cdf0e10cSrcweir                 UIElementType() : bModified( false ),
160cdf0e10cSrcweir                                   bLoaded( false ),
161cdf0e10cSrcweir                                   bDefaultLayer( false ),
162cdf0e10cSrcweir                                   nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 
165cdf0e10cSrcweir                 bool                                                              bModified;
166cdf0e10cSrcweir                 bool                                                              bLoaded;
167cdf0e10cSrcweir                 bool                                                              bDefaultLayer;
168cdf0e10cSrcweir                 sal_Int16                                                         nElementType;
169cdf0e10cSrcweir                 UIElementDataHashMap                                              aElementsHashMap;
170cdf0e10cSrcweir                 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
171cdf0e10cSrcweir             };
172cdf0e10cSrcweir 
173cdf0e10cSrcweir             typedef ::std::vector< UIElementType > UIElementTypesVector;
174cdf0e10cSrcweir             typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
175*5758ad8cSAriel Constenla-Haile             typedef ::std::hash_map< rtl::OUString, UIElementInfo, rtl::OUStringHash, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir             // private methods
178cdf0e10cSrcweir             void            impl_Initialize();
179cdf0e10cSrcweir             void            implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
180cdf0e10cSrcweir             void            impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
181cdf0e10cSrcweir             void            impl_preloadUIElementTypeList( sal_Int16 nElementType );
182cdf0e10cSrcweir             UIElementData*  impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
183cdf0e10cSrcweir             void            impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData );
184cdf0e10cSrcweir             void            impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState = true );
185cdf0e10cSrcweir             void            impl_resetElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer );
186cdf0e10cSrcweir             void            impl_reloadElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir             UIElementTypesVector                                                            m_aUIElements;
189cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >               m_xDocConfigStorage;
190cdf0e10cSrcweir             bool                                                                            m_bReadOnly;
191cdf0e10cSrcweir             bool                                                                            m_bInitialized;
192cdf0e10cSrcweir             bool                                                                            m_bModified;
193cdf0e10cSrcweir             bool                                                                            m_bConfigRead;
194cdf0e10cSrcweir             bool                                                                            m_bDisposed;
195cdf0e10cSrcweir             rtl::OUString                                                                   m_aXMLPostfix;
196cdf0e10cSrcweir             rtl::OUString                                                                   m_aPropUIName;
197cdf0e10cSrcweir             rtl::OUString                                                                   m_aPropResourceURL;
198cdf0e10cSrcweir             rtl::OUString                                                                   m_aModuleIdentifier;
199cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
200cdf0e10cSrcweir             ::cppu::OMultiTypeInterfaceContainerHelper                                      m_aListenerContainer;   /// container for ALL Listener
201cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::lang::XComponent >              m_xImageManager;
202cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::uno::XInterface >               m_xAccConfig;
203cdf0e10cSrcweir    };
204cdf0e10cSrcweir }
205cdf0e10cSrcweir 
206cdf0e10cSrcweir #endif // __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
207