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 31 //_________________________________________________________________________________________________________________ 32 // my own includes 33 //_________________________________________________________________________________________________________________ 34 #include <helper/uiconfigelementwrapperbase.hxx> 35 #include <general.h> 36 #include <properties.h> 37 #include <threadhelp/resetableguard.hxx> 38 #include <uielement/constitemcontainer.hxx> 39 #include <uielement/rootitemcontainer.hxx> 40 41 //_________________________________________________________________________________________________________________ 42 // interface includes 43 //_________________________________________________________________________________________________________________ 44 #include <com/sun/star/beans/PropertyAttribute.hpp> 45 #include <com/sun/star/beans/PropertyValue.hpp> 46 #include <com/sun/star/beans/XPropertySet.hpp> 47 #include <com/sun/star/ui/XUIConfiguration.hpp> 48 49 //_________________________________________________________________________________________________________________ 50 // includes of other projects 51 //_________________________________________________________________________________________________________________ 52 #include <vcl/svapp.hxx> 53 #include <rtl/logfile.hxx> 54 55 const int UIELEMENT_PROPHANDLE_CONFIGSOURCE = 1; 56 const int UIELEMENT_PROPHANDLE_FRAME = 2; 57 const int UIELEMENT_PROPHANDLE_PERSISTENT = 3; 58 const int UIELEMENT_PROPHANDLE_RESOURCEURL = 4; 59 const int UIELEMENT_PROPHANDLE_TYPE = 5; 60 const int UIELEMENT_PROPHANDLE_XMENUBAR = 6; 61 const int UIELEMENT_PROPHANDLE_CONFIGLISTENER = 7; 62 const int UIELEMENT_PROPHANDLE_NOCLOSE = 8; 63 const int UIELEMENT_PROPCOUNT = 8; 64 const rtl::OUString UIELEMENT_PROPNAME_CONFIGLISTENER( RTL_CONSTASCII_USTRINGPARAM( "ConfigListener" )); 65 const rtl::OUString UIELEMENT_PROPNAME_CONFIGSOURCE( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" )); 66 const rtl::OUString UIELEMENT_PROPNAME_FRAME( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 67 const rtl::OUString UIELEMENT_PROPNAME_PERSISTENT( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); 68 const rtl::OUString UIELEMENT_PROPNAME_RESOURCEURL( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" )); 69 const rtl::OUString UIELEMENT_PROPNAME_TYPE( RTL_CONSTASCII_USTRINGPARAM( "Type" )); 70 const rtl::OUString UIELEMENT_PROPNAME_XMENUBAR( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" )); 71 const rtl::OUString UIELEMENT_PROPNAME_NOCLOSE( RTL_CONSTASCII_USTRINGPARAM( "NoClose" )); 72 73 //using namespace rtl; 74 using namespace com::sun::star::beans; 75 using namespace com::sun::star::uno; 76 using namespace com::sun::star::frame; 77 using namespace com::sun::star::lang; 78 using namespace com::sun::star::container; 79 using namespace ::com::sun::star::ui; 80 81 namespace framework 82 { 83 84 //***************************************************************************************************************** 85 // XInterface, XTypeProvider 86 //***************************************************************************************************************** 87 DEFINE_XINTERFACE_10 ( UIConfigElementWrapperBase , 88 OWeakObject , 89 DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider ), 90 DIRECT_INTERFACE( ::com::sun::star::ui::XUIElement ), 91 DIRECT_INTERFACE( ::com::sun::star::ui::XUIElementSettings ), 92 DIRECT_INTERFACE( ::com::sun::star::beans::XMultiPropertySet ), 93 DIRECT_INTERFACE( ::com::sun::star::beans::XFastPropertySet ), 94 DIRECT_INTERFACE( ::com::sun::star::beans::XPropertySet ), 95 DIRECT_INTERFACE( ::com::sun::star::lang::XInitialization ), 96 DIRECT_INTERFACE( ::com::sun::star::lang::XComponent ), 97 DIRECT_INTERFACE( ::com::sun::star::util::XUpdatable ), 98 DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationListener ) 99 ) 100 101 DEFINE_XTYPEPROVIDER_10 ( UIConfigElementWrapperBase , 102 ::com::sun::star::lang::XTypeProvider , 103 ::com::sun::star::ui::XUIElement , 104 ::com::sun::star::ui::XUIElementSettings , 105 ::com::sun::star::beans::XMultiPropertySet , 106 ::com::sun::star::beans::XFastPropertySet , 107 ::com::sun::star::beans::XPropertySet , 108 ::com::sun::star::lang::XInitialization , 109 ::com::sun::star::lang::XComponent , 110 ::com::sun::star::util::XUpdatable , 111 ::com::sun::star::ui::XUIConfigurationListener 112 ) 113 114 UIConfigElementWrapperBase::UIConfigElementWrapperBase( sal_Int16 nType,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory ) 115 : ThreadHelpBase ( &Application::GetSolarMutex() ) 116 , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() ) 117 , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) 118 , ::cppu::OWeakObject ( ) 119 , m_nType ( nType ) 120 , m_bPersistent ( sal_True ) 121 , m_bInitialized ( sal_False ) 122 , m_bConfigListener ( sal_False ) 123 , m_bConfigListening ( sal_False ) 124 , m_bDisposed ( sal_False ) 125 , m_bNoClose ( sal_False ) 126 , m_xServiceFactory ( _xServiceFactory ) 127 , m_aListenerContainer ( m_aLock.getShareableOslMutex() ) 128 { 129 } 130 131 UIConfigElementWrapperBase::~UIConfigElementWrapperBase() 132 { 133 } 134 135 // XComponent 136 void SAL_CALL UIConfigElementWrapperBase::dispose() throw (::com::sun::star::uno::RuntimeException) 137 { 138 // must be implemented by derived class 139 ResetableGuard aLock( m_aLock ); 140 m_bDisposed = sal_True; 141 } 142 143 void SAL_CALL UIConfigElementWrapperBase::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 144 { 145 m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener ); 146 } 147 148 void SAL_CALL UIConfigElementWrapperBase::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException) 149 { 150 m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), aListener ); 151 } 152 153 // XEventListener 154 void SAL_CALL UIConfigElementWrapperBase::disposing( const EventObject& ) 155 throw( RuntimeException ) 156 { 157 ResetableGuard aLock( m_aLock ); 158 m_xConfigSource.clear(); 159 } 160 161 void SAL_CALL UIConfigElementWrapperBase::initialize( const Sequence< Any >& aArguments ) 162 throw ( Exception, RuntimeException ) 163 { 164 ResetableGuard aLock( m_aLock ); 165 166 if ( !m_bInitialized ) 167 { 168 for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ ) 169 { 170 PropertyValue aPropValue; 171 if ( aArguments[n] >>= aPropValue ) 172 { 173 if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_CONFIGSOURCE )) 174 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_CONFIGSOURCE, aPropValue.Value ); 175 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_FRAME )) 176 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_FRAME, aPropValue.Value ); 177 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_PERSISTENT )) 178 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_PERSISTENT, aPropValue.Value ); 179 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_RESOURCEURL )) 180 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_RESOURCEURL, aPropValue.Value ); 181 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_TYPE )) 182 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_TYPE, aPropValue.Value ); 183 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_CONFIGLISTENER )) 184 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_CONFIGLISTENER, aPropValue.Value ); 185 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_NOCLOSE )) 186 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_NOCLOSE, aPropValue.Value ); 187 } 188 } 189 190 m_bInitialized = sal_True; 191 } 192 } 193 194 // XUpdatable 195 void SAL_CALL UIConfigElementWrapperBase::update() throw (::com::sun::star::uno::RuntimeException) 196 { 197 // can be implemented by derived class 198 } 199 200 void SAL_CALL UIConfigElementWrapperBase::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException) 201 { 202 // can be implemented by derived class 203 } 204 205 void SAL_CALL UIConfigElementWrapperBase::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException) 206 { 207 // can be implemented by derived class 208 } 209 210 void SAL_CALL UIConfigElementWrapperBase::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException) 211 { 212 // can be implemented by derived class 213 } 214 215 // XPropertySet helper 216 sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any& aConvertedValue , 217 Any& aOldValue , 218 sal_Int32 nHandle , 219 const Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException ) 220 { 221 // Initialize state with sal_False !!! 222 // (Handle can be invalid) 223 sal_Bool bReturn = sal_False; 224 225 switch( nHandle ) 226 { 227 case UIELEMENT_PROPHANDLE_CONFIGLISTENER: 228 bReturn = PropHelper::willPropertyBeChanged( 229 com::sun::star::uno::makeAny(m_bConfigListener), 230 aValue, 231 aOldValue, 232 aConvertedValue); 233 break; 234 235 case UIELEMENT_PROPHANDLE_CONFIGSOURCE: 236 bReturn = PropHelper::willPropertyBeChanged( 237 com::sun::star::uno::makeAny(m_xConfigSource), 238 aValue, 239 aOldValue, 240 aConvertedValue); 241 break; 242 243 case UIELEMENT_PROPHANDLE_FRAME: 244 { 245 Reference< XFrame > xFrame( m_xWeakFrame ); 246 bReturn = PropHelper::willPropertyBeChanged( 247 com::sun::star::uno::makeAny(xFrame), 248 aValue, 249 aOldValue, 250 aConvertedValue); 251 } 252 break; 253 254 case UIELEMENT_PROPHANDLE_PERSISTENT: 255 bReturn = PropHelper::willPropertyBeChanged( 256 com::sun::star::uno::makeAny(m_bPersistent), 257 aValue, 258 aOldValue, 259 aConvertedValue); 260 break; 261 262 case UIELEMENT_PROPHANDLE_RESOURCEURL: 263 bReturn = PropHelper::willPropertyBeChanged( 264 com::sun::star::uno::makeAny(m_aResourceURL), 265 aValue, 266 aOldValue, 267 aConvertedValue); 268 break; 269 270 case UIELEMENT_PROPHANDLE_TYPE : 271 bReturn = PropHelper::willPropertyBeChanged( 272 com::sun::star::uno::makeAny(m_nType), 273 aValue, 274 aOldValue, 275 aConvertedValue); 276 break; 277 278 case UIELEMENT_PROPHANDLE_XMENUBAR : 279 bReturn = PropHelper::willPropertyBeChanged( 280 com::sun::star::uno::makeAny(m_xMenuBar), 281 aValue, 282 aOldValue, 283 aConvertedValue); 284 break; 285 286 case UIELEMENT_PROPHANDLE_NOCLOSE: 287 bReturn = PropHelper::willPropertyBeChanged( 288 com::sun::star::uno::makeAny(m_bNoClose), 289 aValue, 290 aOldValue, 291 aConvertedValue); 292 break; 293 } 294 295 // Return state of operation. 296 return bReturn ; 297 } 298 299 void SAL_CALL UIConfigElementWrapperBase::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , 300 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception ) 301 { 302 switch( nHandle ) 303 { 304 case UIELEMENT_PROPHANDLE_CONFIGLISTENER: 305 { 306 bool bBool( m_bConfigListener ); 307 aValue >>= bBool; 308 if ( m_bConfigListener != bBool ) 309 { 310 if ( m_bConfigListening ) 311 { 312 if ( m_xConfigSource.is() && !bBool ) 313 { 314 try 315 { 316 Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY ); 317 if ( xUIConfig.is() ) 318 { 319 xUIConfig->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 320 m_bConfigListening = sal_False; 321 } 322 } 323 catch ( Exception& ) 324 { 325 } 326 } 327 } 328 else 329 { 330 if ( m_xConfigSource.is() && bBool ) 331 { 332 try 333 { 334 Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY ); 335 if ( xUIConfig.is() ) 336 { 337 xUIConfig->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 338 m_bConfigListening = sal_True; 339 } 340 } 341 catch ( Exception& ) 342 { 343 } 344 } 345 } 346 347 m_bConfigListener = bBool; 348 } 349 } 350 break; 351 case UIELEMENT_PROPHANDLE_CONFIGSOURCE: 352 aValue >>= m_xConfigSource; 353 break; 354 case UIELEMENT_PROPHANDLE_FRAME: 355 { 356 Reference< XFrame > xFrame; 357 358 aValue >>= xFrame; 359 m_xWeakFrame = xFrame; 360 break; 361 } 362 case UIELEMENT_PROPHANDLE_PERSISTENT: 363 { 364 sal_Bool bBool( m_bPersistent ); 365 aValue >>= bBool; 366 m_bPersistent = bBool; 367 break; 368 } 369 case UIELEMENT_PROPHANDLE_RESOURCEURL: 370 aValue >>= m_aResourceURL; 371 break; 372 case UIELEMENT_PROPHANDLE_TYPE: 373 aValue >>= m_nType; 374 break; 375 case UIELEMENT_PROPHANDLE_XMENUBAR: 376 aValue >>= m_xMenuBar; 377 break; 378 case UIELEMENT_PROPHANDLE_NOCLOSE: 379 { 380 sal_Bool bBool( m_bNoClose ); 381 aValue >>= bBool; 382 m_bNoClose = bBool; 383 break; 384 } 385 } 386 } 387 388 void SAL_CALL UIConfigElementWrapperBase::getFastPropertyValue( com::sun::star::uno::Any& aValue , 389 sal_Int32 nHandle ) const 390 { 391 switch( nHandle ) 392 { 393 case UIELEMENT_PROPHANDLE_CONFIGLISTENER: 394 aValue <<= m_bConfigListener; 395 break; 396 case UIELEMENT_PROPHANDLE_CONFIGSOURCE: 397 aValue <<= m_xConfigSource; 398 break; 399 case UIELEMENT_PROPHANDLE_FRAME: 400 { 401 Reference< XFrame > xFrame( m_xWeakFrame ); 402 aValue <<= xFrame; 403 break; 404 } 405 case UIELEMENT_PROPHANDLE_PERSISTENT: 406 aValue <<= m_bPersistent; 407 break; 408 case UIELEMENT_PROPHANDLE_RESOURCEURL: 409 aValue <<= m_aResourceURL; 410 break; 411 case UIELEMENT_PROPHANDLE_TYPE: 412 aValue <<= m_nType; 413 break; 414 case UIELEMENT_PROPHANDLE_XMENUBAR: 415 aValue <<= m_xMenuBar; 416 break; 417 case UIELEMENT_PROPHANDLE_NOCLOSE: 418 aValue <<= m_bNoClose; 419 break; 420 } 421 } 422 423 ::cppu::IPropertyArrayHelper& SAL_CALL UIConfigElementWrapperBase::getInfoHelper() 424 { 425 // Optimize this method ! 426 // We initialize a static variable only one time. And we don't must use a mutex at every call! 427 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL! 428 static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL; 429 430 if( pInfoHelper == NULL ) 431 { 432 // Ready for multithreading 433 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 434 435 // Control this pointer again, another instance can be faster then these! 436 if( pInfoHelper == NULL ) 437 { 438 // Define static member to give structure of properties to baseclass "OPropertySetHelper". 439 // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable. 440 // "sal_True" say: Table is sorted by name. 441 static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True ); 442 pInfoHelper = &aInfoHelper; 443 } 444 } 445 446 return(*pInfoHelper); 447 } 448 449 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL UIConfigElementWrapperBase::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException) 450 { 451 // Optimize this method ! 452 // We initialize a static variable only one time. And we don't must use a mutex at every call! 453 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL! 454 static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >* pInfo = NULL; 455 456 if( pInfo == NULL ) 457 { 458 // Ready for multithreading 459 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 460 // Control this pointer again, another instance can be faster then these! 461 if( pInfo == NULL ) 462 { 463 // Create structure of propertysetinfo for baseclass "OPropertySetHelper". 464 // (Use method "getInfoHelper()".) 465 static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 466 pInfo = &xInfo; 467 } 468 } 469 470 return (*pInfo); 471 } 472 473 const com::sun::star::uno::Sequence< com::sun::star::beans::Property > UIConfigElementWrapperBase::impl_getStaticPropertyDescriptor() 474 { 475 // Create a new static property array to initialize sequence! 476 // Table of all predefined properties of this class. Its used from OPropertySetHelper-class! 477 // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!! 478 // It's necessary for methods of OPropertySetHelper. 479 // ATTENTION: 480 // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!! 481 482 static const com::sun::star::beans::Property pProperties[] = 483 { 484 com::sun::star::beans::Property( UIELEMENT_PROPNAME_CONFIGLISTENER, UIELEMENT_PROPHANDLE_CONFIGLISTENER , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), 485 com::sun::star::beans::Property( UIELEMENT_PROPNAME_CONFIGSOURCE , UIELEMENT_PROPHANDLE_CONFIGSOURCE , ::getCppuType((const Reference< ::com::sun::star::ui::XUIConfigurationManager >*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), 486 com::sun::star::beans::Property( UIELEMENT_PROPNAME_FRAME , UIELEMENT_PROPHANDLE_FRAME , ::getCppuType((const Reference< com::sun::star::frame::XFrame >*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ), 487 com::sun::star::beans::Property( UIELEMENT_PROPNAME_NOCLOSE , UIELEMENT_PROPHANDLE_NOCLOSE , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), 488 com::sun::star::beans::Property( UIELEMENT_PROPNAME_PERSISTENT , UIELEMENT_PROPHANDLE_PERSISTENT , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ), 489 com::sun::star::beans::Property( UIELEMENT_PROPNAME_RESOURCEURL , UIELEMENT_PROPHANDLE_RESOURCEURL , ::getCppuType((const ::rtl::OUString*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ), 490 com::sun::star::beans::Property( UIELEMENT_PROPNAME_TYPE , UIELEMENT_PROPHANDLE_TYPE , ::getCppuType((const ::rtl::OUString*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ), 491 com::sun::star::beans::Property( UIELEMENT_PROPNAME_XMENUBAR , UIELEMENT_PROPHANDLE_XMENUBAR , ::getCppuType((const Reference< com::sun::star::awt::XMenuBar >*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ) 492 }; 493 // Use it to initialize sequence! 494 static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, UIELEMENT_PROPCOUNT ); 495 // Return static "PropertyDescriptor" 496 return lPropertyDescriptor; 497 } 498 void SAL_CALL UIConfigElementWrapperBase::setSettings( const Reference< XIndexAccess >& xSettings ) throw ( RuntimeException ) 499 { 500 ResetableGuard aLock( m_aLock ); 501 502 //if ( m_bDisposed ) 503 // throw DisposedException(); 504 505 if ( xSettings.is() ) 506 { 507 // Create a copy of the data if the container is not const 508 Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY ); 509 if ( xReplace.is() ) 510 m_xConfigData = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY ); 511 else 512 m_xConfigData = xSettings; 513 514 if ( m_xConfigSource.is() && m_bPersistent ) 515 { 516 ::rtl::OUString aResourceURL( m_aResourceURL ); 517 Reference< XUIConfigurationManager > xUICfgMgr( m_xConfigSource ); 518 519 aLock.unlock(); 520 521 try 522 { 523 xUICfgMgr->replaceSettings( aResourceURL, m_xConfigData ); 524 } 525 catch( NoSuchElementException& ) 526 { 527 } 528 } 529 else if ( !m_bPersistent ) 530 { 531 // Transient menubar => Fill menubar with new data 532 impl_fillNewData(); 533 } 534 } 535 } 536 void UIConfigElementWrapperBase::impl_fillNewData() 537 { 538 } 539 Reference< XIndexAccess > SAL_CALL UIConfigElementWrapperBase::getSettings( sal_Bool bWriteable ) throw ( RuntimeException ) 540 { 541 ResetableGuard aLock( m_aLock ); 542 543 //if ( m_bDisposed ) 544 // throw DisposedException(); 545 546 if ( bWriteable ) 547 return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY ); 548 549 return m_xConfigData; 550 } 551 552 Reference< XFrame > SAL_CALL UIConfigElementWrapperBase::getFrame() throw (RuntimeException) 553 { 554 ResetableGuard aLock( m_aLock ); 555 Reference< XFrame > xFrame( m_xWeakFrame ); 556 return xFrame; 557 } 558 559 ::rtl::OUString SAL_CALL UIConfigElementWrapperBase::getResourceURL() throw (RuntimeException) 560 { 561 ResetableGuard aLock( m_aLock ); 562 return m_aResourceURL; 563 } 564 565 ::sal_Int16 SAL_CALL UIConfigElementWrapperBase::getType() throw (RuntimeException) 566 { 567 ResetableGuard aLock( m_aLock ); 568 return m_nType; 569 } 570 571 } 572