1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "precompiled_embeddedobj.hxx" 25 #include <com/sun/star/embed/EmbedStates.hpp> 26 #include <com/sun/star/embed/EmbedVerbs.hpp> 27 #include <com/sun/star/embed/EmbedUpdateModes.hpp> 28 #include <com/sun/star/embed/XEmbeddedClient.hpp> 29 #include <com/sun/star/embed/XInplaceClient.hpp> 30 #include <com/sun/star/embed/XWindowSupplier.hpp> 31 #include <com/sun/star/embed/StateChangeInProgressException.hpp> 32 #include <com/sun/star/embed/EmbedStates.hpp> 33 #include <com/sun/star/embed/Aspects.hpp> 34 #include <com/sun/star/embed/EmbedMapUnits.hpp> 35 #include <com/sun/star/embed/EntryInitModes.hpp> 36 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 37 #include <com/sun/star/lang/DisposedException.hpp> 38 39 #include <cppuhelper/interfacecontainer.h> 40 41 #include <dummyobject.hxx> 42 43 44 using namespace ::com::sun::star; 45 46 //---------------------------------------------- 47 void ODummyEmbeddedObject::CheckInit() 48 { 49 if ( m_bDisposed ) 50 throw lang::DisposedException(); 51 52 if ( m_nObjectState == -1 ) 53 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 54 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 55 } 56 57 //---------------------------------------------- 58 void ODummyEmbeddedObject::PostEvent_Impl( const ::rtl::OUString& aEventName, 59 const uno::Reference< uno::XInterface >& /*xSource*/ ) 60 { 61 if ( m_pInterfaceContainer ) 62 { 63 ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer( 64 ::getCppuType((const uno::Reference< document::XEventListener >*)0) ); 65 if( pIC ) 66 { 67 document::EventObject aEvent; 68 aEvent.EventName = aEventName; 69 aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ); 70 // For now all the events are sent as object events 71 // aEvent.Source = ( xSource.is() ? xSource 72 // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); 73 ::cppu::OInterfaceIteratorHelper aIt( *pIC ); 74 while( aIt.hasMoreElements() ) 75 { 76 try 77 { 78 ((document::XEventListener *)aIt.next())->notifyEvent( aEvent ); 79 } 80 catch( uno::RuntimeException& ) 81 { 82 aIt.remove(); 83 } 84 85 // the listener could dispose the object. 86 if ( m_bDisposed ) 87 return; 88 } 89 } 90 } 91 } 92 93 //---------------------------------------------- 94 ODummyEmbeddedObject::~ODummyEmbeddedObject() 95 { 96 } 97 98 //---------------------------------------------- 99 void SAL_CALL ODummyEmbeddedObject::changeState( sal_Int32 nNewState ) 100 { 101 ::osl::MutexGuard aGuard( m_aMutex ); 102 CheckInit(); 103 104 if ( nNewState == embed::EmbedStates::LOADED ) 105 return; 106 107 throw embed::UnreachableStateException(); 108 } 109 110 //---------------------------------------------- 111 uno::Sequence< sal_Int32 > SAL_CALL ODummyEmbeddedObject::getReachableStates() 112 { 113 ::osl::MutexGuard aGuard( m_aMutex ); 114 CheckInit(); 115 116 uno::Sequence< sal_Int32 > aResult( 1 ); 117 aResult[0] = embed::EmbedStates::LOADED; 118 119 return aResult; 120 } 121 122 //---------------------------------------------- 123 sal_Int32 SAL_CALL ODummyEmbeddedObject::getCurrentState() 124 { 125 ::osl::MutexGuard aGuard( m_aMutex ); 126 CheckInit(); 127 128 return m_nObjectState; 129 } 130 131 //---------------------------------------------- 132 void SAL_CALL ODummyEmbeddedObject::doVerb( sal_Int32 ) 133 { 134 ::osl::MutexGuard aGuard( m_aMutex ); 135 CheckInit(); 136 137 // no supported verbs 138 } 139 140 //---------------------------------------------- 141 uno::Sequence< embed::VerbDescriptor > SAL_CALL ODummyEmbeddedObject::getSupportedVerbs() 142 { 143 ::osl::MutexGuard aGuard( m_aMutex ); 144 CheckInit(); 145 146 return uno::Sequence< embed::VerbDescriptor >(); 147 } 148 149 //---------------------------------------------- 150 void SAL_CALL ODummyEmbeddedObject::setClientSite( 151 const uno::Reference< embed::XEmbeddedClient >& xClient ) 152 { 153 ::osl::MutexGuard aGuard( m_aMutex ); 154 CheckInit(); 155 156 m_xClientSite = xClient; 157 } 158 159 //---------------------------------------------- 160 uno::Reference< embed::XEmbeddedClient > SAL_CALL ODummyEmbeddedObject::getClientSite() 161 { 162 ::osl::MutexGuard aGuard( m_aMutex ); 163 CheckInit(); 164 165 return m_xClientSite; 166 } 167 168 //---------------------------------------------- 169 void SAL_CALL ODummyEmbeddedObject::update() 170 { 171 ::osl::MutexGuard aGuard( m_aMutex ); 172 CheckInit(); 173 } 174 175 //---------------------------------------------- 176 void SAL_CALL ODummyEmbeddedObject::setUpdateMode( sal_Int32 ) 177 { 178 ::osl::MutexGuard aGuard( m_aMutex ); 179 CheckInit(); 180 } 181 182 //---------------------------------------------- 183 sal_Int64 SAL_CALL ODummyEmbeddedObject::getStatus( sal_Int64 ) 184 { 185 ::osl::MutexGuard aGuard( m_aMutex ); 186 CheckInit(); 187 188 return 0; 189 } 190 191 //---------------------------------------------- 192 void SAL_CALL ODummyEmbeddedObject::setContainerName( const ::rtl::OUString& ) 193 { 194 ::osl::MutexGuard aGuard( m_aMutex ); 195 CheckInit(); 196 } 197 198 //---------------------------------------------- 199 void SAL_CALL ODummyEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize ) 200 { 201 ::osl::MutexGuard aGuard( m_aMutex ); 202 CheckInit(); 203 204 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" ); 205 if ( nAspect == embed::Aspects::MSOLE_ICON ) 206 // no representation can be retrieved 207 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), 208 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 209 210 m_nCachedAspect = nAspect; 211 m_aCachedSize = aSize; 212 m_bHasCachedSize = sal_True; 213 } 214 215 //---------------------------------------------- 216 awt::Size SAL_CALL ODummyEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) 217 { 218 ::osl::MutexGuard aGuard( m_aMutex ); 219 CheckInit(); 220 221 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" ); 222 if ( nAspect == embed::Aspects::MSOLE_ICON ) 223 // no representation can be retrieved 224 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), 225 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 226 227 if ( !m_bHasCachedSize || m_nCachedAspect != nAspect ) 228 throw embed::NoVisualAreaSizeException( 229 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No size available!\n" ) ), 230 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 231 232 return m_aCachedSize; 233 } 234 235 //---------------------------------------------- 236 sal_Int32 SAL_CALL ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect ) 237 { 238 ::osl::MutexGuard aGuard( m_aMutex ); 239 CheckInit(); 240 241 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" ); 242 if ( nAspect == embed::Aspects::MSOLE_ICON ) 243 // no representation can be retrieved 244 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), 245 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 246 247 return embed::EmbedMapUnits::ONE_100TH_MM; 248 } 249 250 //---------------------------------------------- 251 embed::VisualRepresentation SAL_CALL ODummyEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 ) 252 { 253 ::osl::MutexGuard aGuard( m_aMutex ); 254 CheckInit(); 255 256 // no representation can be retrieved 257 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), 258 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 259 } 260 261 //---------------------------------------------- 262 void SAL_CALL ODummyEmbeddedObject::setPersistentEntry( 263 const uno::Reference< embed::XStorage >& xStorage, 264 const ::rtl::OUString& sEntName, 265 sal_Int32 nEntryConnectionMode, 266 const uno::Sequence< beans::PropertyValue >& /* lArguments */, 267 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ ) 268 { 269 ::osl::MutexGuard aGuard( m_aMutex ); 270 if ( m_bDisposed ) 271 throw lang::DisposedException(); // TODO 272 273 if ( !xStorage.is() ) 274 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ), 275 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), 276 1 ); 277 278 if ( !sEntName.getLength() ) 279 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ), 280 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), 281 2 ); 282 283 if ( ( m_nObjectState != -1 || nEntryConnectionMode == embed::EntryInitModes::NO_INIT ) 284 && ( m_nObjectState == -1 || nEntryConnectionMode != embed::EntryInitModes::NO_INIT ) ) 285 { 286 throw embed::WrongStateException( 287 ::rtl::OUString::createFromAscii( "Can't change persistent representation of activated object!\n" ), 288 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 289 } 290 291 if ( m_bWaitSaveCompleted ) 292 { 293 if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT ) 294 saveCompleted( ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) ) ); 295 else 296 throw embed::WrongStateException( 297 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 298 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 299 } 300 301 if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT 302 || nEntryConnectionMode == embed::EntryInitModes::NO_INIT ) 303 { 304 if ( xStorage->hasByName( sEntName ) ) 305 306 { 307 m_xParentStorage = xStorage; 308 m_aEntryName = sEntName; 309 m_nObjectState = embed::EmbedStates::LOADED; 310 } 311 else 312 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Wrong entry is provided!\n" ), 313 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), 314 2 ); 315 316 } 317 else 318 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Wrong connection mode is provided!\n" ), 319 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), 320 3 ); 321 } 322 323 //------------------------------------------------------ 324 void SAL_CALL ODummyEmbeddedObject::storeToEntry( const uno::Reference< embed::XStorage >& xStorage, 325 const ::rtl::OUString& sEntName, 326 const uno::Sequence< beans::PropertyValue >& /* lArguments */, 327 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ ) 328 { 329 ::osl::MutexGuard aGuard( m_aMutex ); 330 CheckInit(); 331 332 if ( m_bWaitSaveCompleted ) 333 throw embed::WrongStateException( 334 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 335 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 336 337 m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName ); 338 } 339 340 //------------------------------------------------------ 341 void SAL_CALL ODummyEmbeddedObject::storeAsEntry( const uno::Reference< embed::XStorage >& xStorage, 342 const ::rtl::OUString& sEntName, 343 const uno::Sequence< beans::PropertyValue >& /* lArguments */, 344 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ ) 345 { 346 ::osl::MutexGuard aGuard( m_aMutex ); 347 CheckInit(); 348 349 if ( m_bWaitSaveCompleted ) 350 throw embed::WrongStateException( 351 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 352 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 353 354 PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAs" ), 355 uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( this ) ) ); 356 357 m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName ); 358 359 m_bWaitSaveCompleted = sal_True; 360 m_xNewParentStorage = xStorage; 361 m_aNewEntryName = sEntName; 362 } 363 364 //------------------------------------------------------ 365 void SAL_CALL ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew ) 366 { 367 ::osl::MutexGuard aGuard( m_aMutex ); 368 CheckInit(); 369 370 // it is allowed to call saveCompleted( false ) for nonstored objects 371 if ( !m_bWaitSaveCompleted && !bUseNew ) 372 return; 373 374 OSL_ENSURE( m_bWaitSaveCompleted, "Unexpected saveCompleted() call!\n" ); 375 if ( !m_bWaitSaveCompleted ) 376 throw io::IOException(); // TODO: illegal call 377 378 OSL_ENSURE( m_xNewParentStorage.is() , "Internal object information is broken!\n" ); 379 if ( !m_xNewParentStorage.is() ) 380 throw uno::RuntimeException(); // TODO: broken internal information 381 382 if ( bUseNew ) 383 { 384 m_xParentStorage = m_xNewParentStorage; 385 m_aEntryName = m_aNewEntryName; 386 387 PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAsDone" ), 388 uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( this ) ) ); 389 } 390 391 m_xNewParentStorage = uno::Reference< embed::XStorage >(); 392 m_aNewEntryName = ::rtl::OUString(); 393 m_bWaitSaveCompleted = sal_False; 394 } 395 396 //------------------------------------------------------ 397 sal_Bool SAL_CALL ODummyEmbeddedObject::hasEntry() 398 { 399 ::osl::MutexGuard aGuard( m_aMutex ); 400 CheckInit(); 401 402 if ( m_bWaitSaveCompleted ) 403 throw embed::WrongStateException( 404 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 405 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 406 407 if ( m_aEntryName.getLength() ) 408 return sal_True; 409 410 return sal_False; 411 } 412 413 //------------------------------------------------------ 414 ::rtl::OUString SAL_CALL ODummyEmbeddedObject::getEntryName() 415 { 416 ::osl::MutexGuard aGuard( m_aMutex ); 417 CheckInit(); 418 419 if ( m_bWaitSaveCompleted ) 420 throw embed::WrongStateException( 421 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 422 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 423 424 return m_aEntryName; 425 } 426 427 //------------------------------------------------------ 428 void SAL_CALL ODummyEmbeddedObject::storeOwn() 429 { 430 ::osl::MutexGuard aGuard( m_aMutex ); 431 CheckInit(); 432 433 if ( m_bWaitSaveCompleted ) 434 throw embed::WrongStateException( 435 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 436 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 437 438 // the object can not be activated or changed 439 return; 440 } 441 442 //------------------------------------------------------ 443 sal_Bool SAL_CALL ODummyEmbeddedObject::isReadonly() 444 { 445 ::osl::MutexGuard aGuard( m_aMutex ); 446 CheckInit(); 447 448 if ( m_bWaitSaveCompleted ) 449 throw embed::WrongStateException( 450 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 451 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 452 453 // this object can not be changed 454 return sal_True; 455 } 456 457 //------------------------------------------------------ 458 void SAL_CALL ODummyEmbeddedObject::reload( 459 const uno::Sequence< beans::PropertyValue >& /* lArguments */, 460 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ ) 461 { 462 ::osl::MutexGuard aGuard( m_aMutex ); 463 CheckInit(); 464 465 if ( m_bWaitSaveCompleted ) 466 throw embed::WrongStateException( 467 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 468 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 469 470 // nothing to reload 471 } 472 473 //------------------------------------------------------ 474 uno::Sequence< sal_Int8 > SAL_CALL ODummyEmbeddedObject::getClassID() 475 { 476 ::osl::MutexGuard aGuard( m_aMutex ); 477 CheckInit(); 478 479 // currently the class ID is empty 480 // TODO/LATER: should a special class ID be used in this case? 481 return uno::Sequence< sal_Int8 >(); 482 } 483 484 //------------------------------------------------------ 485 ::rtl::OUString SAL_CALL ODummyEmbeddedObject::getClassName() 486 { 487 ::osl::MutexGuard aGuard( m_aMutex ); 488 if ( m_bDisposed ) 489 throw lang::DisposedException(); // TODO 490 491 return ::rtl::OUString(); 492 } 493 494 //------------------------------------------------------ 495 void SAL_CALL ODummyEmbeddedObject::setClassInfo( 496 const uno::Sequence< sal_Int8 >& /*aClassID*/, const ::rtl::OUString& /*aClassName*/ ) 497 { 498 throw lang::NoSupportException(); 499 } 500 501 //------------------------------------------------------ 502 uno::Reference< util::XCloseable > SAL_CALL ODummyEmbeddedObject::getComponent() 503 { 504 ::osl::MutexGuard aGuard( m_aMutex ); 505 CheckInit(); 506 507 return uno::Reference< util::XCloseable >(); 508 } 509 510 //---------------------------------------------- 511 void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener ) 512 { 513 ::osl::MutexGuard aGuard( m_aMutex ); 514 if ( m_bDisposed ) 515 return; 516 517 if ( !m_pInterfaceContainer ) 518 m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); 519 520 m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ), 521 xListener ); 522 } 523 524 //---------------------------------------------- 525 void SAL_CALL ODummyEmbeddedObject::removeStateChangeListener( 526 const uno::Reference< embed::XStateChangeListener >& xListener ) 527 { 528 ::osl::MutexGuard aGuard( m_aMutex ); 529 if ( m_pInterfaceContainer ) 530 m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ), 531 xListener ); 532 } 533 534 //---------------------------------------------- 535 void SAL_CALL ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership ) 536 { 537 ::osl::MutexGuard aGuard( m_aMutex ); 538 if ( m_bDisposed ) 539 throw lang::DisposedException(); // TODO 540 541 uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) ); 542 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); 543 544 if ( m_pInterfaceContainer ) 545 { 546 ::cppu::OInterfaceContainerHelper* pContainer = 547 m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) ); 548 if ( pContainer != NULL ) 549 { 550 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); 551 while (pIterator.hasMoreElements()) 552 { 553 try 554 { 555 ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership ); 556 } 557 catch( uno::RuntimeException& ) 558 { 559 pIterator.remove(); 560 } 561 } 562 } 563 564 pContainer = m_pInterfaceContainer->getContainer( 565 ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) ); 566 if ( pContainer != NULL ) 567 { 568 ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer); 569 while (pCloseIterator.hasMoreElements()) 570 { 571 try 572 { 573 ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource ); 574 } 575 catch( uno::RuntimeException& ) 576 { 577 pCloseIterator.remove(); 578 } 579 } 580 } 581 582 m_pInterfaceContainer->disposeAndClear( aSource ); 583 } 584 585 m_bDisposed = sal_True; // the object is disposed now for outside 586 } 587 588 //---------------------------------------------- 589 void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener ) 590 { 591 ::osl::MutexGuard aGuard( m_aMutex ); 592 if ( m_bDisposed ) 593 return; 594 595 if ( !m_pInterfaceContainer ) 596 m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); 597 598 m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener ); 599 } 600 601 //---------------------------------------------- 602 void SAL_CALL ODummyEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener ) 603 { 604 ::osl::MutexGuard aGuard( m_aMutex ); 605 if ( m_pInterfaceContainer ) 606 m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), 607 xListener ); 608 } 609 610 //------------------------------------------------------ 611 void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener ) 612 { 613 ::osl::MutexGuard aGuard( m_aMutex ); 614 if ( m_bDisposed ) 615 return; 616 617 if ( !m_pInterfaceContainer ) 618 m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); 619 620 m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener ); 621 } 622 623 //------------------------------------------------------ 624 void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener ) 625 { 626 ::osl::MutexGuard aGuard( m_aMutex ); 627 if ( m_pInterfaceContainer ) 628 m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), 629 xListener ); 630 } 631