Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
21 : #define __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
22 :
23 :
24 : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
25 : with solaris headers ...
26 : */
27 : #include <vector>
28 : #include <list>
29 : #include <boost/unordered_map.hpp>
30 :
31 : #include <threadhelp/threadhelpbase.hxx>
32 : #include <macros/generic.hxx>
33 : #include <macros/xinterface.hxx>
34 : #include <macros/xtypeprovider.hxx>
35 : #include <macros/xserviceinfo.hxx>
36 : #include <stdtypes.h>
37 : #include <uiconfiguration/imagemanager.hxx>
38 :
39 : #include <com/sun/star/container/XIndexContainer.hpp>
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/XUIConfigurationManager2.hpp>
44 : #include <com/sun/star/ui/ConfigurationEvent.hpp>
45 : #include <com/sun/star/ui/UIElementType.hpp>
46 : #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
47 :
48 : #include <cppuhelper/weak.hxx>
49 : #include <cppuhelper/interfacecontainer.hxx>
50 : #include <rtl/ustring.hxx>
51 :
52 :
53 : namespace framework
54 : {
55 : class UIConfigurationManager : public com::sun::star::lang::XTypeProvider ,
56 : public com::sun::star::lang::XServiceInfo ,
57 : public com::sun::star::ui::XUIConfigurationManager2 ,
58 : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
59 : public ::cppu::OWeakObject
60 : {
61 : public:
62 : // XInterface, XTypeProvider, XServiceInfo
63 : FWK_DECLARE_XINTERFACE
64 : FWK_DECLARE_XTYPEPROVIDER
65 : DECLARE_XSERVICEINFO
66 :
67 : UIConfigurationManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext );
68 : virtual ~UIConfigurationManager();
69 :
70 : // XComponent
71 : virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
72 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
73 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
74 :
75 : // XUIConfiguration
76 : virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
77 : virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
78 :
79 : // XUIConfigurationManager
80 : virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException);
81 : 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);
82 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings( ) throw (::com::sun::star::uno::RuntimeException);
83 : virtual sal_Bool SAL_CALL hasSettings( const OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
84 : 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);
85 : 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);
86 : 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);
87 : 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);
88 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException);
89 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
90 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException);
91 :
92 : // XUIConfigurationPersistence
93 : virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
94 : virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
95 : 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);
96 : virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
97 : virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException);
98 :
99 : // XUIConfigurationStorage
100 : virtual void SAL_CALL setStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
101 : virtual sal_Bool SAL_CALL hasStorage() throw (::com::sun::star::uno::RuntimeException);
102 :
103 : private:
104 : // private data types
105 : enum NotifyOp
106 : {
107 : NotifyOp_Remove,
108 : NotifyOp_Insert,
109 : NotifyOp_Replace
110 : };
111 :
112 0 : struct UIElementInfo
113 : {
114 0 : UIElementInfo( const OUString& rResourceURL, const OUString& rUIName ) :
115 0 : aResourceURL( rResourceURL), aUIName( rUIName ) {}
116 : OUString aResourceURL;
117 : OUString aUIName;
118 : };
119 :
120 0 : struct UIElementData
121 : {
122 0 : UIElementData() : bModified( false ), bDefault( true ) {};
123 :
124 : OUString aResourceURL;
125 : OUString aName;
126 : bool bModified; // has been changed since last storing
127 : bool bDefault; // default settings
128 : com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
129 : };
130 :
131 : struct UIElementType;
132 : friend struct UIElementType;
133 : typedef ::boost::unordered_map< OUString, UIElementData, OUStringHash, ::std::equal_to< OUString > > UIElementDataHashMap;
134 :
135 9784 : struct UIElementType
136 : {
137 9840 : UIElementType() : bModified( false ),
138 : bLoaded( false ),
139 : bDefaultLayer( false ),
140 9840 : nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
141 :
142 :
143 : bool bModified;
144 : bool bLoaded;
145 : bool bDefaultLayer;
146 : sal_Int16 nElementType;
147 : UIElementDataHashMap aElementsHashMap;
148 : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
149 : };
150 :
151 : typedef ::std::vector< UIElementType > UIElementTypesVector;
152 : typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
153 : typedef ::boost::unordered_map< OUString, UIElementInfo, OUStringHash, ::std::equal_to< OUString > > UIElementInfoHashMap;
154 :
155 : // private methods
156 : void impl_Initialize();
157 : void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
158 : void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
159 : void impl_preloadUIElementTypeList( sal_Int16 nElementType );
160 : UIElementData* impl_findUIElementData( const OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
161 : void impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData );
162 : void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState = true );
163 : void impl_resetElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer );
164 : void impl_reloadElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
165 :
166 : UIElementTypesVector m_aUIElements;
167 : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDocConfigStorage;
168 : bool m_bReadOnly;
169 : bool m_bModified;
170 : bool m_bConfigRead;
171 : bool m_bDisposed;
172 : OUString m_aXMLPostfix;
173 : OUString m_aPropUIName;
174 : OUString m_aPropResourceURL;
175 : OUString m_aModuleIdentifier;
176 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
177 : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
178 : com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xImageManager;
179 : com::sun::star::uno::Reference< com::sun::star::ui::XAcceleratorConfiguration > m_xAccConfig;
180 : };
181 : }
182 :
183 : #endif // __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
184 :
185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|