1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
21 #define __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
24 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
25 with solaris headers ...
29 #include <boost/unordered_map.hpp>
31 #include <accelerators/presethandler.hxx>
32 #include <threadhelp/threadhelpbase.hxx>
33 #include <macros/generic.hxx>
34 #include <macros/xinterface.hxx>
35 #include <macros/xtypeprovider.hxx>
36 #include <macros/xserviceinfo.hxx>
38 #include <uiconfiguration/moduleimagemanager.hxx>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/lang/XTypeProvider.hpp>
42 #include <com/sun/star/lang/XComponent.hpp>
43 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
44 #include <com/sun/star/ui/XUIConfiguration.hpp>
45 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
46 #include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
47 #include <com/sun/star/ui/UIElementType.hpp>
48 #include <com/sun/star/lang/XInitialization.hpp>
49 #include <com/sun/star/ui/ConfigurationEvent.hpp>
50 #include <com/sun/star/embed/XTransactedObject.hpp>
51 #include <com/sun/star/container/XIndexContainer.hpp>
53 #include <cppuhelper/weak.hxx>
54 #include <cppuhelper/interfacecontainer.hxx>
55 #include <rtl/ustring.hxx>
60 class ModuleUIConfigurationManager
: public com::sun::star::lang::XTypeProvider
,
61 public com::sun::star::lang::XServiceInfo
,
62 public com::sun::star::lang::XComponent
,
63 public com::sun::star::lang::XInitialization
,
64 public ::com::sun::star::ui::XUIConfiguration
,
65 public ::com::sun::star::ui::XUIConfigurationManager
,
66 public ::com::sun::star::ui::XModuleUIConfigurationManager
,
67 public ::com::sun::star::ui::XUIConfigurationPersistence
,
68 private ThreadHelpBase
, // Struct for right initalization of mutex member! Must be first of baseclasses.
69 public ::cppu::OWeakObject
72 // XInterface, XTypeProvider, XServiceInfo
73 FWK_DECLARE_XINTERFACE
74 FWK_DECLARE_XTYPEPROVIDER
77 ModuleUIConfigurationManager( com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> xServiceManager
);
78 virtual ~ModuleUIConfigurationManager();
81 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
);
82 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
83 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
86 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
);
89 virtual void SAL_CALL
addConfigurationListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
90 virtual void SAL_CALL
removeConfigurationListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
92 // XUIConfigurationManager
93 virtual void SAL_CALL
reset() throw (::com::sun::star::uno::RuntimeException
);
94 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
);
95 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> SAL_CALL
createSettings( ) throw (::com::sun::star::uno::RuntimeException
);
96 virtual sal_Bool SAL_CALL
hasSettings( const OUString
& ResourceURL
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
97 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> SAL_CALL
getSettings( const OUString
& ResourceURL
, sal_Bool bWriteable
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
98 virtual void SAL_CALL
replaceSettings( const 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
);
99 virtual void SAL_CALL
removeSettings( const OUString
& ResourceURL
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::IllegalAccessException
, ::com::sun::star::uno::RuntimeException
);
100 virtual void SAL_CALL
insertSettings( const 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
);
101 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getImageManager() throw (::com::sun::star::uno::RuntimeException
);
102 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getShortCutManager() throw (::com::sun::star::uno::RuntimeException
);
103 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getEventsManager() throw (::com::sun::star::uno::RuntimeException
);
105 // XModuleUIConfigurationManager
106 virtual sal_Bool SAL_CALL
isDefaultSettings( const OUString
& ResourceURL
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
107 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> SAL_CALL
getDefaultSettings( const OUString
& ResourceURL
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
109 // XUIConfigurationPersistence
110 virtual void SAL_CALL
reload() throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
store() throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
112 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
);
113 virtual sal_Bool SAL_CALL
isModified() throw (::com::sun::star::uno::RuntimeException
);
114 virtual sal_Bool SAL_CALL
isReadOnly() throw (::com::sun::star::uno::RuntimeException
);
117 // private data types
134 UIElementInfo( const OUString
& rResourceURL
, const OUString
& rUIName
) :
135 aResourceURL( rResourceURL
), aUIName( rUIName
) {}
136 OUString aResourceURL
;
142 UIElementData() : bModified( false ), bDefault( true ), bDefaultNode( true ) {};
144 OUString aResourceURL
;
146 bool bModified
; // has been changed since last storing
147 bool bDefault
; // default settings
148 bool bDefaultNode
; // this is a default layer element data
149 com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
> xSettings
;
152 struct UIElementType
;
153 friend struct UIElementType
;
154 typedef ::boost::unordered_map
< OUString
, UIElementData
, OUStringHash
, ::std::equal_to
< OUString
> > UIElementDataHashMap
;
158 UIElementType() : bModified( false ),
160 bDefaultLayer( false ),
161 nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN
) {}
167 sal_Int16 nElementType
;
168 UIElementDataHashMap aElementsHashMap
;
169 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> xStorage
;
172 typedef ::std::vector
< UIElementType
> UIElementTypesVector
;
173 typedef ::std::vector
< ::com::sun::star::ui::ConfigurationEvent
> ConfigEventNotifyContainer
;
174 typedef ::boost::unordered_map
< OUString
, UIElementInfo
, OUStringHash
, ::std::equal_to
< OUString
> > UIElementInfoHashMap
;
177 void impl_Initialize();
178 void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent
& aEvent
, NotifyOp eOp
);
179 void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap
& aUIElementInfoCollection
, sal_Int16 nElementType
);
180 void impl_preloadUIElementTypeList( Layer eLayer
, sal_Int16 nElementType
);
181 UIElementData
* impl_findUIElementData( const OUString
& aResourceURL
, sal_Int16 nElementType
, bool bLoad
= true );
182 void impl_requestUIElementData( sal_Int16 nElementType
, Layer eLayer
, UIElementData
& aUIElementData
);
183 void impl_storeElementTypeData( com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> xStorage
, UIElementType
& rElementType
, bool bResetModifyState
= true );
184 void impl_resetElementTypeData( UIElementType
& rUserElementType
, UIElementType
& rDefaultElementType
, ConfigEventNotifyContainer
& rRemoveNotifyContainer
, ConfigEventNotifyContainer
& rReplaceNotifyContainer
);
185 void impl_reloadElementTypeData( UIElementType
& rUserElementType
, UIElementType
& rDefaultElementType
, ConfigEventNotifyContainer
& rRemoveNotifyContainer
, ConfigEventNotifyContainer
& rReplaceNotifyContainer
);
187 UIElementTypesVector m_aUIElements
[LAYER_COUNT
];
188 PresetHandler
* m_pStorageHandler
[::com::sun::star::ui::UIElementType::COUNT
];
189 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xDefaultConfigStorage
;
190 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xUserConfigStorage
;
196 OUString m_aXMLPostfix
;
197 OUString m_aPropUIName
;
198 OUString m_aPropResourceURL
;
199 OUString m_aModuleIdentifier
;
200 OUString m_aModuleShortName
;
201 com::sun::star::uno::Reference
< com::sun::star::embed::XTransactedObject
> m_xUserRootCommit
;
202 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> m_xServiceManager
;
203 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; /// container for ALL Listener
204 com::sun::star::uno::Reference
< com::sun::star::lang::XComponent
> m_xModuleImageManager
;
205 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> m_xModuleAcceleratorManager
;
209 #endif // __FRAMEWORK_UICONFIGURATION_MODULEUICONFIGMANAGER_HXX_
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */