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