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 : #include <uiconfiguration/moduleuiconfigurationmanager.hxx>
21 : #include <threadhelp/resetableguard.hxx>
22 : #include <services.h>
23 : #include <uielement/constitemcontainer.hxx>
24 : #include <uielement/rootitemcontainer.hxx>
25 : #include <uielement/uielementtypenames.hxx>
26 : #include <framework/menuconfiguration.hxx>
27 : #include <framework/toolboxconfiguration.hxx>
28 :
29 : #include <framework/statusbarconfiguration.hxx>
30 :
31 : #include <com/sun/star/ui/UIElementType.hpp>
32 : #include <com/sun/star/ui/ConfigurationEvent.hpp>
33 : #include <com/sun/star/ui/ModuleAcceleratorConfiguration.hpp>
34 : #include <com/sun/star/lang/DisposedException.hpp>
35 : #include <com/sun/star/beans/XPropertySet.hpp>
36 : #include <com/sun/star/embed/ElementModes.hpp>
37 : #include <com/sun/star/container/XNameAccess.hpp>
38 : #include <com/sun/star/io/XStream.hpp>
39 :
40 : #include <vcl/svapp.hxx>
41 : #include <rtl/ustrbuf.hxx>
42 : #include <comphelper/sequenceashashmap.hxx>
43 :
44 : //_________________________________________________________________________________________________________________
45 : // namespaces
46 : //_________________________________________________________________________________________________________________
47 :
48 : using namespace com::sun::star::uno;
49 : using namespace com::sun::star::io;
50 : using namespace com::sun::star::embed;
51 : using namespace com::sun::star::lang;
52 : using namespace com::sun::star::container;
53 : using namespace com::sun::star::beans;
54 : using namespace ::com::sun::star::ui;
55 :
56 : namespace framework
57 : {
58 :
59 : //*****************************************************************************************************************
60 : // XInterface, XTypeProvider, XServiceInfo
61 : //*****************************************************************************************************************
62 142860 : DEFINE_XINTERFACE_8 ( ModuleUIConfigurationManager ,
63 : OWeakObject ,
64 : DIRECT_INTERFACE( css::lang::XTypeProvider ),
65 : DIRECT_INTERFACE( css::lang::XServiceInfo ),
66 : DIRECT_INTERFACE( css::lang::XComponent ),
67 : DIRECT_INTERFACE( css::lang::XInitialization ),
68 : DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfiguration ),
69 : DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationManager ),
70 : DIRECT_INTERFACE( ::com::sun::star::ui::XModuleUIConfigurationManager ),
71 : DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationPersistence )
72 : )
73 :
74 0 : DEFINE_XTYPEPROVIDER_8 ( ModuleUIConfigurationManager ,
75 : css::lang::XTypeProvider ,
76 : css::lang::XServiceInfo ,
77 : css::lang::XComponent ,
78 : css::lang::XInitialization ,
79 : ::com::sun::star::ui::XUIConfiguration ,
80 : ::com::sun::star::ui::XUIConfigurationManager ,
81 : ::com::sun::star::ui::XModuleUIConfigurationManager ,
82 : ::com::sun::star::ui::XUIConfigurationPersistence
83 : )
84 :
85 1372 : DEFINE_XSERVICEINFO_MULTISERVICE_2 ( ModuleUIConfigurationManager ,
86 : ::cppu::OWeakObject ,
87 : SERVICENAME_MODULEUICONFIGURATIONMANAGER ,
88 : IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGER
89 : )
90 :
91 77 : DEFINE_INIT_SERVICE ( ModuleUIConfigurationManager, {} )
92 :
93 :
94 : // important: The order and position of the elements must match the constant
95 : // definition of "::com::sun::star::ui::UIElementType"
96 : static const char* UIELEMENTTYPENAMES[] =
97 : {
98 : "", // Dummy value for unknown!
99 : UIELEMENTTYPE_MENUBAR_NAME,
100 : UIELEMENTTYPE_POPUPMENU_NAME,
101 : UIELEMENTTYPE_TOOLBAR_NAME,
102 : UIELEMENTTYPE_STATUSBAR_NAME,
103 : UIELEMENTTYPE_FLOATINGWINDOW_NAME,
104 : UIELEMENTTYPE_PROGRESSBAR_NAME,
105 : UIELEMENTTYPE_TOOLPANEL_NAME
106 : };
107 :
108 : static const char RESOURCEURL_PREFIX[] = "private:resource/";
109 : static const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17;
110 : static const char RESOURCEURL_CUSTOM_ELEMENT[] = "custom_";
111 :
112 8980 : static sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL )
113 : {
114 :
115 17960 : if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) &&
116 8980 : ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
117 : {
118 8980 : OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
119 8980 : sal_Int32 nIndex = aTmpStr.indexOf( '/' );
120 8980 : if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex ))
121 : {
122 8980 : OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
123 33770 : for ( int i = 0; i < UIElementType::COUNT; i++ )
124 : {
125 33770 : if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] ))
126 8980 : return sal_Int16( i );
127 0 : }
128 0 : }
129 : }
130 :
131 0 : return UIElementType::UNKNOWN;
132 : }
133 :
134 4 : static OUString RetrieveNameFromResourceURL( const OUString& aResourceURL )
135 : {
136 8 : if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) &&
137 4 : ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
138 : {
139 4 : sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
140 4 : if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
141 4 : return aResourceURL.copy( nIndex+1 );
142 : }
143 :
144 0 : return OUString();
145 : }
146 :
147 1116 : void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType )
148 : {
149 : // preload list of element types on demand
150 1116 : impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType );
151 1116 : impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
152 :
153 1116 : UIElementDataHashMap& rUserElements = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
154 1116 : UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin();
155 :
156 1116 : OUString aCustomUrlPrefix( RESOURCEURL_CUSTOM_ELEMENT );
157 2232 : while ( pUserIter != rUserElements.end() )
158 : {
159 0 : sal_Int32 nIndex = pUserIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
160 0 : if ( nIndex > RESOURCEURL_PREFIX_SIZE )
161 : {
162 : // Performance: Retrieve user interface name only for custom user interface elements.
163 : // It's only used by them!
164 0 : UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType );
165 0 : if ( pDataSettings )
166 : {
167 : // Retrieve user interface name from XPropertySet interface
168 0 : OUString aUIName;
169 0 : Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
170 0 : if ( xPropSet.is() )
171 : {
172 0 : Any a = xPropSet->getPropertyValue( m_aPropUIName );
173 0 : a >>= aUIName;
174 : }
175 :
176 0 : UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName );
177 0 : aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
178 : }
179 : }
180 : else
181 : {
182 : // The user interface name for standard user interface elements is stored in the WindowState.xcu file
183 0 : UIElementInfo aInfo( pUserIter->second.aResourceURL, OUString() );
184 0 : aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
185 : }
186 0 : ++pUserIter;
187 : }
188 :
189 1116 : UIElementDataHashMap& rDefaultElements = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
190 1116 : UIElementDataHashMap::const_iterator pDefIter = rDefaultElements.begin();
191 :
192 25757 : while ( pDefIter != rDefaultElements.end() )
193 : {
194 23525 : UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( pDefIter->second.aResourceURL );
195 23525 : if ( pIterInfo == aUIElementInfoCollection.end() )
196 : {
197 23525 : sal_Int32 nIndex = pDefIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
198 23525 : if ( nIndex > RESOURCEURL_PREFIX_SIZE )
199 : {
200 : // Performance: Retrieve user interface name only for custom user interface elements.
201 : // It's only used by them!
202 0 : UIElementData* pDataSettings = impl_findUIElementData( pDefIter->second.aResourceURL, nElementType );
203 0 : if ( pDataSettings )
204 : {
205 : // Retrieve user interface name from XPropertySet interface
206 0 : OUString aUIName;
207 0 : Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
208 0 : if ( xPropSet.is() )
209 : {
210 0 : Any a = xPropSet->getPropertyValue( m_aPropUIName );
211 0 : a >>= aUIName;
212 : }
213 :
214 0 : UIElementInfo aInfo( pDefIter->second.aResourceURL, aUIName );
215 0 : aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo ));
216 : }
217 : }
218 : else
219 : {
220 : // The user interface name for standard user interface elements is stored in the WindowState.xcu file
221 23525 : UIElementInfo aInfo( pDefIter->second.aResourceURL, OUString() );
222 23525 : aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo ));
223 : }
224 : }
225 :
226 23525 : ++pDefIter;
227 1116 : }
228 1116 : }
229 :
230 20193 : void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType )
231 : {
232 20193 : UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType];
233 :
234 20193 : if ( !rElementTypeData.bLoaded )
235 : {
236 14367 : Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
237 14367 : if ( xElementTypeStorage.is() )
238 : {
239 14304 : OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE );
240 14304 : aBuf.appendAscii( RESOURCEURL_PREFIX );
241 14304 : aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] );
242 14304 : aBuf.appendAscii( "/" );
243 28608 : OUString aResURLPrefix( aBuf.makeStringAndClear() );
244 :
245 14304 : UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap;
246 28608 : Sequence< OUString > aUIElementNames = xElementTypeStorage->getElementNames();
247 16096 : for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ )
248 : {
249 1792 : UIElementData aUIElementData;
250 :
251 : // Resource name must be without ".xml"
252 1792 : sal_Int32 nIndex = aUIElementNames[n].lastIndexOf( '.' );
253 1792 : if (( nIndex > 0 ) && ( nIndex < aUIElementNames[n].getLength() ))
254 : {
255 1792 : OUString aExtension( aUIElementNames[n].copy( nIndex+1 ));
256 3584 : OUString aUIElementName( aUIElementNames[n].copy( 0, nIndex ));
257 :
258 3584 : if (!aUIElementName.isEmpty() &&
259 1792 : ( aExtension.equalsIgnoreAsciiCase("xml")))
260 : {
261 1792 : aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
262 1792 : aUIElementData.aName = aUIElementNames[n];
263 :
264 1792 : if ( eLayer == LAYER_USERDEFINED )
265 : {
266 0 : aUIElementData.bModified = false;
267 0 : aUIElementData.bDefault = false;
268 0 : aUIElementData.bDefaultNode = false;
269 : }
270 :
271 : // Create boost::unordered_map entries for all user interface elements inside the storage. We don't load the
272 : // settings to speed up the process.
273 1792 : rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData ));
274 1792 : }
275 : }
276 1792 : rElementTypeData.bLoaded = true;
277 16096 : }
278 14367 : }
279 : }
280 :
281 20193 : }
282 :
283 205 : void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData )
284 : {
285 205 : UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType];
286 :
287 205 : Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
288 205 : if ( xElementTypeStorage.is() && !aUIElementData.aName.isEmpty() )
289 : {
290 : try
291 : {
292 205 : Reference< XStream > xStream = xElementTypeStorage->openStreamElement( aUIElementData.aName, ElementModes::READ );
293 205 : Reference< XInputStream > xInputStream = xStream->getInputStream();
294 :
295 205 : if ( xInputStream.is() )
296 : {
297 205 : switch ( nElementType )
298 : {
299 : case ::com::sun::star::ui::UIElementType::UNKNOWN:
300 0 : break;
301 :
302 : case ::com::sun::star::ui::UIElementType::MENUBAR:
303 : {
304 : try
305 : {
306 48 : MenuConfiguration aMenuCfg( m_xContext );
307 96 : Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
308 48 : RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer );
309 48 : if ( pRootItemContainer )
310 48 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
311 : else
312 0 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, sal_True ) ), UNO_QUERY );
313 96 : return;
314 : }
315 0 : catch ( const ::com::sun::star::lang::WrappedTargetException& )
316 : {
317 : }
318 : }
319 0 : break;
320 :
321 : case ::com::sun::star::ui::UIElementType::POPUPMENU:
322 : {
323 0 : break;
324 : }
325 :
326 : case ::com::sun::star::ui::UIElementType::TOOLBAR:
327 : {
328 : try
329 : {
330 112 : Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
331 112 : ToolBoxConfiguration::LoadToolBox( m_xContext, xInputStream, xIndexContainer );
332 112 : RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
333 112 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
334 112 : return;
335 : }
336 0 : catch ( const ::com::sun::star::lang::WrappedTargetException& )
337 : {
338 : }
339 :
340 0 : break;
341 : }
342 :
343 : case ::com::sun::star::ui::UIElementType::STATUSBAR:
344 : {
345 : try
346 : {
347 45 : Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
348 45 : StatusBarConfiguration::LoadStatusBar( m_xContext, xInputStream, xIndexContainer );
349 45 : RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
350 45 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
351 45 : return;
352 : }
353 0 : catch ( const ::com::sun::star::lang::WrappedTargetException& )
354 : {
355 : }
356 :
357 0 : break;
358 : }
359 :
360 : case ::com::sun::star::ui::UIElementType::FLOATINGWINDOW:
361 : {
362 0 : break;
363 : }
364 : }
365 0 : }
366 : }
367 0 : catch ( const ::com::sun::star::embed::InvalidStorageException& )
368 : {
369 : }
370 0 : catch ( const ::com::sun::star::lang::IllegalArgumentException& )
371 : {
372 : }
373 0 : catch ( const ::com::sun::star::io::IOException& )
374 : {
375 : }
376 0 : catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
377 : {
378 : }
379 : }
380 :
381 : // At least we provide an empty settings container!
382 0 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer() ), UNO_QUERY );
383 : }
384 :
385 8980 : ModuleUIConfigurationManager::UIElementData* ModuleUIConfigurationManager::impl_findUIElementData( const OUString& aResourceURL, sal_Int16 nElementType, bool bLoad )
386 : {
387 : // preload list of element types on demand
388 8980 : impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType );
389 8980 : impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
390 :
391 : // first try to look into our user-defined vector/boost::unordered_map combination
392 8980 : UIElementDataHashMap& rUserHashMap = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
393 8980 : UIElementDataHashMap::iterator pIter = rUserHashMap.find( aResourceURL );
394 8980 : if ( pIter != rUserHashMap.end() )
395 : {
396 : // Default data settings data must be retrieved from the default layer!
397 6 : if ( !pIter->second.bDefault )
398 : {
399 5 : if ( !pIter->second.xSettings.is() && bLoad )
400 0 : impl_requestUIElementData( nElementType, LAYER_USERDEFINED, pIter->second );
401 5 : return &(pIter->second);
402 : }
403 : }
404 :
405 : // Not successful, we have to look into our default vector/boost::unordered_map combination
406 8975 : UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
407 8975 : pIter = rDefaultHashMap.find( aResourceURL );
408 8975 : if ( pIter != rDefaultHashMap.end() )
409 : {
410 5292 : if ( !pIter->second.xSettings.is() && bLoad )
411 202 : impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second );
412 5292 : return &(pIter->second);
413 : }
414 :
415 : // Nothing has been found!
416 3683 : return NULL;
417 : }
418 :
419 0 : void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState )
420 : {
421 0 : UIElementDataHashMap& rHashMap = rElementType.aElementsHashMap;
422 0 : UIElementDataHashMap::iterator pIter = rHashMap.begin();
423 :
424 0 : while ( pIter != rHashMap.end() )
425 : {
426 0 : UIElementData& rElement = pIter->second;
427 0 : if ( rElement.bModified )
428 : {
429 0 : if ( rElement.bDefault )
430 : {
431 0 : xStorage->removeElement( rElement.aName );
432 0 : rElement.bModified = sal_False; // mark as not modified
433 : }
434 : else
435 : {
436 0 : Reference< XStream > xStream( xStorage->openStreamElement( rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY );
437 0 : Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
438 :
439 0 : if ( xOutputStream.is() )
440 : {
441 0 : switch( rElementType.nElementType )
442 : {
443 : case ::com::sun::star::ui::UIElementType::MENUBAR:
444 : {
445 : try
446 : {
447 0 : MenuConfiguration aMenuCfg( m_xContext );
448 0 : aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream );
449 : }
450 0 : catch ( const ::com::sun::star::lang::WrappedTargetException& )
451 : {
452 : }
453 : }
454 0 : break;
455 :
456 : case ::com::sun::star::ui::UIElementType::TOOLBAR:
457 : {
458 : try
459 : {
460 0 : ToolBoxConfiguration::StoreToolBox( m_xContext, xOutputStream, rElement.xSettings );
461 : }
462 0 : catch ( const ::com::sun::star::lang::WrappedTargetException& )
463 : {
464 : }
465 : }
466 0 : break;
467 :
468 : case ::com::sun::star::ui::UIElementType::STATUSBAR:
469 : {
470 : try
471 : {
472 0 : StatusBarConfiguration::StoreStatusBar( m_xContext, xOutputStream, rElement.xSettings );
473 : }
474 0 : catch ( const ::com::sun::star::lang::WrappedTargetException& )
475 : {
476 : }
477 : }
478 0 : break;
479 :
480 : default:
481 0 : break;
482 : }
483 : }
484 :
485 : // mark as not modified if we store to our own storage
486 0 : if ( bResetModifyState )
487 0 : rElement.bModified = sal_False;
488 : }
489 : }
490 :
491 0 : ++pIter;
492 : }
493 :
494 : // commit element type storage
495 0 : Reference< XTransactedObject > xTransactedObject( xStorage, UNO_QUERY );
496 0 : if ( xTransactedObject.is() )
497 0 : xTransactedObject->commit();
498 :
499 : // mark UIElementType as not modified if we store to our own storage
500 0 : if ( bResetModifyState )
501 0 : rElementType.bModified = sal_False;
502 0 : }
503 :
504 : // This is only allowed to be called on the LAYER_USER_DEFINED!
505 21 : void ModuleUIConfigurationManager::impl_resetElementTypeData(
506 : UIElementType& rUserElementType,
507 : UIElementType& rDefaultElementType,
508 : ConfigEventNotifyContainer& rRemoveNotifyContainer,
509 : ConfigEventNotifyContainer& rReplaceNotifyContainer )
510 : {
511 21 : UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap;
512 21 : UIElementDataHashMap::iterator pIter = rHashMap.begin();
513 :
514 21 : Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
515 42 : Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
516 21 : sal_Int16 nType = rUserElementType.nElementType;
517 :
518 : // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
519 : // our listeners!
520 46 : while ( pIter != rHashMap.end() )
521 : {
522 4 : UIElementData& rElement = pIter->second;
523 4 : if ( !rElement.bDefault )
524 : {
525 3 : if ( xDefaultNameAccess->hasByName( rElement.aName ))
526 : {
527 : // Replace settings with data from default layer
528 3 : Reference< XIndexAccess > xOldSettings( rElement.xSettings );
529 3 : impl_requestUIElementData( nType, LAYER_DEFAULT, rElement );
530 :
531 6 : ConfigurationEvent aReplaceEvent;
532 3 : aReplaceEvent.ResourceURL = rElement.aResourceURL;
533 3 : aReplaceEvent.Accessor <<= xThis;
534 3 : aReplaceEvent.Source = xThis;
535 3 : aReplaceEvent.ReplacedElement <<= xOldSettings;
536 3 : aReplaceEvent.Element <<= rElement.xSettings;
537 :
538 3 : rReplaceNotifyContainer.push_back( aReplaceEvent );
539 :
540 : // Mark element as default and not modified. That means "not active"
541 : // in the user layer anymore.
542 3 : rElement.bModified = false;
543 6 : rElement.bDefault = true;
544 : }
545 : else
546 : {
547 : // Remove user-defined settings from user layer
548 0 : ConfigurationEvent aEvent;
549 0 : aEvent.ResourceURL = rElement.aResourceURL;
550 0 : aEvent.Accessor <<= xThis;
551 0 : aEvent.Source = xThis;
552 0 : aEvent.Element <<= rElement.xSettings;
553 :
554 0 : rRemoveNotifyContainer.push_back( aEvent );
555 :
556 : // Mark element as default and not modified. That means "not active"
557 : // in the user layer anymore.
558 0 : rElement.bModified = false;
559 0 : rElement.bDefault = true;
560 : }
561 : }
562 :
563 4 : ++pIter;
564 : }
565 :
566 : // Remove all settings from our user interface elements
567 42 : rHashMap.clear();
568 21 : }
569 :
570 0 : void ModuleUIConfigurationManager::impl_reloadElementTypeData(
571 : UIElementType& rUserElementType,
572 : UIElementType& rDefaultElementType,
573 : ConfigEventNotifyContainer& rRemoveNotifyContainer,
574 : ConfigEventNotifyContainer& rReplaceNotifyContainer )
575 : {
576 0 : UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap;
577 0 : UIElementDataHashMap::iterator pIter = rHashMap.begin();
578 0 : Reference< XStorage > xUserStorage( rUserElementType.xStorage );
579 0 : Reference< XStorage > xDefaultStorage( rDefaultElementType.xStorage );
580 0 : Reference< XNameAccess > xUserNameAccess( rUserElementType.xStorage, UNO_QUERY );
581 0 : Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
582 :
583 0 : Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
584 0 : sal_Int16 nType = rUserElementType.nElementType;
585 :
586 0 : while ( pIter != rHashMap.end() )
587 : {
588 0 : UIElementData& rElement = pIter->second;
589 0 : if ( rElement.bModified )
590 : {
591 0 : if ( xUserNameAccess->hasByName( rElement.aName ))
592 : {
593 : // Replace settings with data from user layer
594 0 : Reference< XIndexAccess > xOldSettings( rElement.xSettings );
595 :
596 0 : impl_requestUIElementData( nType, LAYER_USERDEFINED, rElement );
597 :
598 0 : ConfigurationEvent aReplaceEvent;
599 :
600 0 : aReplaceEvent.ResourceURL = rElement.aResourceURL;
601 0 : aReplaceEvent.Accessor <<= xThis;
602 0 : aReplaceEvent.Source = xThis;
603 0 : aReplaceEvent.ReplacedElement <<= xOldSettings;
604 0 : aReplaceEvent.Element <<= rElement.xSettings;
605 0 : rReplaceNotifyContainer.push_back( aReplaceEvent );
606 :
607 0 : rElement.bModified = false;
608 : }
609 0 : else if ( xDefaultNameAccess->hasByName( rElement.aName ))
610 : {
611 : // Replace settings with data from default layer
612 0 : Reference< XIndexAccess > xOldSettings( rElement.xSettings );
613 :
614 0 : impl_requestUIElementData( nType, LAYER_DEFAULT, rElement );
615 :
616 0 : ConfigurationEvent aReplaceEvent;
617 :
618 0 : aReplaceEvent.ResourceURL = rElement.aResourceURL;
619 0 : aReplaceEvent.Accessor <<= xThis;
620 0 : aReplaceEvent.Source = xThis;
621 0 : aReplaceEvent.ReplacedElement <<= xOldSettings;
622 0 : aReplaceEvent.Element <<= rElement.xSettings;
623 0 : rReplaceNotifyContainer.push_back( aReplaceEvent );
624 :
625 : // Mark element as default and not modified. That means "not active"
626 : // in the user layer anymore.
627 0 : rElement.bModified = false;
628 0 : rElement.bDefault = true;
629 : }
630 : else
631 : {
632 : // Element settings are not in any storage => remove
633 0 : ConfigurationEvent aRemoveEvent;
634 :
635 0 : aRemoveEvent.ResourceURL = rElement.aResourceURL;
636 0 : aRemoveEvent.Accessor <<= xThis;
637 0 : aRemoveEvent.Source = xThis;
638 0 : aRemoveEvent.Element <<= rElement.xSettings;
639 :
640 0 : rRemoveNotifyContainer.push_back( aRemoveEvent );
641 :
642 : // Mark element as default and not modified. That means "not active"
643 : // in the user layer anymore.
644 0 : rElement.bModified = false;
645 0 : rElement.bDefault = true;
646 : }
647 : }
648 0 : ++pIter;
649 : }
650 :
651 0 : rUserElementType.bModified = sal_False;
652 0 : }
653 :
654 77 : void ModuleUIConfigurationManager::impl_Initialize()
655 : {
656 : // Initialize the top-level structures with the storage data
657 77 : if ( m_xUserConfigStorage.is() )
658 : {
659 : // Try to access our module sub folder
660 608 : for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
661 : i++ )
662 : {
663 532 : Reference< XStorage > xElementTypeStorage;
664 : try
665 : {
666 532 : if ( m_pStorageHandler[i] )
667 228 : xElementTypeStorage = m_pStorageHandler[i]->getWorkingStorageUser();
668 : }
669 0 : catch ( const com::sun::star::container::NoSuchElementException& )
670 : {
671 : }
672 0 : catch ( const ::com::sun::star::embed::InvalidStorageException& )
673 : {
674 : }
675 0 : catch ( const ::com::sun::star::lang::IllegalArgumentException& )
676 : {
677 : }
678 0 : catch ( const ::com::sun::star::io::IOException& )
679 : {
680 : }
681 0 : catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
682 : {
683 : }
684 :
685 532 : m_aUIElements[LAYER_USERDEFINED][i].nElementType = i;
686 532 : m_aUIElements[LAYER_USERDEFINED][i].bModified = false;
687 532 : m_aUIElements[LAYER_USERDEFINED][i].xStorage = xElementTypeStorage;
688 532 : m_aUIElements[LAYER_USERDEFINED][i].bDefaultLayer = false;
689 532 : }
690 : }
691 :
692 77 : if ( m_xDefaultConfigStorage.is() )
693 : {
694 75 : Reference< XNameAccess > xNameAccess( m_xDefaultConfigStorage, UNO_QUERY_THROW );
695 :
696 : // Try to access our module sub folder
697 600 : for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
698 : i++ )
699 : {
700 525 : Reference< XStorage > xElementTypeStorage;
701 : try
702 : {
703 525 : const OUString sName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ) );
704 525 : if( xNameAccess->hasByName( sName ) )
705 224 : xNameAccess->getByName( sName ) >>= xElementTypeStorage;
706 : }
707 0 : catch ( const com::sun::star::container::NoSuchElementException& )
708 : {
709 : }
710 :
711 525 : m_aUIElements[LAYER_DEFAULT][i].nElementType = i;
712 525 : m_aUIElements[LAYER_DEFAULT][i].bModified = false;
713 525 : m_aUIElements[LAYER_DEFAULT][i].xStorage = xElementTypeStorage;
714 525 : m_aUIElements[LAYER_DEFAULT][i].bDefaultLayer = true;
715 600 : }
716 : }
717 77 : }
718 :
719 77 : ModuleUIConfigurationManager::ModuleUIConfigurationManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext ) :
720 77 : ThreadHelpBase( &Application::GetSolarMutex() )
721 : , m_xDefaultConfigStorage( 0 )
722 : , m_xUserConfigStorage( 0 )
723 : , m_bReadOnly( true )
724 : , m_bInitialized( false )
725 : , m_bModified( false )
726 : , m_bConfigRead( false )
727 : , m_bDisposed( false )
728 : , m_aXMLPostfix( ".xml" )
729 : , m_aPropUIName( "UIName" )
730 : , m_aPropResourceURL( "ResourceURL" )
731 : , m_xContext( xContext )
732 154 : , m_aListenerContainer( m_aLock.getShareableOslMutex() )
733 : {
734 693 : for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
735 616 : m_pStorageHandler[i] = 0;
736 :
737 : // Make sure we have a default initialized entry for every layer and user interface element type!
738 : // The following code depends on this!
739 77 : m_aUIElements[LAYER_DEFAULT].resize( ::com::sun::star::ui::UIElementType::COUNT );
740 77 : m_aUIElements[LAYER_USERDEFINED].resize( ::com::sun::star::ui::UIElementType::COUNT );
741 77 : }
742 :
743 222 : ModuleUIConfigurationManager::~ModuleUIConfigurationManager()
744 : {
745 666 : for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
746 592 : delete m_pStorageHandler[i];
747 148 : }
748 :
749 : // XComponent
750 76 : void SAL_CALL ModuleUIConfigurationManager::dispose() throw (::com::sun::star::uno::RuntimeException)
751 : {
752 76 : Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
753 :
754 152 : css::lang::EventObject aEvent( xThis );
755 76 : m_aListenerContainer.disposeAndClear( aEvent );
756 :
757 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
758 152 : ResetableGuard aGuard( m_aLock );
759 152 : Reference< XComponent > xModuleImageManager( m_xModuleImageManager );
760 76 : m_xModuleImageManager.clear();
761 152 : Reference< XComponent > xCompMAM( m_xModuleAcceleratorManager, UNO_QUERY );
762 76 : if ( xCompMAM.is() )
763 46 : xCompMAM->dispose();
764 76 : m_xModuleAcceleratorManager.clear();
765 76 : m_aUIElements[LAYER_USERDEFINED].clear();
766 76 : m_aUIElements[LAYER_DEFAULT].clear();
767 76 : m_xDefaultConfigStorage.clear();
768 76 : m_xUserConfigStorage.clear();
769 76 : m_xUserRootCommit.clear();
770 76 : m_bConfigRead = false;
771 76 : m_bModified = false;
772 76 : m_bDisposed = true;
773 76 : aGuard.unlock();
774 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
775 :
776 : try
777 : {
778 76 : if ( xModuleImageManager.is() )
779 74 : xModuleImageManager->dispose();
780 : }
781 0 : catch ( const Exception& )
782 : {
783 76 : }
784 76 : }
785 :
786 0 : void SAL_CALL ModuleUIConfigurationManager::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
787 : {
788 : {
789 0 : ResetableGuard aGuard( m_aLock );
790 :
791 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
792 0 : if ( m_bDisposed )
793 0 : throw DisposedException();
794 : }
795 :
796 0 : m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
797 0 : }
798 :
799 0 : void SAL_CALL ModuleUIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
800 : {
801 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
802 0 : m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
803 0 : }
804 :
805 : // XInitialization
806 78 : void SAL_CALL ModuleUIConfigurationManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
807 : {
808 78 : ResetableGuard aLock( m_aLock );
809 :
810 78 : if ( !m_bInitialized )
811 : {
812 77 : ::comphelper::SequenceAsHashMap lArgs(aArguments);
813 77 : m_aModuleIdentifier = lArgs.getUnpackedValueOrDefault("ModuleIdentifier", OUString());
814 77 : m_aModuleShortName = lArgs.getUnpackedValueOrDefault("ModuleShortName", OUString());
815 :
816 616 : for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
817 : {
818 539 : OUString aResourceType;
819 539 : if ( i == ::com::sun::star::ui::UIElementType::MENUBAR )
820 77 : aResourceType = PresetHandler::RESOURCETYPE_MENUBAR();
821 462 : else if ( i == ::com::sun::star::ui::UIElementType::TOOLBAR )
822 77 : aResourceType = PresetHandler::RESOURCETYPE_TOOLBAR();
823 385 : else if ( i == ::com::sun::star::ui::UIElementType::STATUSBAR )
824 77 : aResourceType = PresetHandler::RESOURCETYPE_STATUSBAR();
825 :
826 539 : if ( !aResourceType.isEmpty() )
827 : {
828 231 : m_pStorageHandler[i] = new PresetHandler( m_xContext );
829 231 : m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES,
830 : aResourceType, // this path wont be used later ... seee next lines!
831 : m_aModuleShortName,
832 462 : css::uno::Reference< css::embed::XStorage >()); // no document root used here!
833 : }
834 539 : }
835 :
836 : // initialize root storages for all resource types
837 154 : m_xUserRootCommit = css::uno::Reference< css::embed::XTransactedObject >(
838 154 : m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getOrCreateRootStorageUser(), css::uno::UNO_QUERY); // can be empty
839 154 : m_xDefaultConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageShare(
840 154 : m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageShare());
841 154 : m_xUserConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageUser(
842 154 : m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageUser());
843 :
844 77 : if ( m_xUserConfigStorage.is() )
845 : {
846 76 : Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY );
847 76 : if ( xPropSet.is() )
848 : {
849 76 : long nOpenMode = 0;
850 76 : Any a = xPropSet->getPropertyValue("OpenMode");
851 76 : if ( a >>= nOpenMode )
852 76 : m_bReadOnly = !( nOpenMode & ElementModes::WRITE );
853 76 : }
854 : }
855 :
856 77 : impl_Initialize();
857 :
858 77 : m_bInitialized = true;
859 78 : }
860 78 : }
861 :
862 : // XUIConfiguration
863 1106 : void SAL_CALL ModuleUIConfigurationManager::addConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
864 : {
865 : {
866 1106 : ResetableGuard aGuard( m_aLock );
867 :
868 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
869 1106 : if ( m_bDisposed )
870 0 : throw DisposedException();
871 : }
872 :
873 1106 : m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
874 1106 : }
875 :
876 1103 : void SAL_CALL ModuleUIConfigurationManager::removeConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
877 : {
878 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
879 1103 : m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
880 1103 : }
881 :
882 :
883 : // XUIConfigurationManager
884 3 : void SAL_CALL ModuleUIConfigurationManager::reset() throw (::com::sun::star::uno::RuntimeException)
885 : {
886 3 : ResetableGuard aGuard( m_aLock );
887 :
888 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
889 3 : if ( m_bDisposed )
890 0 : throw DisposedException();
891 :
892 3 : if ( !isReadOnly() )
893 : {
894 : // Remove all elements from our user-defined storage!
895 : try
896 : {
897 24 : for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
898 : {
899 21 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i];
900 21 : Reference< XStorage > xSubStorage( rElementType.xStorage, UNO_QUERY );
901 :
902 21 : if ( xSubStorage.is() )
903 : {
904 9 : bool bCommitSubStorage( false );
905 9 : Sequence< OUString > aUIElementStreamNames = xSubStorage->getElementNames();
906 9 : for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ )
907 : {
908 0 : xSubStorage->removeElement( aUIElementStreamNames[j] );
909 0 : bCommitSubStorage = true;
910 : }
911 :
912 9 : if ( bCommitSubStorage )
913 : {
914 0 : Reference< XTransactedObject > xTransactedObject( xSubStorage, UNO_QUERY );
915 0 : if ( xTransactedObject.is() )
916 0 : xTransactedObject->commit();
917 0 : m_pStorageHandler[i]->commitUserChanges();
918 9 : }
919 : }
920 21 : }
921 :
922 : // remove settings from user defined layer and notify listener about removed settings data!
923 3 : ConfigEventNotifyContainer aRemoveEventNotifyContainer;
924 6 : ConfigEventNotifyContainer aReplaceEventNotifyContainer;
925 24 : for ( sal_Int16 j = 1; j < ::com::sun::star::ui::UIElementType::COUNT; j++ )
926 : {
927 : try
928 : {
929 21 : UIElementType& rUserElementType = m_aUIElements[LAYER_USERDEFINED][j];
930 21 : UIElementType& rDefaultElementType = m_aUIElements[LAYER_DEFAULT][j];
931 :
932 21 : impl_resetElementTypeData( rUserElementType, rDefaultElementType, aRemoveEventNotifyContainer, aReplaceEventNotifyContainer );
933 21 : rUserElementType.bModified = sal_False;
934 : }
935 0 : catch ( const Exception& )
936 : {
937 0 : throw IOException();
938 : }
939 : }
940 :
941 3 : m_bModified = sal_False;
942 :
943 : // Unlock mutex before notify our listeners
944 3 : aGuard.unlock();
945 :
946 : // Notify our listeners
947 3 : sal_uInt32 k = 0;
948 3 : for ( k = 0; k < aRemoveEventNotifyContainer.size(); k++ )
949 0 : implts_notifyContainerListener( aRemoveEventNotifyContainer[k], NotifyOp_Remove );
950 6 : for ( k = 0; k < aReplaceEventNotifyContainer.size(); k++ )
951 6 : implts_notifyContainerListener( aReplaceEventNotifyContainer[k], NotifyOp_Replace );
952 : }
953 0 : catch ( const ::com::sun::star::lang::IllegalArgumentException& )
954 : {
955 : }
956 0 : catch ( const ::com::sun::star::container::NoSuchElementException& )
957 : {
958 : }
959 0 : catch ( const ::com::sun::star::embed::InvalidStorageException& )
960 : {
961 : }
962 0 : catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
963 : {
964 : }
965 3 : }
966 3 : }
967 :
968 1109 : Sequence< Sequence< PropertyValue > > SAL_CALL ModuleUIConfigurationManager::getUIElementsInfo( sal_Int16 ElementType )
969 : throw ( IllegalArgumentException, RuntimeException )
970 : {
971 1109 : if (( ElementType < 0 ) || ( ElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
972 0 : throw IllegalArgumentException();
973 :
974 1109 : ResetableGuard aGuard( m_aLock );
975 1109 : if ( m_bDisposed )
976 0 : throw DisposedException();
977 :
978 1109 : Sequence< Sequence< PropertyValue > > aElementInfoSeq;
979 2218 : UIElementInfoHashMap aUIElementInfoCollection;
980 :
981 1109 : if ( ElementType == ::com::sun::star::ui::UIElementType::UNKNOWN )
982 : {
983 9 : for ( sal_Int16 i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
984 8 : impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, sal_Int16( i ) );
985 : }
986 : else
987 1108 : impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType );
988 :
989 2218 : Sequence< PropertyValue > aUIElementInfo( 2 );
990 1109 : aUIElementInfo[0].Name = m_aPropResourceURL;
991 1109 : aUIElementInfo[1].Name = m_aPropUIName;
992 :
993 1109 : aElementInfoSeq.realloc( aUIElementInfoCollection.size() );
994 1109 : UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin();
995 :
996 1109 : sal_Int32 n = 0;
997 25743 : while ( pIter != aUIElementInfoCollection.end() )
998 : {
999 23525 : aUIElementInfo[0].Value <<= pIter->second.aResourceURL;
1000 23525 : aUIElementInfo[1].Value <<= pIter->second.aUIName;
1001 23525 : aElementInfoSeq[n++] = aUIElementInfo;
1002 23525 : ++pIter;
1003 : }
1004 :
1005 2218 : return aElementInfoSeq;
1006 : }
1007 :
1008 1 : Reference< XIndexContainer > SAL_CALL ModuleUIConfigurationManager::createSettings() throw (::com::sun::star::uno::RuntimeException)
1009 : {
1010 1 : ResetableGuard aGuard( m_aLock );
1011 :
1012 1 : if ( m_bDisposed )
1013 0 : throw DisposedException();
1014 :
1015 : // Creates an empty item container which can be filled from outside
1016 1 : return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
1017 : }
1018 :
1019 4481 : sal_Bool SAL_CALL ModuleUIConfigurationManager::hasSettings( const OUString& ResourceURL )
1020 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1021 : {
1022 4481 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1023 :
1024 4481 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1025 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1026 0 : throw IllegalArgumentException();
1027 : else
1028 : {
1029 4481 : ResetableGuard aGuard( m_aLock );
1030 :
1031 4481 : if ( m_bDisposed )
1032 0 : throw DisposedException();
1033 :
1034 4481 : UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
1035 4481 : if ( pDataSettings )
1036 2641 : return sal_True;
1037 : }
1038 :
1039 1840 : return sal_False;
1040 : }
1041 :
1042 4491 : Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getSettings( const OUString& ResourceURL, sal_Bool bWriteable )
1043 : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1044 : {
1045 4491 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1046 :
1047 4491 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1048 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1049 0 : throw IllegalArgumentException();
1050 : else
1051 : {
1052 4491 : ResetableGuard aGuard( m_aLock );
1053 :
1054 4491 : if ( m_bDisposed )
1055 0 : throw DisposedException();
1056 :
1057 4491 : UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1058 4491 : if ( pDataSettings )
1059 : {
1060 : // Create a copy of our data if someone wants to change the data.
1061 2651 : if ( bWriteable )
1062 4 : return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY );
1063 : else
1064 2647 : return pDataSettings->xSettings;
1065 1840 : }
1066 : }
1067 :
1068 1840 : throw NoSuchElementException();
1069 : }
1070 :
1071 3 : void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const OUString& ResourceURL, const Reference< ::com::sun::star::container::XIndexAccess >& aNewData )
1072 : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
1073 : {
1074 3 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1075 :
1076 3 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1077 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1078 0 : throw IllegalArgumentException();
1079 3 : else if ( m_bReadOnly )
1080 0 : throw IllegalAccessException();
1081 : else
1082 : {
1083 3 : ResetableGuard aGuard( m_aLock );
1084 :
1085 3 : if ( m_bDisposed )
1086 0 : throw DisposedException();
1087 :
1088 3 : UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1089 3 : if ( pDataSettings )
1090 : {
1091 3 : if ( !pDataSettings->bDefaultNode )
1092 : {
1093 : // we have a settings entry in our user-defined layer - replace
1094 0 : Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
1095 :
1096 : // Create a copy of the data if the container is not const
1097 0 : Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
1098 0 : if ( xReplace.is() )
1099 0 : pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
1100 : else
1101 0 : pDataSettings->xSettings = aNewData;
1102 0 : pDataSettings->bDefault = false;
1103 0 : pDataSettings->bModified = true;
1104 0 : m_bModified = true;
1105 :
1106 : // Modify type container
1107 0 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1108 0 : rElementType.bModified = true;
1109 :
1110 0 : Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1111 :
1112 : // Create event to notify listener about replaced element settings
1113 0 : ConfigurationEvent aEvent;
1114 0 : aEvent.ResourceURL = ResourceURL;
1115 0 : aEvent.Accessor <<= xThis;
1116 0 : aEvent.Source = xThis;
1117 0 : aEvent.ReplacedElement <<= xOldSettings;
1118 0 : aEvent.Element <<= pDataSettings->xSettings;
1119 :
1120 0 : aGuard.unlock();
1121 :
1122 0 : implts_notifyContainerListener( aEvent, NotifyOp_Replace );
1123 : }
1124 : else
1125 : {
1126 : // we have no settings in our user-defined layer - insert
1127 3 : UIElementData aUIElementData;
1128 :
1129 3 : aUIElementData.bDefault = false;
1130 3 : aUIElementData.bDefaultNode = false;
1131 3 : aUIElementData.bModified = true;
1132 :
1133 : // Create a copy of the data if the container is not const
1134 6 : Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
1135 3 : if ( xReplace.is() )
1136 3 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
1137 : else
1138 0 : aUIElementData.xSettings = aNewData;
1139 3 : aUIElementData.aName = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix;
1140 3 : aUIElementData.aResourceURL = ResourceURL;
1141 3 : m_bModified = true;
1142 :
1143 : // Modify type container
1144 3 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1145 3 : rElementType.bModified = true;
1146 :
1147 3 : UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
1148 :
1149 : // Check our user element settings hash map as it can already contain settings that have been set to default!
1150 : // If no node can be found, we have to insert it.
1151 3 : UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL );
1152 3 : if ( pIter != rElements.end() )
1153 0 : pIter->second = aUIElementData;
1154 : else
1155 3 : rElements.insert( UIElementDataHashMap::value_type( ResourceURL, aUIElementData ));
1156 :
1157 6 : Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1158 :
1159 : // Create event to notify listener about replaced element settings
1160 6 : ConfigurationEvent aEvent;
1161 :
1162 3 : aEvent.ResourceURL = ResourceURL;
1163 3 : aEvent.Accessor <<= xThis;
1164 3 : aEvent.Source = xThis;
1165 3 : aEvent.ReplacedElement <<= pDataSettings->xSettings;
1166 3 : aEvent.Element <<= aUIElementData.xSettings;
1167 :
1168 3 : aGuard.unlock();
1169 :
1170 6 : implts_notifyContainerListener( aEvent, NotifyOp_Replace );
1171 : }
1172 : }
1173 : else
1174 0 : throw NoSuchElementException();
1175 : }
1176 3 : }
1177 :
1178 1 : void SAL_CALL ModuleUIConfigurationManager::removeSettings( const OUString& ResourceURL )
1179 : throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException, RuntimeException)
1180 : {
1181 1 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1182 :
1183 1 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1184 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1185 0 : throw IllegalArgumentException();
1186 1 : else if ( m_bReadOnly )
1187 0 : throw IllegalAccessException();
1188 : else
1189 : {
1190 1 : ResetableGuard aGuard( m_aLock );
1191 :
1192 1 : if ( m_bDisposed )
1193 0 : throw DisposedException();
1194 :
1195 1 : UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1196 1 : if ( pDataSettings )
1197 : {
1198 : // If element settings are default, we don't need to change anything!
1199 1 : if ( pDataSettings->bDefault )
1200 1 : return;
1201 : else
1202 : {
1203 1 : Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
1204 1 : pDataSettings->bDefault = true;
1205 :
1206 : // check if this is a default layer node
1207 1 : if ( !pDataSettings->bDefaultNode )
1208 1 : pDataSettings->bModified = true; // we have to remove this node from the user layer!
1209 1 : pDataSettings->xSettings.clear();
1210 1 : m_bModified = true; // user layer must be written
1211 :
1212 : // Modify type container
1213 1 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1214 1 : rElementType.bModified = true;
1215 :
1216 2 : Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1217 :
1218 : // Check if we have settings in the default layer which replaces the user-defined one!
1219 1 : UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1220 1 : if ( pDefaultDataSettings )
1221 : {
1222 : // Create event to notify listener about replaced element settings
1223 0 : ConfigurationEvent aEvent;
1224 :
1225 0 : aEvent.ResourceURL = ResourceURL;
1226 0 : aEvent.Accessor <<= xThis;
1227 0 : aEvent.Source = xThis;
1228 0 : aEvent.Element <<= xRemovedSettings;
1229 0 : aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings;
1230 :
1231 0 : aGuard.unlock();
1232 :
1233 0 : implts_notifyContainerListener( aEvent, NotifyOp_Replace );
1234 : }
1235 : else
1236 : {
1237 : // Create event to notify listener about removed element settings
1238 1 : ConfigurationEvent aEvent;
1239 :
1240 1 : aEvent.ResourceURL = ResourceURL;
1241 1 : aEvent.Accessor <<= xThis;
1242 1 : aEvent.Source = xThis;
1243 1 : aEvent.Element <<= xRemovedSettings;
1244 :
1245 1 : aGuard.unlock();
1246 :
1247 1 : implts_notifyContainerListener( aEvent, NotifyOp_Remove );
1248 1 : }
1249 : }
1250 : }
1251 : else
1252 0 : throw NoSuchElementException();
1253 : }
1254 : }
1255 :
1256 1 : void SAL_CALL ModuleUIConfigurationManager::insertSettings( const OUString& NewResourceURL, const Reference< XIndexAccess >& aNewData )
1257 : throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, RuntimeException )
1258 : {
1259 1 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( NewResourceURL );
1260 :
1261 1 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1262 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1263 0 : throw IllegalArgumentException();
1264 1 : else if ( m_bReadOnly )
1265 0 : throw IllegalAccessException();
1266 : else
1267 : {
1268 1 : ResetableGuard aGuard( m_aLock );
1269 :
1270 1 : if ( m_bDisposed )
1271 0 : throw DisposedException();
1272 :
1273 1 : UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType );
1274 1 : if ( !pDataSettings )
1275 : {
1276 1 : UIElementData aUIElementData;
1277 :
1278 1 : aUIElementData.bDefault = false;
1279 1 : aUIElementData.bDefaultNode = false;
1280 1 : aUIElementData.bModified = true;
1281 :
1282 : // Create a copy of the data if the container is not const
1283 2 : Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
1284 1 : if ( xReplace.is() )
1285 1 : aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
1286 : else
1287 0 : aUIElementData.xSettings = aNewData;
1288 1 : aUIElementData.aName = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
1289 1 : aUIElementData.aResourceURL = NewResourceURL;
1290 1 : m_bModified = true;
1291 :
1292 1 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1293 1 : rElementType.bModified = true;
1294 :
1295 1 : UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
1296 1 : rElements.insert( UIElementDataHashMap::value_type( NewResourceURL, aUIElementData ));
1297 :
1298 2 : Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
1299 2 : Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1300 :
1301 : // Create event to notify listener about removed element settings
1302 2 : ConfigurationEvent aEvent;
1303 :
1304 1 : aEvent.ResourceURL = NewResourceURL;
1305 1 : aEvent.Accessor <<= xThis;
1306 1 : aEvent.Source = xThis;
1307 1 : aEvent.Element <<= xInsertSettings;
1308 :
1309 1 : aGuard.unlock();
1310 :
1311 2 : implts_notifyContainerListener( aEvent, NotifyOp_Insert );
1312 : }
1313 : else
1314 0 : throw ElementExistException();
1315 : }
1316 1 : }
1317 :
1318 25303 : Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager() throw (::com::sun::star::uno::RuntimeException)
1319 : {
1320 25303 : ResetableGuard aGuard( m_aLock );
1321 :
1322 25303 : if ( m_bDisposed )
1323 0 : throw DisposedException();
1324 :
1325 25303 : if ( !m_xModuleImageManager.is() )
1326 : {
1327 148 : m_xModuleImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ModuleImageManager( m_xContext )),
1328 74 : UNO_QUERY );
1329 74 : Reference< XInitialization > xInit( m_xModuleImageManager, UNO_QUERY );
1330 :
1331 148 : Sequence< Any > aPropSeq( 3 );
1332 148 : PropertyValue aPropValue;
1333 74 : aPropValue.Name = OUString( "UserConfigStorage" );
1334 74 : aPropValue.Value = makeAny( m_xUserConfigStorage );
1335 74 : aPropSeq[0] = makeAny( aPropValue );
1336 74 : aPropValue.Name = OUString( "ModuleIdentifier" );
1337 74 : aPropValue.Value = makeAny( m_aModuleIdentifier );
1338 74 : aPropSeq[1] = makeAny( aPropValue );
1339 74 : aPropValue.Name = OUString( "UserRootCommit" );
1340 74 : aPropValue.Value = makeAny( m_xUserRootCommit );
1341 74 : aPropSeq[2] = makeAny( aPropValue );
1342 :
1343 148 : xInit->initialize( aPropSeq );
1344 : }
1345 :
1346 25303 : return Reference< XInterface >( m_xModuleImageManager, UNO_QUERY );
1347 : }
1348 :
1349 1383 : Reference< XAcceleratorConfiguration > SAL_CALL ModuleUIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException)
1350 : {
1351 1383 : ResetableGuard aGuard( m_aLock );
1352 :
1353 1383 : if ( m_bDisposed )
1354 0 : throw DisposedException();
1355 :
1356 2766 : Reference< XComponentContext > xContext = m_xContext;
1357 2766 : OUString aModule = m_aModuleIdentifier;
1358 :
1359 1383 : if ( !m_xModuleAcceleratorManager.is() )
1360 : {
1361 46 : Reference< XAcceleratorConfiguration > xManager = ModuleAcceleratorConfiguration::createWithModuleIdentifier(xContext, aModule);
1362 46 : m_xModuleAcceleratorManager = xManager;
1363 : }
1364 :
1365 2766 : return m_xModuleAcceleratorManager;
1366 : }
1367 :
1368 1 : Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException)
1369 : {
1370 1 : return Reference< XInterface >();
1371 : }
1372 :
1373 : // XModuleUIConfigurationManager
1374 2 : sal_Bool SAL_CALL ModuleUIConfigurationManager::isDefaultSettings( const OUString& ResourceURL )
1375 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1376 : {
1377 2 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1378 :
1379 2 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1380 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1381 0 : throw IllegalArgumentException();
1382 : else
1383 : {
1384 2 : ResetableGuard aGuard( m_aLock );
1385 :
1386 2 : if ( m_bDisposed )
1387 0 : throw DisposedException();
1388 :
1389 2 : UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
1390 2 : if ( pDataSettings && pDataSettings->bDefaultNode )
1391 1 : return sal_True;
1392 : }
1393 :
1394 1 : return sal_False;
1395 : }
1396 :
1397 1 : Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getDefaultSettings( const OUString& ResourceURL )
1398 : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1399 : {
1400 1 : sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1401 :
1402 1 : if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1403 : ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
1404 0 : throw IllegalArgumentException();
1405 : else
1406 : {
1407 1 : ResetableGuard aGuard( m_aLock );
1408 :
1409 1 : if ( m_bDisposed )
1410 0 : throw DisposedException();
1411 :
1412 : // preload list of element types on demand
1413 1 : impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
1414 :
1415 : // Look into our default vector/boost::unordered_map combination
1416 1 : UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
1417 1 : UIElementDataHashMap::iterator pIter = rDefaultHashMap.find( ResourceURL );
1418 1 : if ( pIter != rDefaultHashMap.end() )
1419 : {
1420 1 : if ( !pIter->second.xSettings.is() )
1421 0 : impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second );
1422 2 : return pIter->second.xSettings;
1423 0 : }
1424 : }
1425 :
1426 : // Nothing has been found!
1427 0 : throw NoSuchElementException();
1428 : }
1429 :
1430 : // XUIConfigurationPersistence
1431 1 : void SAL_CALL ModuleUIConfigurationManager::reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1432 : {
1433 1 : ResetableGuard aGuard( m_aLock );
1434 :
1435 1 : if ( m_bDisposed )
1436 0 : throw DisposedException();
1437 :
1438 1 : if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
1439 : {
1440 : // Try to access our module sub folder
1441 0 : ConfigEventNotifyContainer aRemoveNotifyContainer;
1442 0 : ConfigEventNotifyContainer aReplaceNotifyContainer;
1443 0 : for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1444 : {
1445 : try
1446 : {
1447 0 : UIElementType& rUserElementType = m_aUIElements[LAYER_USERDEFINED][i];
1448 0 : UIElementType& rDefaultElementType = m_aUIElements[LAYER_DEFAULT][i];
1449 :
1450 0 : if ( rUserElementType.bModified )
1451 0 : impl_reloadElementTypeData( rUserElementType, rDefaultElementType, aRemoveNotifyContainer, aReplaceNotifyContainer );
1452 : }
1453 0 : catch ( const Exception& )
1454 : {
1455 0 : throw IOException();
1456 : }
1457 : }
1458 :
1459 0 : m_bModified = sal_False;
1460 :
1461 : // Unlock mutex before notify our listeners
1462 0 : aGuard.unlock();
1463 :
1464 : // Notify our listeners
1465 0 : for ( sal_uInt32 j = 0; j < aRemoveNotifyContainer.size(); j++ )
1466 0 : implts_notifyContainerListener( aRemoveNotifyContainer[j], NotifyOp_Remove );
1467 0 : for ( sal_uInt32 k = 0; k < aReplaceNotifyContainer.size(); k++ )
1468 0 : implts_notifyContainerListener( aReplaceNotifyContainer[k], NotifyOp_Replace );
1469 1 : }
1470 1 : }
1471 :
1472 1 : void SAL_CALL ModuleUIConfigurationManager::store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1473 : {
1474 1 : ResetableGuard aGuard( m_aLock );
1475 :
1476 1 : if ( m_bDisposed )
1477 0 : throw DisposedException();
1478 :
1479 1 : if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
1480 : {
1481 : // Try to access our module sub folder
1482 0 : for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1483 : {
1484 : try
1485 : {
1486 0 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i];
1487 0 : Reference< XStorage > xStorage( rElementType.xStorage, UNO_QUERY );
1488 :
1489 0 : if ( rElementType.bModified && xStorage.is() )
1490 : {
1491 0 : impl_storeElementTypeData( xStorage, rElementType );
1492 0 : m_pStorageHandler[i]->commitUserChanges();
1493 0 : }
1494 : }
1495 0 : catch ( const Exception& )
1496 : {
1497 0 : throw IOException();
1498 : }
1499 : }
1500 :
1501 0 : m_bModified = false;
1502 1 : }
1503 1 : }
1504 :
1505 1 : void SAL_CALL ModuleUIConfigurationManager::storeToStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1506 : {
1507 1 : ResetableGuard aGuard( m_aLock );
1508 :
1509 1 : if ( m_bDisposed )
1510 0 : throw DisposedException();
1511 :
1512 1 : if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
1513 : {
1514 : // Try to access our module sub folder
1515 0 : for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1516 : {
1517 : try
1518 : {
1519 0 : Reference< XStorage > xElementTypeStorage( Storage->openStorageElement(
1520 0 : OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE ));
1521 0 : UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][i];
1522 :
1523 0 : if ( rElementType.bModified && xElementTypeStorage.is() )
1524 0 : impl_storeElementTypeData( xElementTypeStorage, rElementType, false ); // store data to storage, but don't reset modify flag!
1525 : }
1526 0 : catch ( const Exception& )
1527 : {
1528 0 : throw IOException();
1529 : }
1530 : }
1531 :
1532 0 : Reference< XTransactedObject > xTransactedObject( Storage, UNO_QUERY );
1533 0 : if ( xTransactedObject.is() )
1534 0 : xTransactedObject->commit();
1535 1 : }
1536 1 : }
1537 :
1538 1 : sal_Bool SAL_CALL ModuleUIConfigurationManager::isModified() throw (::com::sun::star::uno::RuntimeException)
1539 : {
1540 1 : ResetableGuard aGuard( m_aLock );
1541 :
1542 1 : return m_bModified;
1543 : }
1544 :
1545 4 : sal_Bool SAL_CALL ModuleUIConfigurationManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
1546 : {
1547 4 : ResetableGuard aGuard( m_aLock );
1548 :
1549 4 : return m_bReadOnly;
1550 : }
1551 :
1552 8 : void ModuleUIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
1553 : {
1554 8 : ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) );
1555 8 : if ( pContainer != NULL )
1556 : {
1557 8 : ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
1558 26 : while ( pIterator.hasMoreElements() )
1559 : {
1560 : try
1561 : {
1562 10 : switch ( eOp )
1563 : {
1564 : case NotifyOp_Replace:
1565 8 : ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent );
1566 8 : break;
1567 : case NotifyOp_Insert:
1568 1 : ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent );
1569 1 : break;
1570 : case NotifyOp_Remove:
1571 1 : ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent );
1572 1 : break;
1573 : }
1574 : }
1575 0 : catch( const css::uno::RuntimeException& )
1576 : {
1577 0 : pIterator.remove();
1578 : }
1579 8 : }
1580 : }
1581 8 : }
1582 :
1583 402 : } // namespace framework
1584 :
1585 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|