update dev300-m58
[ooovba.git] / framework / source / uiconfiguration / uiconfigurationmanagerimpl.hxx
blob937aca2a9aeafba22d9c7a67a72231594c2ea5f0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UIConfigurationManagerImpl.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGERIMPL_HXX_
32 #define __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGERIMPL_HXX_
35 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
36 with solaris headers ...
38 #include <vector>
39 #include <list>
40 #include <hash_map>
42 //_________________________________________________________________________________________________________________
43 // my own includes
44 //_________________________________________________________________________________________________________________
45 #include <accelerators/presethandler.hxx>
46 #include <threadhelp/threadhelpbase.hxx>
47 #include <macros/generic.hxx>
48 #include <macros/xinterface.hxx>
49 #include <macros/xtypeprovider.hxx>
50 #include <macros/xserviceinfo.hxx>
51 #include <stdtypes.h>
52 #include <uiconfiguration/moduleimagemanager.hxx>
54 //_________________________________________________________________________________________________________________
55 // interface includes
56 //_________________________________________________________________________________________________________________
57 #include <com/sun/star/lang/XServiceInfo.hpp>
58 #include <com/sun/star/lang/XTypeProvider.hpp>
59 #include <com/sun/star/lang/XComponent.hpp>
60 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
61 #include <com/sun/star/ui/XUIConfiguration.hpp>
62 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
63 #include <com/sun/star/ui/UIElementType.hpp>
64 #include <com/sun/star/lang/XInitialization.hpp>
65 #include <com/sun/star/ui/ConfigurationEvent.hpp>
66 #include <com/sun/star/embed/XTransactedObject.hpp>
67 #include <com/sun/star/container/XIndexContainer.hpp>
69 //_________________________________________________________________________________________________________________
70 // other includes
71 //_________________________________________________________________________________________________________________
72 #include <cppuhelper/weak.hxx>
73 #include <cppuhelper/interfacecontainer.hxx>
74 #include <rtl/ustring.hxx>
77 namespace framework
79 class UIConfigurationManagerImpl : public ThreadHelpBase // Struct for right initalization of mutex member! Must be first of baseclasses.
81 public:
82 // XInterface, XTypeProvider, XServiceInfo
83 UIConfigurationManagerImpl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager
84 , const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& _xOwner
85 , bool _bUseDefault);
86 ~UIConfigurationManagerImpl();
88 // XComponent
89 void dispose() throw (::com::sun::star::uno::RuntimeException);
90 void addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
91 void removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
93 // XInitialization
94 void initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
96 // XUIConfiguration
97 void addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
98 void removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
100 // XUIConfigurationManager
101 void reset() throw (::com::sun::star::uno::RuntimeException);
102 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > getUIElementsInfo( sal_Int16 ElementType ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
103 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > createSettings( ) throw (::com::sun::star::uno::RuntimeException);
104 sal_Bool hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
105 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
106 void 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);
107 void 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);
108 void 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);
109 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getImageManager() throw (::com::sun::star::uno::RuntimeException);
110 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
111 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getEventsManager() throw (::com::sun::star::uno::RuntimeException);
113 // XUIConfigurationManagerImpl
114 sal_Bool isDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
115 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > getDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
117 // XUIConfigurationPersistence
118 void reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
119 void store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
120 void storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
121 sal_Bool isModified() throw (::com::sun::star::uno::RuntimeException);
122 sal_Bool isReadOnly() throw (::com::sun::star::uno::RuntimeException);
124 // XUIConfigurationStorage
125 void setStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
126 sal_Bool hasStorage() throw (::com::sun::star::uno::RuntimeException);
128 enum Layer
130 LAYER_DEFAULT,
131 LAYER_USERDEFINED,
132 LAYER_COUNT
135 enum NotifyOp
137 NotifyOp_Remove,
138 NotifyOp_Insert,
139 NotifyOp_Replace
142 struct UIElementInfo
144 UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) :
145 aResourceURL( rResourceURL), aUIName( rUIName ) {}
146 rtl::OUString aResourceURL;
147 rtl::OUString aUIName;
150 struct UIElementData
152 UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {};
154 rtl::OUString aResourceURL;
155 rtl::OUString aName;
156 bool bModified; // has been changed since last storing
157 bool bDefault; // default settings
158 bool bDefaultNode; // this is a default layer element data
159 com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
162 struct UIElementType;
163 friend struct UIElementType;
164 typedef ::std::hash_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap;
166 struct UIElementType
168 UIElementType() : bModified( false ),
169 bLoaded( false ),
170 bDefaultLayer( false ),
171 nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
174 bool bModified;
175 bool bLoaded;
176 bool bDefaultLayer;
177 sal_Int16 nElementType;
178 UIElementDataHashMap aElementsHashMap;
179 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
182 typedef ::std::vector< UIElementType > UIElementTypesVector;
183 typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
184 typedef ::std::hash_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap;
186 // private methods
187 void impl_Initialize();
188 void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
189 void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
190 void impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType );
191 UIElementData* impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
192 void impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData );
193 void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState = true );
194 void impl_resetElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
195 void impl_reloadElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
197 UIElementTypesVector m_aUIElements[LAYER_COUNT];
198 PresetHandler* m_pStorageHandler[::com::sun::star::ui::UIElementType::COUNT];
199 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDefaultConfigStorage;
200 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserConfigStorage;
201 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xOwner;
202 bool m_bUseDefault;
203 bool m_bReadOnly;
204 bool m_bInitialized;
205 bool m_bModified;
206 bool m_bConfigRead;
207 bool m_bDisposed;
208 rtl::OUString m_aXMLPostfix;
209 rtl::OUString m_aPropUIName;
210 rtl::OUString m_aPropResourceURL;
211 rtl::OUString m_aModuleIdentifier;
212 rtl::OUString m_aModuleShortName;
213 com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit;
214 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
215 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
216 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xAccConfig;
217 com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xModuleImageManager;
221 #endif // __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGERIMPL_HXX_