Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
30 : : #define __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
31 : :
32 : :
33 : : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
34 : : with solaris headers ...
35 : : */
36 : : #include <vector>
37 : : #include <list>
38 : : #include <boost/unordered_map.hpp>
39 : :
40 : : #include <accelerators/presethandler.hxx>
41 : : #include <threadhelp/threadhelpbase.hxx>
42 : : #include <macros/generic.hxx>
43 : : #include <macros/xinterface.hxx>
44 : : #include <macros/xtypeprovider.hxx>
45 : : #include <macros/xserviceinfo.hxx>
46 : : #include <stdtypes.h>
47 : : #include <uiconfiguration/moduleimagemanager.hxx>
48 : :
49 : : #include <com/sun/star/lang/XServiceInfo.hpp>
50 : : #include <com/sun/star/lang/XTypeProvider.hpp>
51 : : #include <com/sun/star/lang/XComponent.hpp>
52 : : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
53 : : #include <com/sun/star/ui/XUIConfiguration.hpp>
54 : : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
55 : : #include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
56 : : #include <com/sun/star/ui/UIElementType.hpp>
57 : : #include <com/sun/star/lang/XInitialization.hpp>
58 : : #include <com/sun/star/ui/ConfigurationEvent.hpp>
59 : : #include <com/sun/star/embed/XTransactedObject.hpp>
60 : : #include <com/sun/star/container/XIndexContainer.hpp>
61 : :
62 : : #include <cppuhelper/weak.hxx>
63 : : #include <cppuhelper/interfacecontainer.hxx>
64 : : #include <rtl/ustring.hxx>
65 : :
66 : :
67 : : namespace framework
68 : : {
69 : : class ModuleUIConfigurationManager : public com::sun::star::lang::XTypeProvider ,
70 : : public com::sun::star::lang::XServiceInfo ,
71 : : public com::sun::star::lang::XComponent ,
72 : : public com::sun::star::lang::XInitialization ,
73 : : public ::com::sun::star::ui::XUIConfiguration ,
74 : : public ::com::sun::star::ui::XUIConfigurationManager ,
75 : : public ::com::sun::star::ui::XModuleUIConfigurationManager ,
76 : : public ::com::sun::star::ui::XUIConfigurationPersistence ,
77 : : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
78 : : public ::cppu::OWeakObject
79 : : {
80 : : public:
81 : : // XInterface, XTypeProvider, XServiceInfo
82 : : FWK_DECLARE_XINTERFACE
83 : : FWK_DECLARE_XTYPEPROVIDER
84 : : DECLARE_XSERVICEINFO
85 : :
86 : : ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager );
87 : : virtual ~ModuleUIConfigurationManager();
88 : :
89 : : // XComponent
90 : : virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
91 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
92 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
93 : :
94 : : // XInitialization
95 : : 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);
96 : :
97 : : // XUIConfiguration
98 : : virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
99 : : virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
100 : :
101 : : // XUIConfigurationManager
102 : : virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException);
103 : : 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);
104 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings( ) throw (::com::sun::star::uno::RuntimeException);
105 : : virtual sal_Bool SAL_CALL hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
106 : : 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);
107 : : 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);
108 : : 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);
109 : : 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);
110 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException);
111 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
112 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException);
113 : :
114 : : // XModuleUIConfigurationManager
115 : : virtual sal_Bool SAL_CALL isDefaultSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
116 : : 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);
117 : :
118 : : // XUIConfigurationPersistence
119 : : virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
120 : : virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
121 : : 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);
122 : : virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
123 : : virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException);
124 : :
125 : : private:
126 : : // private data types
127 : : enum Layer
128 : : {
129 : : LAYER_DEFAULT,
130 : : LAYER_USERDEFINED,
131 : : LAYER_COUNT
132 : : };
133 : :
134 : : enum NotifyOp
135 : : {
136 : : NotifyOp_Remove,
137 : : NotifyOp_Insert,
138 : : NotifyOp_Replace
139 : : };
140 : :
141 : 216730 : struct UIElementInfo
142 : : {
143 : 43346 : UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) :
144 : 43346 : aResourceURL( rResourceURL), aUIName( rUIName ) {}
145 : : rtl::OUString aResourceURL;
146 : : rtl::OUString aUIName;
147 : : };
148 : :
149 : 17580 : struct UIElementData
150 : : {
151 : 3516 : UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {};
152 : :
153 : : rtl::OUString aResourceURL;
154 : : rtl::OUString aName;
155 : : bool bModified; // has been changed since last storing
156 : : bool bDefault; // default settings
157 : : bool bDefaultNode; // this is a default layer element data
158 : : com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
159 : : };
160 : :
161 : : struct UIElementType;
162 : : friend struct UIElementType;
163 : : typedef ::boost::unordered_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap;
164 : :
165 : 2384 : struct UIElementType
166 : : {
167 : 2384 : UIElementType() : bModified( false ),
168 : : bLoaded( false ),
169 : : bDefaultLayer( false ),
170 [ + - ]: 2384 : nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
171 : :
172 : :
173 : : bool bModified;
174 : : bool bLoaded;
175 : : bool bDefaultLayer;
176 : : sal_Int16 nElementType;
177 : : UIElementDataHashMap aElementsHashMap;
178 : : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
179 : : };
180 : :
181 : : typedef ::std::vector< UIElementType > UIElementTypesVector;
182 : : typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
183 : : typedef ::boost::unordered_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap;
184 : :
185 : : // private methods
186 : : void impl_Initialize();
187 : : void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
188 : : void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
189 : : void impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType );
190 : : UIElementData* impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
191 : : void impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData );
192 : : void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState = true );
193 : : void impl_resetElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
194 : : void impl_reloadElementTypeData( UIElementType& rUserElementType, UIElementType& rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
195 : :
196 : : UIElementTypesVector m_aUIElements[LAYER_COUNT];
197 : : PresetHandler* m_pStorageHandler[::com::sun::star::ui::UIElementType::COUNT];
198 : : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDefaultConfigStorage;
199 : : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserConfigStorage;
200 : : bool m_bReadOnly;
201 : : bool m_bInitialized;
202 : : bool m_bModified;
203 : : bool m_bConfigRead;
204 : : bool m_bDisposed;
205 : : rtl::OUString m_aXMLPostfix;
206 : : rtl::OUString m_aPropUIName;
207 : : rtl::OUString m_aPropResourceURL;
208 : : rtl::OUString m_aModuleIdentifier;
209 : : rtl::OUString m_aModuleShortName;
210 : : com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit;
211 : : com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
212 : : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
213 : : com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xModuleImageManager;
214 : : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xModuleAcceleratorManager;
215 : : };
216 : : }
217 : :
218 : : #endif // __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
219 : :
220 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|