1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGERIMPL_HXX_
29 #define __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGERIMPL_HXX_
32 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
33 with solaris headers ...
39 //_________________________________________________________________________________________________________________
41 //_________________________________________________________________________________________________________________
42 #include <accelerators/presethandler.hxx>
43 #include <threadhelp/threadhelpbase.hxx>
44 #include <macros/generic.hxx>
45 #include <macros/xinterface.hxx>
46 #include <macros/xtypeprovider.hxx>
47 #include <macros/xserviceinfo.hxx>
49 #include <uiconfiguration/moduleimagemanager.hxx>
51 //_________________________________________________________________________________________________________________
53 //_________________________________________________________________________________________________________________
54 #include <com/sun/star/lang/XServiceInfo.hpp>
55 #include <com/sun/star/lang/XTypeProvider.hpp>
56 #include <com/sun/star/lang/XComponent.hpp>
57 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
58 #include <com/sun/star/ui/XUIConfiguration.hpp>
59 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
60 #include <com/sun/star/ui/UIElementType.hpp>
61 #include <com/sun/star/lang/XInitialization.hpp>
62 #include <com/sun/star/ui/ConfigurationEvent.hpp>
63 #include <com/sun/star/embed/XTransactedObject.hpp>
64 #include <com/sun/star/container/XIndexContainer.hpp>
66 //_________________________________________________________________________________________________________________
68 //_________________________________________________________________________________________________________________
69 #include <cppuhelper/weak.hxx>
70 #include <cppuhelper/interfacecontainer.hxx>
71 #include <rtl/ustring.hxx>
76 class UIConfigurationManagerImpl
: public ThreadHelpBase
// Struct for right initalization of mutex member! Must be first of baseclasses.
79 // XInterface, XTypeProvider, XServiceInfo
80 UIConfigurationManagerImpl( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xServiceManager
81 , const com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>& _xOwner
83 ~UIConfigurationManagerImpl();
86 void dispose() throw (::com::sun::star::uno::RuntimeException
);
87 void addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
88 void removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
91 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
);
94 void addConfigurationListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
95 void removeConfigurationListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
97 // XUIConfigurationManager
98 void reset() throw (::com::sun::star::uno::RuntimeException
);
99 ::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
);
100 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> createSettings( ) throw (::com::sun::star::uno::RuntimeException
);
101 sal_Bool
hasSettings( const ::rtl::OUString
& ResourceURL
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
102 ::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
);
103 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
);
104 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
);
105 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
);
106 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getImageManager() throw (::com::sun::star::uno::RuntimeException
);
107 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getShortCutManager() throw (::com::sun::star::uno::RuntimeException
);
108 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getEventsManager() throw (::com::sun::star::uno::RuntimeException
);
110 // XUIConfigurationManagerImpl
111 sal_Bool
isDefaultSettings( const ::rtl::OUString
& ResourceURL
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
112 ::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
);
114 // XUIConfigurationPersistence
115 void reload() throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
116 void store() throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
117 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
);
118 sal_Bool
isModified() throw (::com::sun::star::uno::RuntimeException
);
119 sal_Bool
isReadOnly() throw (::com::sun::star::uno::RuntimeException
);
121 // XUIConfigurationStorage
122 void setStorage( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& Storage
) throw (::com::sun::star::uno::RuntimeException
);
123 sal_Bool
hasStorage() throw (::com::sun::star::uno::RuntimeException
);
141 UIElementInfo( const rtl::OUString
& rResourceURL
, const rtl::OUString
& rUIName
) :
142 aResourceURL( rResourceURL
), aUIName( rUIName
) {}
143 rtl::OUString aResourceURL
;
144 rtl::OUString aUIName
;
149 UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {};
151 rtl::OUString aResourceURL
;
153 bool bModified
; // has been changed since last storing
154 bool bDefault
; // default settings
155 bool bDefaultNode
; // this is a default layer element data
156 com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
> xSettings
;
159 struct UIElementType
;
160 friend struct UIElementType
;
161 typedef ::std::hash_map
< rtl::OUString
, UIElementData
, OUStringHashCode
, ::std::equal_to
< rtl::OUString
> > UIElementDataHashMap
;
165 UIElementType() : bModified( false ),
167 bDefaultLayer( false ),
168 nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN
) {}
174 sal_Int16 nElementType
;
175 UIElementDataHashMap aElementsHashMap
;
176 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> xStorage
;
179 typedef ::std::vector
< UIElementType
> UIElementTypesVector
;
180 typedef ::std::vector
< ::com::sun::star::ui::ConfigurationEvent
> ConfigEventNotifyContainer
;
181 typedef ::std::hash_map
< rtl::OUString
, UIElementInfo
, OUStringHashCode
, ::std::equal_to
< rtl::OUString
> > UIElementInfoHashMap
;
184 void impl_Initialize();
185 void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent
& aEvent
, NotifyOp eOp
);
186 void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap
& aUIElementInfoCollection
, sal_Int16 nElementType
);
187 void impl_preloadUIElementTypeList( Layer eLayer
, sal_Int16 nElementType
);
188 UIElementData
* impl_findUIElementData( const rtl::OUString
& aResourceURL
, sal_Int16 nElementType
, bool bLoad
= true );
189 void impl_requestUIElementData( sal_Int16 nElementType
, Layer eLayer
, UIElementData
& aUIElementData
);
190 void impl_storeElementTypeData( com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> xStorage
, UIElementType
& rElementType
, bool bResetModifyState
= true );
191 void impl_resetElementTypeData( UIElementType
& rUserElementType
, UIElementType
& rDefaultElementType
, ConfigEventNotifyContainer
& rRemoveNotifyContainer
, ConfigEventNotifyContainer
& rReplaceNotifyContainer
);
192 void impl_reloadElementTypeData( UIElementType
& rUserElementType
, UIElementType
& rDefaultElementType
, ConfigEventNotifyContainer
& rRemoveNotifyContainer
, ConfigEventNotifyContainer
& rReplaceNotifyContainer
);
194 UIElementTypesVector m_aUIElements
[LAYER_COUNT
];
195 PresetHandler
* m_pStorageHandler
[::com::sun::star::ui::UIElementType::COUNT
];
196 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xDefaultConfigStorage
;
197 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xUserConfigStorage
;
198 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> m_xOwner
;
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::uno::XInterface
> m_xAccConfig
;
214 com::sun::star::uno::Reference
< com::sun::star::lang::XComponent
> m_xModuleImageManager
;
218 #endif // __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGERIMPL_HXX_