1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/embed/EmbedStates.hpp>
30 #include <com/sun/star/embed/EmbedVerbs.hpp>
31 #include <com/sun/star/embed/EmbedUpdateModes.hpp>
32 #include <com/sun/star/embed/XEmbeddedClient.hpp>
33 #include <com/sun/star/embed/XInplaceClient.hpp>
34 #include <com/sun/star/embed/XWindowSupplier.hpp>
35 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
36 #include <com/sun/star/embed/EmbedStates.hpp>
37 #include <com/sun/star/embed/Aspects.hpp>
38 #include <com/sun/star/embed/EmbedMapUnits.hpp>
39 #include <com/sun/star/embed/EntryInitModes.hpp>
40 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
41 #include <com/sun/star/lang/DisposedException.hpp>
43 #include <cppuhelper/interfacecontainer.h>
45 #include <dummyobject.hxx>
48 using namespace ::com::sun::star
;
50 //----------------------------------------------
51 void ODummyEmbeddedObject::CheckInit()
54 throw lang::DisposedException();
56 if ( m_nObjectState
== -1 )
57 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
58 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
61 //----------------------------------------------
62 void ODummyEmbeddedObject::PostEvent_Impl( const ::rtl::OUString
& aEventName
)
64 if ( m_pInterfaceContainer
)
66 ::cppu::OInterfaceContainerHelper
* pIC
= m_pInterfaceContainer
->getContainer(
67 ::getCppuType((const uno::Reference
< document::XEventListener
>*)0) );
70 document::EventObject aEvent
;
71 aEvent
.EventName
= aEventName
;
72 aEvent
.Source
= uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >( this ) );
73 // For now all the events are sent as object events
74 // aEvent.Source = ( xSource.is() ? xSource
75 // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) );
76 ::cppu::OInterfaceIteratorHelper
aIt( *pIC
);
77 while( aIt
.hasMoreElements() )
81 ((document::XEventListener
*)aIt
.next())->notifyEvent( aEvent
);
83 catch( const uno::RuntimeException
& )
88 // the listener could dispose the object.
96 //----------------------------------------------
97 ODummyEmbeddedObject::~ODummyEmbeddedObject()
101 //----------------------------------------------
102 void SAL_CALL
ODummyEmbeddedObject::changeState( sal_Int32 nNewState
)
103 throw ( embed::UnreachableStateException
,
104 embed::WrongStateException
,
106 uno::RuntimeException
)
108 ::osl::MutexGuard
aGuard( m_aMutex
);
111 if ( nNewState
== embed::EmbedStates::LOADED
)
114 throw embed::UnreachableStateException();
117 //----------------------------------------------
118 uno::Sequence
< sal_Int32
> SAL_CALL
ODummyEmbeddedObject::getReachableStates()
119 throw ( embed::WrongStateException
,
120 uno::RuntimeException
)
122 ::osl::MutexGuard
aGuard( m_aMutex
);
125 uno::Sequence
< sal_Int32
> aResult( 1 );
126 aResult
[0] = embed::EmbedStates::LOADED
;
131 //----------------------------------------------
132 sal_Int32 SAL_CALL
ODummyEmbeddedObject::getCurrentState()
133 throw ( embed::WrongStateException
,
134 uno::RuntimeException
)
136 ::osl::MutexGuard
aGuard( m_aMutex
);
139 return m_nObjectState
;
142 //----------------------------------------------
143 void SAL_CALL
ODummyEmbeddedObject::doVerb( sal_Int32
)
144 throw ( lang::IllegalArgumentException
,
145 embed::WrongStateException
,
146 embed::UnreachableStateException
,
148 uno::RuntimeException
)
150 ::osl::MutexGuard
aGuard( m_aMutex
);
153 // no supported verbs
156 //----------------------------------------------
157 uno::Sequence
< embed::VerbDescriptor
> SAL_CALL
ODummyEmbeddedObject::getSupportedVerbs()
158 throw ( embed::WrongStateException
,
159 uno::RuntimeException
)
161 ::osl::MutexGuard
aGuard( m_aMutex
);
164 return uno::Sequence
< embed::VerbDescriptor
>();
167 //----------------------------------------------
168 void SAL_CALL
ODummyEmbeddedObject::setClientSite(
169 const uno::Reference
< embed::XEmbeddedClient
>& xClient
)
170 throw ( embed::WrongStateException
,
171 uno::RuntimeException
)
173 ::osl::MutexGuard
aGuard( m_aMutex
);
176 m_xClientSite
= xClient
;
179 //----------------------------------------------
180 uno::Reference
< embed::XEmbeddedClient
> SAL_CALL
ODummyEmbeddedObject::getClientSite()
181 throw ( embed::WrongStateException
,
182 uno::RuntimeException
)
184 ::osl::MutexGuard
aGuard( m_aMutex
);
187 return m_xClientSite
;
190 //----------------------------------------------
191 void SAL_CALL
ODummyEmbeddedObject::update()
192 throw ( embed::WrongStateException
,
194 uno::RuntimeException
)
196 ::osl::MutexGuard
aGuard( m_aMutex
);
200 //----------------------------------------------
201 void SAL_CALL
ODummyEmbeddedObject::setUpdateMode( sal_Int32
)
202 throw ( embed::WrongStateException
,
203 uno::RuntimeException
)
205 ::osl::MutexGuard
aGuard( m_aMutex
);
209 //----------------------------------------------
210 sal_Int64 SAL_CALL
ODummyEmbeddedObject::getStatus( sal_Int64
)
211 throw ( embed::WrongStateException
,
212 uno::RuntimeException
)
214 ::osl::MutexGuard
aGuard( m_aMutex
);
220 //----------------------------------------------
221 void SAL_CALL
ODummyEmbeddedObject::setContainerName( const ::rtl::OUString
& )
222 throw ( uno::RuntimeException
)
224 ::osl::MutexGuard
aGuard( m_aMutex
);
228 //----------------------------------------------
229 void SAL_CALL
ODummyEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect
, const awt::Size
& aSize
)
230 throw ( lang::IllegalArgumentException
,
231 embed::WrongStateException
,
233 uno::RuntimeException
)
235 ::osl::MutexGuard
aGuard( m_aMutex
);
238 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
239 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
240 // no representation can be retrieved
241 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
242 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
244 m_nCachedAspect
= nAspect
;
245 m_aCachedSize
= aSize
;
246 m_bHasCachedSize
= sal_True
;
249 //----------------------------------------------
250 awt::Size SAL_CALL
ODummyEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect
)
251 throw ( lang::IllegalArgumentException
,
252 embed::WrongStateException
,
254 uno::RuntimeException
)
256 ::osl::MutexGuard
aGuard( m_aMutex
);
259 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
260 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
261 // no representation can be retrieved
262 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
263 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
265 if ( !m_bHasCachedSize
|| m_nCachedAspect
!= nAspect
)
266 throw embed::NoVisualAreaSizeException(
267 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No size available!\n" ) ),
268 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
270 return m_aCachedSize
;
273 //----------------------------------------------
274 sal_Int32 SAL_CALL
ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect
)
275 throw ( uno::Exception
,
276 uno::RuntimeException
)
278 ::osl::MutexGuard
aGuard( m_aMutex
);
281 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
282 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
283 // no representation can be retrieved
284 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
285 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
287 return embed::EmbedMapUnits::ONE_100TH_MM
;
290 //----------------------------------------------
291 embed::VisualRepresentation SAL_CALL
ODummyEmbeddedObject::getPreferredVisualRepresentation( sal_Int64
)
292 throw ( lang::IllegalArgumentException
,
293 embed::WrongStateException
,
295 uno::RuntimeException
)
297 ::osl::MutexGuard
aGuard( m_aMutex
);
300 // no representation can be retrieved
301 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
302 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
305 //----------------------------------------------
306 void SAL_CALL
ODummyEmbeddedObject::setPersistentEntry(
307 const uno::Reference
< embed::XStorage
>& xStorage
,
308 const ::rtl::OUString
& sEntName
,
309 sal_Int32 nEntryConnectionMode
,
310 const uno::Sequence
< beans::PropertyValue
>& /* lArguments */,
311 const uno::Sequence
< beans::PropertyValue
>& /* lObjArgs */ )
312 throw ( lang::IllegalArgumentException
,
313 embed::WrongStateException
,
316 uno::RuntimeException
)
318 ::osl::MutexGuard
aGuard( m_aMutex
);
320 throw lang::DisposedException(); // TODO
322 if ( !xStorage
.is() )
323 throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
324 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ),
327 if ( sEntName
.isEmpty() )
328 throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
329 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ),
332 if ( ( m_nObjectState
!= -1 || nEntryConnectionMode
== embed::EntryInitModes::NO_INIT
)
333 && ( m_nObjectState
== -1 || nEntryConnectionMode
!= embed::EntryInitModes::NO_INIT
) )
335 throw embed::WrongStateException(
336 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Can't change persistant representation of activated object!\n" )),
337 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
340 if ( m_bWaitSaveCompleted
)
342 if ( nEntryConnectionMode
== embed::EntryInitModes::NO_INIT
)
343 saveCompleted( ( m_xParentStorage
!= xStorage
|| !m_aEntryName
.equals( sEntName
) ) );
345 throw embed::WrongStateException(
346 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
347 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
350 if ( nEntryConnectionMode
== embed::EntryInitModes::DEFAULT_INIT
351 || nEntryConnectionMode
== embed::EntryInitModes::NO_INIT
)
353 if ( xStorage
->hasByName( sEntName
) )
356 m_xParentStorage
= xStorage
;
357 m_aEntryName
= sEntName
;
358 m_nObjectState
= embed::EmbedStates::LOADED
;
361 throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Wrong entry is provided!\n" )),
362 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ),
367 throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Wrong connection mode is provided!\n" )),
368 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ),
372 //------------------------------------------------------
373 void SAL_CALL
ODummyEmbeddedObject::storeToEntry( const uno::Reference
< embed::XStorage
>& xStorage
,
374 const ::rtl::OUString
& sEntName
,
375 const uno::Sequence
< beans::PropertyValue
>& /* lArguments */,
376 const uno::Sequence
< beans::PropertyValue
>& /* lObjArgs */ )
377 throw ( lang::IllegalArgumentException
,
378 embed::WrongStateException
,
381 uno::RuntimeException
)
383 ::osl::MutexGuard
aGuard( m_aMutex
);
386 if ( m_bWaitSaveCompleted
)
387 throw embed::WrongStateException(
388 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
389 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
391 m_xParentStorage
->copyElementTo( m_aEntryName
, xStorage
, sEntName
);
394 //------------------------------------------------------
395 void SAL_CALL
ODummyEmbeddedObject::storeAsEntry( const uno::Reference
< embed::XStorage
>& xStorage
,
396 const ::rtl::OUString
& sEntName
,
397 const uno::Sequence
< beans::PropertyValue
>& /* lArguments */,
398 const uno::Sequence
< beans::PropertyValue
>& /* lObjArgs */ )
399 throw ( lang::IllegalArgumentException
,
400 embed::WrongStateException
,
403 uno::RuntimeException
)
405 ::osl::MutexGuard
aGuard( m_aMutex
);
408 if ( m_bWaitSaveCompleted
)
409 throw embed::WrongStateException(
410 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
411 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
413 PostEvent_Impl( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OnSaveAs" )) );
415 m_xParentStorage
->copyElementTo( m_aEntryName
, xStorage
, sEntName
);
417 m_bWaitSaveCompleted
= sal_True
;
418 m_xNewParentStorage
= xStorage
;
419 m_aNewEntryName
= sEntName
;
422 //------------------------------------------------------
423 void SAL_CALL
ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew
)
424 throw ( embed::WrongStateException
,
426 uno::RuntimeException
)
428 ::osl::MutexGuard
aGuard( m_aMutex
);
431 // it is allowed to call saveCompleted( false ) for nonstored objects
432 if ( !m_bWaitSaveCompleted
&& !bUseNew
)
435 OSL_ENSURE( m_bWaitSaveCompleted
, "Unexpected saveCompleted() call!\n" );
436 if ( !m_bWaitSaveCompleted
)
437 throw io::IOException(); // TODO: illegal call
439 OSL_ENSURE( m_xNewParentStorage
.is() , "Internal object information is broken!\n" );
440 if ( !m_xNewParentStorage
.is() )
441 throw uno::RuntimeException(); // TODO: broken internal information
445 m_xParentStorage
= m_xNewParentStorage
;
446 m_aEntryName
= m_aNewEntryName
;
448 PostEvent_Impl( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OnSaveAsDone" )) );
451 m_xNewParentStorage
= uno::Reference
< embed::XStorage
>();
452 m_aNewEntryName
= ::rtl::OUString();
453 m_bWaitSaveCompleted
= sal_False
;
456 //------------------------------------------------------
457 sal_Bool SAL_CALL
ODummyEmbeddedObject::hasEntry()
458 throw ( embed::WrongStateException
,
459 uno::RuntimeException
)
461 ::osl::MutexGuard
aGuard( m_aMutex
);
464 if ( m_bWaitSaveCompleted
)
465 throw embed::WrongStateException(
466 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
467 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
469 if ( !m_aEntryName
.isEmpty() )
475 //------------------------------------------------------
476 ::rtl::OUString SAL_CALL
ODummyEmbeddedObject::getEntryName()
477 throw ( embed::WrongStateException
,
478 uno::RuntimeException
)
480 ::osl::MutexGuard
aGuard( m_aMutex
);
483 if ( m_bWaitSaveCompleted
)
484 throw embed::WrongStateException(
485 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
486 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
491 //------------------------------------------------------
492 void SAL_CALL
ODummyEmbeddedObject::storeOwn()
493 throw ( embed::WrongStateException
,
496 uno::RuntimeException
)
498 ::osl::MutexGuard
aGuard( m_aMutex
);
501 if ( m_bWaitSaveCompleted
)
502 throw embed::WrongStateException(
503 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
504 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
506 // the object can not be activated or changed
510 //------------------------------------------------------
511 sal_Bool SAL_CALL
ODummyEmbeddedObject::isReadonly()
512 throw ( embed::WrongStateException
,
513 uno::RuntimeException
)
515 ::osl::MutexGuard
aGuard( m_aMutex
);
518 if ( m_bWaitSaveCompleted
)
519 throw embed::WrongStateException(
520 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
521 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
523 // this object can not be changed
527 //------------------------------------------------------
528 void SAL_CALL
ODummyEmbeddedObject::reload(
529 const uno::Sequence
< beans::PropertyValue
>& /* lArguments */,
530 const uno::Sequence
< beans::PropertyValue
>& /* lObjArgs */ )
531 throw ( lang::IllegalArgumentException
,
532 embed::WrongStateException
,
535 uno::RuntimeException
)
537 ::osl::MutexGuard
aGuard( m_aMutex
);
540 if ( m_bWaitSaveCompleted
)
541 throw embed::WrongStateException(
542 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object waits for saveCompleted() call!\n" )),
543 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
548 //------------------------------------------------------
549 uno::Sequence
< sal_Int8
> SAL_CALL
ODummyEmbeddedObject::getClassID()
550 throw ( uno::RuntimeException
)
552 ::osl::MutexGuard
aGuard( m_aMutex
);
555 // currently the class ID is empty
556 // TODO/LATER: should a special class ID be used in this case?
557 return uno::Sequence
< sal_Int8
>();
560 //------------------------------------------------------
561 ::rtl::OUString SAL_CALL
ODummyEmbeddedObject::getClassName()
562 throw ( uno::RuntimeException
)
564 ::osl::MutexGuard
aGuard( m_aMutex
);
566 throw lang::DisposedException(); // TODO
568 return ::rtl::OUString();
571 //------------------------------------------------------
572 void SAL_CALL
ODummyEmbeddedObject::setClassInfo(
573 const uno::Sequence
< sal_Int8
>& /*aClassID*/, const ::rtl::OUString
& /*aClassName*/ )
574 throw ( lang::NoSupportException
,
575 uno::RuntimeException
)
577 throw lang::NoSupportException();
580 //------------------------------------------------------
581 uno::Reference
< util::XCloseable
> SAL_CALL
ODummyEmbeddedObject::getComponent()
582 throw ( uno::RuntimeException
)
584 ::osl::MutexGuard
aGuard( m_aMutex
);
587 return uno::Reference
< util::XCloseable
>();
590 //----------------------------------------------
591 void SAL_CALL
ODummyEmbeddedObject::addStateChangeListener( const uno::Reference
< embed::XStateChangeListener
>& xListener
)
592 throw ( uno::RuntimeException
)
594 ::osl::MutexGuard
aGuard( m_aMutex
);
598 if ( !m_pInterfaceContainer
)
599 m_pInterfaceContainer
= new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex
);
601 m_pInterfaceContainer
->addInterface( ::getCppuType( (const uno::Reference
< embed::XStateChangeListener
>*)0 ),
605 //----------------------------------------------
606 void SAL_CALL
ODummyEmbeddedObject::removeStateChangeListener(
607 const uno::Reference
< embed::XStateChangeListener
>& xListener
)
608 throw (uno::RuntimeException
)
610 ::osl::MutexGuard
aGuard( m_aMutex
);
611 if ( m_pInterfaceContainer
)
612 m_pInterfaceContainer
->removeInterface( ::getCppuType( (const uno::Reference
< embed::XStateChangeListener
>*)0 ),
616 //----------------------------------------------
617 void SAL_CALL
ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership
)
618 throw ( util::CloseVetoException
,
619 uno::RuntimeException
)
621 ::osl::MutexGuard
aGuard( m_aMutex
);
623 throw lang::DisposedException(); // TODO
625 uno::Reference
< uno::XInterface
> xSelfHold( static_cast< ::cppu::OWeakObject
* >( this ) );
626 lang::EventObject
aSource( static_cast< ::cppu::OWeakObject
* >( this ) );
628 if ( m_pInterfaceContainer
)
630 ::cppu::OInterfaceContainerHelper
* pContainer
=
631 m_pInterfaceContainer
->getContainer( ::getCppuType( ( const uno::Reference
< util::XCloseListener
>*) NULL
) );
632 if ( pContainer
!= NULL
)
634 ::cppu::OInterfaceIteratorHelper
pIterator(*pContainer
);
635 while (pIterator
.hasMoreElements())
639 ((util::XCloseListener
*)pIterator
.next())->queryClosing( aSource
, bDeliverOwnership
);
641 catch( const uno::RuntimeException
& )
648 pContainer
= m_pInterfaceContainer
->getContainer(
649 ::getCppuType( ( const uno::Reference
< util::XCloseListener
>*) NULL
) );
650 if ( pContainer
!= NULL
)
652 ::cppu::OInterfaceIteratorHelper
pCloseIterator(*pContainer
);
653 while (pCloseIterator
.hasMoreElements())
657 ((util::XCloseListener
*)pCloseIterator
.next())->notifyClosing( aSource
);
659 catch( const uno::RuntimeException
& )
661 pCloseIterator
.remove();
666 m_pInterfaceContainer
->disposeAndClear( aSource
);
669 m_bDisposed
= sal_True
; // the object is disposed now for outside
672 //----------------------------------------------
673 void SAL_CALL
ODummyEmbeddedObject::addCloseListener( const uno::Reference
< util::XCloseListener
>& xListener
)
674 throw ( uno::RuntimeException
)
676 ::osl::MutexGuard
aGuard( m_aMutex
);
680 if ( !m_pInterfaceContainer
)
681 m_pInterfaceContainer
= new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex
);
683 m_pInterfaceContainer
->addInterface( ::getCppuType( (const uno::Reference
< util::XCloseListener
>*)0 ), xListener
);
686 //----------------------------------------------
687 void SAL_CALL
ODummyEmbeddedObject::removeCloseListener( const uno::Reference
< util::XCloseListener
>& xListener
)
688 throw (uno::RuntimeException
)
690 ::osl::MutexGuard
aGuard( m_aMutex
);
691 if ( m_pInterfaceContainer
)
692 m_pInterfaceContainer
->removeInterface( ::getCppuType( (const uno::Reference
< util::XCloseListener
>*)0 ),
696 //------------------------------------------------------
697 void SAL_CALL
ODummyEmbeddedObject::addEventListener( const uno::Reference
< document::XEventListener
>& xListener
)
698 throw ( uno::RuntimeException
)
700 ::osl::MutexGuard
aGuard( m_aMutex
);
704 if ( !m_pInterfaceContainer
)
705 m_pInterfaceContainer
= new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex
);
707 m_pInterfaceContainer
->addInterface( ::getCppuType( (const uno::Reference
< document::XEventListener
>*)0 ), xListener
);
710 //------------------------------------------------------
711 void SAL_CALL
ODummyEmbeddedObject::removeEventListener( const uno::Reference
< document::XEventListener
>& xListener
)
712 throw ( uno::RuntimeException
)
714 ::osl::MutexGuard
aGuard( m_aMutex
);
715 if ( m_pInterfaceContainer
)
716 m_pInterfaceContainer
->removeInterface( ::getCppuType( (const uno::Reference
< document::XEventListener
>*)0 ),
720 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */