Update ooo320-m1
[ooovba.git] / embeddedobj / source / general / dummyobject.cxx
blobdb048a49696e23e3e59f35e1037ae7350726b011
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dummyobject.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_embeddedobj.hxx"
32 #include <com/sun/star/embed/EmbedStates.hpp>
33 #include <com/sun/star/embed/EmbedVerbs.hpp>
34 #include <com/sun/star/embed/EmbedUpdateModes.hpp>
35 #include <com/sun/star/embed/XEmbeddedClient.hpp>
36 #include <com/sun/star/embed/XInplaceClient.hpp>
37 #include <com/sun/star/embed/XWindowSupplier.hpp>
38 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
39 #include <com/sun/star/embed/EmbedStates.hpp>
40 #include <com/sun/star/embed/Aspects.hpp>
41 #include <com/sun/star/embed/EmbedMapUnits.hpp>
42 #include <com/sun/star/embed/EntryInitModes.hpp>
43 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
44 #include <com/sun/star/lang/DisposedException.hpp>
46 #include <cppuhelper/interfacecontainer.h>
48 #include <dummyobject.hxx>
51 using namespace ::com::sun::star;
53 //----------------------------------------------
54 void ODummyEmbeddedObject::CheckInit()
56 if ( m_bDisposed )
57 throw lang::DisposedException();
59 if ( m_nObjectState == -1 )
60 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
61 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
64 //----------------------------------------------
65 void ODummyEmbeddedObject::PostEvent_Impl( const ::rtl::OUString& aEventName,
66 const uno::Reference< uno::XInterface >& /*xSource*/ )
68 if ( m_pInterfaceContainer )
70 ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer(
71 ::getCppuType((const uno::Reference< document::XEventListener >*)0) );
72 if( pIC )
74 document::EventObject aEvent;
75 aEvent.EventName = aEventName;
76 aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) );
77 // For now all the events are sent as object events
78 // aEvent.Source = ( xSource.is() ? xSource
79 // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) );
80 ::cppu::OInterfaceIteratorHelper aIt( *pIC );
81 while( aIt.hasMoreElements() )
83 try
85 ((document::XEventListener *)aIt.next())->notifyEvent( aEvent );
87 catch( uno::RuntimeException& )
89 aIt.remove();
92 // the listener could dispose the object.
93 if ( m_bDisposed )
94 return;
100 //----------------------------------------------
101 ODummyEmbeddedObject::~ODummyEmbeddedObject()
105 //----------------------------------------------
106 void SAL_CALL ODummyEmbeddedObject::changeState( sal_Int32 nNewState )
107 throw ( embed::UnreachableStateException,
108 embed::WrongStateException,
109 uno::Exception,
110 uno::RuntimeException )
112 ::osl::MutexGuard aGuard( m_aMutex );
113 CheckInit();
115 if ( nNewState == embed::EmbedStates::LOADED )
116 return;
118 throw embed::UnreachableStateException();
121 //----------------------------------------------
122 uno::Sequence< sal_Int32 > SAL_CALL ODummyEmbeddedObject::getReachableStates()
123 throw ( embed::WrongStateException,
124 uno::RuntimeException )
126 ::osl::MutexGuard aGuard( m_aMutex );
127 CheckInit();
129 uno::Sequence< sal_Int32 > aResult( 1 );
130 aResult[0] = embed::EmbedStates::LOADED;
132 return aResult;
135 //----------------------------------------------
136 sal_Int32 SAL_CALL ODummyEmbeddedObject::getCurrentState()
137 throw ( embed::WrongStateException,
138 uno::RuntimeException )
140 ::osl::MutexGuard aGuard( m_aMutex );
141 CheckInit();
143 return m_nObjectState;
146 //----------------------------------------------
147 void SAL_CALL ODummyEmbeddedObject::doVerb( sal_Int32 )
148 throw ( lang::IllegalArgumentException,
149 embed::WrongStateException,
150 embed::UnreachableStateException,
151 uno::Exception,
152 uno::RuntimeException )
154 ::osl::MutexGuard aGuard( m_aMutex );
155 CheckInit();
157 // no supported verbs
160 //----------------------------------------------
161 uno::Sequence< embed::VerbDescriptor > SAL_CALL ODummyEmbeddedObject::getSupportedVerbs()
162 throw ( embed::WrongStateException,
163 uno::RuntimeException )
165 ::osl::MutexGuard aGuard( m_aMutex );
166 CheckInit();
168 return uno::Sequence< embed::VerbDescriptor >();
171 //----------------------------------------------
172 void SAL_CALL ODummyEmbeddedObject::setClientSite(
173 const uno::Reference< embed::XEmbeddedClient >& xClient )
174 throw ( embed::WrongStateException,
175 uno::RuntimeException )
177 ::osl::MutexGuard aGuard( m_aMutex );
178 CheckInit();
180 m_xClientSite = xClient;
183 //----------------------------------------------
184 uno::Reference< embed::XEmbeddedClient > SAL_CALL ODummyEmbeddedObject::getClientSite()
185 throw ( embed::WrongStateException,
186 uno::RuntimeException )
188 ::osl::MutexGuard aGuard( m_aMutex );
189 CheckInit();
191 return m_xClientSite;
194 //----------------------------------------------
195 void SAL_CALL ODummyEmbeddedObject::update()
196 throw ( embed::WrongStateException,
197 uno::Exception,
198 uno::RuntimeException )
200 ::osl::MutexGuard aGuard( m_aMutex );
201 CheckInit();
204 //----------------------------------------------
205 void SAL_CALL ODummyEmbeddedObject::setUpdateMode( sal_Int32 )
206 throw ( embed::WrongStateException,
207 uno::RuntimeException )
209 ::osl::MutexGuard aGuard( m_aMutex );
210 CheckInit();
213 //----------------------------------------------
214 sal_Int64 SAL_CALL ODummyEmbeddedObject::getStatus( sal_Int64 )
215 throw ( embed::WrongStateException,
216 uno::RuntimeException )
218 ::osl::MutexGuard aGuard( m_aMutex );
219 CheckInit();
221 return 0;
224 //----------------------------------------------
225 void SAL_CALL ODummyEmbeddedObject::setContainerName( const ::rtl::OUString& )
226 throw ( uno::RuntimeException )
228 ::osl::MutexGuard aGuard( m_aMutex );
229 CheckInit();
232 //----------------------------------------------
233 void SAL_CALL ODummyEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
234 throw ( lang::IllegalArgumentException,
235 embed::WrongStateException,
236 uno::Exception,
237 uno::RuntimeException )
239 ::osl::MutexGuard aGuard( m_aMutex );
240 CheckInit();
242 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
243 if ( nAspect == embed::Aspects::MSOLE_ICON )
244 // no representation can be retrieved
245 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
246 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
248 m_nCachedAspect = nAspect;
249 m_aCachedSize = aSize;
250 m_bHasCachedSize = sal_True;
253 //----------------------------------------------
254 awt::Size SAL_CALL ODummyEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
255 throw ( lang::IllegalArgumentException,
256 embed::WrongStateException,
257 uno::Exception,
258 uno::RuntimeException )
260 ::osl::MutexGuard aGuard( m_aMutex );
261 CheckInit();
263 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
264 if ( nAspect == embed::Aspects::MSOLE_ICON )
265 // no representation can be retrieved
266 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
267 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
269 if ( !m_bHasCachedSize || m_nCachedAspect != nAspect )
270 throw embed::NoVisualAreaSizeException(
271 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No size available!\n" ) ),
272 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
274 return m_aCachedSize;
277 //----------------------------------------------
278 sal_Int32 SAL_CALL ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect )
279 throw ( uno::Exception,
280 uno::RuntimeException)
282 ::osl::MutexGuard aGuard( m_aMutex );
283 CheckInit();
285 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
286 if ( nAspect == embed::Aspects::MSOLE_ICON )
287 // no representation can be retrieved
288 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
289 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
291 return embed::EmbedMapUnits::ONE_100TH_MM;
294 //----------------------------------------------
295 embed::VisualRepresentation SAL_CALL ODummyEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 )
296 throw ( lang::IllegalArgumentException,
297 embed::WrongStateException,
298 uno::Exception,
299 uno::RuntimeException )
301 ::osl::MutexGuard aGuard( m_aMutex );
302 CheckInit();
304 // no representation can be retrieved
305 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
306 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
309 //----------------------------------------------
310 void SAL_CALL ODummyEmbeddedObject::setPersistentEntry(
311 const uno::Reference< embed::XStorage >& xStorage,
312 const ::rtl::OUString& sEntName,
313 sal_Int32 nEntryConnectionMode,
314 const uno::Sequence< beans::PropertyValue >& /* lArguments */,
315 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
316 throw ( lang::IllegalArgumentException,
317 embed::WrongStateException,
318 io::IOException,
319 uno::Exception,
320 uno::RuntimeException )
322 ::osl::MutexGuard aGuard( m_aMutex );
323 if ( m_bDisposed )
324 throw lang::DisposedException(); // TODO
326 if ( !xStorage.is() )
327 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
328 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
329 1 );
331 if ( !sEntName.getLength() )
332 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
333 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
334 2 );
336 if ( ( m_nObjectState != -1 || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
337 && ( m_nObjectState == -1 || nEntryConnectionMode != embed::EntryInitModes::NO_INIT ) )
339 throw embed::WrongStateException(
340 ::rtl::OUString::createFromAscii( "Can't change persistant representation of activated object!\n" ),
341 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
344 if ( m_bWaitSaveCompleted )
346 if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
347 saveCompleted( ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) ) );
348 else
349 throw embed::WrongStateException(
350 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
351 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
354 if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT
355 || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
357 if ( xStorage->hasByName( sEntName ) )
360 m_xParentStorage = xStorage;
361 m_aEntryName = sEntName;
362 m_nObjectState = embed::EmbedStates::LOADED;
364 else
365 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Wrong entry is provided!\n" ),
366 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
367 2 );
370 else
371 throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Wrong connection mode is provided!\n" ),
372 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
373 3 );
376 //------------------------------------------------------
377 void SAL_CALL ODummyEmbeddedObject::storeToEntry( const uno::Reference< embed::XStorage >& xStorage,
378 const ::rtl::OUString& sEntName,
379 const uno::Sequence< beans::PropertyValue >& /* lArguments */,
380 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
381 throw ( lang::IllegalArgumentException,
382 embed::WrongStateException,
383 io::IOException,
384 uno::Exception,
385 uno::RuntimeException )
387 ::osl::MutexGuard aGuard( m_aMutex );
388 CheckInit();
390 if ( m_bWaitSaveCompleted )
391 throw embed::WrongStateException(
392 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
393 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
395 m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
398 //------------------------------------------------------
399 void SAL_CALL ODummyEmbeddedObject::storeAsEntry( const uno::Reference< embed::XStorage >& xStorage,
400 const ::rtl::OUString& sEntName,
401 const uno::Sequence< beans::PropertyValue >& /* lArguments */,
402 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
403 throw ( lang::IllegalArgumentException,
404 embed::WrongStateException,
405 io::IOException,
406 uno::Exception,
407 uno::RuntimeException )
409 ::osl::MutexGuard aGuard( m_aMutex );
410 CheckInit();
412 if ( m_bWaitSaveCompleted )
413 throw embed::WrongStateException(
414 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
415 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
417 PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAs" ),
418 uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( this ) ) );
420 m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
422 m_bWaitSaveCompleted = sal_True;
423 m_xNewParentStorage = xStorage;
424 m_aNewEntryName = sEntName;
427 //------------------------------------------------------
428 void SAL_CALL ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew )
429 throw ( embed::WrongStateException,
430 uno::Exception,
431 uno::RuntimeException )
433 ::osl::MutexGuard aGuard( m_aMutex );
434 CheckInit();
436 // it is allowed to call saveCompleted( false ) for nonstored objects
437 if ( !m_bWaitSaveCompleted && !bUseNew )
438 return;
440 OSL_ENSURE( m_bWaitSaveCompleted, "Unexpected saveCompleted() call!\n" );
441 if ( !m_bWaitSaveCompleted )
442 throw io::IOException(); // TODO: illegal call
444 OSL_ENSURE( m_xNewParentStorage.is() , "Internal object information is broken!\n" );
445 if ( !m_xNewParentStorage.is() )
446 throw uno::RuntimeException(); // TODO: broken internal information
448 if ( bUseNew )
450 m_xParentStorage = m_xNewParentStorage;
451 m_aEntryName = m_aNewEntryName;
453 PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAsDone" ),
454 uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( this ) ) );
457 m_xNewParentStorage = uno::Reference< embed::XStorage >();
458 m_aNewEntryName = ::rtl::OUString();
459 m_bWaitSaveCompleted = sal_False;
462 //------------------------------------------------------
463 sal_Bool SAL_CALL ODummyEmbeddedObject::hasEntry()
464 throw ( embed::WrongStateException,
465 uno::RuntimeException )
467 ::osl::MutexGuard aGuard( m_aMutex );
468 CheckInit();
470 if ( m_bWaitSaveCompleted )
471 throw embed::WrongStateException(
472 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
473 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
475 if ( m_aEntryName.getLength() )
476 return sal_True;
478 return sal_False;
481 //------------------------------------------------------
482 ::rtl::OUString SAL_CALL ODummyEmbeddedObject::getEntryName()
483 throw ( embed::WrongStateException,
484 uno::RuntimeException )
486 ::osl::MutexGuard aGuard( m_aMutex );
487 CheckInit();
489 if ( m_bWaitSaveCompleted )
490 throw embed::WrongStateException(
491 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
492 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
494 return m_aEntryName;
497 //------------------------------------------------------
498 void SAL_CALL ODummyEmbeddedObject::storeOwn()
499 throw ( embed::WrongStateException,
500 io::IOException,
501 uno::Exception,
502 uno::RuntimeException )
504 ::osl::MutexGuard aGuard( m_aMutex );
505 CheckInit();
507 if ( m_bWaitSaveCompleted )
508 throw embed::WrongStateException(
509 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
510 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
512 // the object can not be activated or changed
513 return;
516 //------------------------------------------------------
517 sal_Bool SAL_CALL ODummyEmbeddedObject::isReadonly()
518 throw ( embed::WrongStateException,
519 uno::RuntimeException )
521 ::osl::MutexGuard aGuard( m_aMutex );
522 CheckInit();
524 if ( m_bWaitSaveCompleted )
525 throw embed::WrongStateException(
526 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
527 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
529 // this object can not be changed
530 return sal_True;
533 //------------------------------------------------------
534 void SAL_CALL ODummyEmbeddedObject::reload(
535 const uno::Sequence< beans::PropertyValue >& /* lArguments */,
536 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
537 throw ( lang::IllegalArgumentException,
538 embed::WrongStateException,
539 io::IOException,
540 uno::Exception,
541 uno::RuntimeException )
543 ::osl::MutexGuard aGuard( m_aMutex );
544 CheckInit();
546 if ( m_bWaitSaveCompleted )
547 throw embed::WrongStateException(
548 ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
549 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
551 // nothing to reload
554 //------------------------------------------------------
555 uno::Sequence< sal_Int8 > SAL_CALL ODummyEmbeddedObject::getClassID()
556 throw ( uno::RuntimeException )
558 ::osl::MutexGuard aGuard( m_aMutex );
559 CheckInit();
561 // currently the class ID is empty
562 // TODO/LATER: should a special class ID be used in this case?
563 return uno::Sequence< sal_Int8 >();
566 //------------------------------------------------------
567 ::rtl::OUString SAL_CALL ODummyEmbeddedObject::getClassName()
568 throw ( uno::RuntimeException )
570 ::osl::MutexGuard aGuard( m_aMutex );
571 if ( m_bDisposed )
572 throw lang::DisposedException(); // TODO
574 return ::rtl::OUString();
577 //------------------------------------------------------
578 void SAL_CALL ODummyEmbeddedObject::setClassInfo(
579 const uno::Sequence< sal_Int8 >& /*aClassID*/, const ::rtl::OUString& /*aClassName*/ )
580 throw ( lang::NoSupportException,
581 uno::RuntimeException )
583 throw lang::NoSupportException();
586 //------------------------------------------------------
587 uno::Reference< util::XCloseable > SAL_CALL ODummyEmbeddedObject::getComponent()
588 throw ( uno::RuntimeException )
590 ::osl::MutexGuard aGuard( m_aMutex );
591 CheckInit();
593 return uno::Reference< util::XCloseable >();
596 //----------------------------------------------
597 void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
598 throw ( uno::RuntimeException )
600 ::osl::MutexGuard aGuard( m_aMutex );
601 if ( m_bDisposed )
602 return;
604 if ( !m_pInterfaceContainer )
605 m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
607 m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
608 xListener );
611 //----------------------------------------------
612 void SAL_CALL ODummyEmbeddedObject::removeStateChangeListener(
613 const uno::Reference< embed::XStateChangeListener >& xListener )
614 throw (uno::RuntimeException)
616 ::osl::MutexGuard aGuard( m_aMutex );
617 if ( m_pInterfaceContainer )
618 m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
619 xListener );
622 //----------------------------------------------
623 void SAL_CALL ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership )
624 throw ( util::CloseVetoException,
625 uno::RuntimeException )
627 ::osl::MutexGuard aGuard( m_aMutex );
628 if ( m_bDisposed )
629 throw lang::DisposedException(); // TODO
631 uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
632 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
634 if ( m_pInterfaceContainer )
636 ::cppu::OInterfaceContainerHelper* pContainer =
637 m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
638 if ( pContainer != NULL )
640 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
641 while (pIterator.hasMoreElements())
645 ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
647 catch( uno::RuntimeException& )
649 pIterator.remove();
654 pContainer = m_pInterfaceContainer->getContainer(
655 ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
656 if ( pContainer != NULL )
658 ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
659 while (pCloseIterator.hasMoreElements())
663 ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
665 catch( uno::RuntimeException& )
667 pCloseIterator.remove();
672 m_pInterfaceContainer->disposeAndClear( aSource );
675 m_bDisposed = sal_True; // the object is disposed now for outside
678 //----------------------------------------------
679 void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
680 throw ( uno::RuntimeException )
682 ::osl::MutexGuard aGuard( m_aMutex );
683 if ( m_bDisposed )
684 return;
686 if ( !m_pInterfaceContainer )
687 m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
689 m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener );
692 //----------------------------------------------
693 void SAL_CALL ODummyEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
694 throw (uno::RuntimeException)
696 ::osl::MutexGuard aGuard( m_aMutex );
697 if ( m_pInterfaceContainer )
698 m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ),
699 xListener );
702 //------------------------------------------------------
703 void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
704 throw ( uno::RuntimeException )
706 ::osl::MutexGuard aGuard( m_aMutex );
707 if ( m_bDisposed )
708 return;
710 if ( !m_pInterfaceContainer )
711 m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
713 m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener );
716 //------------------------------------------------------
717 void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
718 throw ( uno::RuntimeException )
720 ::osl::MutexGuard aGuard( m_aMutex );
721 if ( m_pInterfaceContainer )
722 m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ),
723 xListener );