1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <commonembobj.hxx>
21 #include <com/sun/star/embed/EmbedStates.hpp>
22 #include <com/sun/star/embed/EmbedVerbs.hpp>
23 #include <com/sun/star/embed/XStorage.hpp>
24 #include <com/sun/star/embed/EmbedUpdateModes.hpp>
25 #include <com/sun/star/embed/XInplaceClient.hpp>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/beans/NamedValue.hpp>
29 #include <cppuhelper/typeprovider.hxx>
30 #include <cppuhelper/queryinterface.hxx>
31 #include <cppuhelper/interfacecontainer.h>
32 #include <comphelper/mimeconfighelper.hxx>
33 #include <comphelper/processfactory.hxx>
35 #include "closepreventer.hxx"
36 #include "intercept.hxx"
37 #include "persistence.hxx"
39 using namespace ::com::sun::star
;
42 OCommonEmbeddedObject::OCommonEmbeddedObject( const uno::Reference
< uno::XComponentContext
>& rxContext
,
43 const uno::Sequence
< beans::NamedValue
>& aObjProps
)
44 : m_pDocHolder( NULL
)
45 , m_pInterfaceContainer( NULL
)
46 , m_bReadOnly( false )
47 , m_bDisposed( false )
49 , m_nObjectState( -1 )
50 , m_nTargetState( -1 )
51 , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE
)
52 , m_xContext( rxContext
)
54 , m_bEmbeddedScriptSupport( true )
55 , m_bDocumentRecoverySupport( true )
56 , m_bWaitSaveCompleted( false )
58 , m_bLinkHasPassword( false )
59 , m_bHasClonedSize( false )
60 , m_nClonedMapUnit( 0 )
62 CommonInit_Impl( aObjProps
);
66 OCommonEmbeddedObject::OCommonEmbeddedObject(
67 const uno::Reference
< uno::XComponentContext
>& rxContext
,
68 const uno::Sequence
< beans::NamedValue
>& aObjProps
,
69 const uno::Sequence
< beans::PropertyValue
>& aMediaDescr
,
70 const uno::Sequence
< beans::PropertyValue
>& aObjectDescr
)
71 : m_pDocHolder( NULL
)
72 , m_pInterfaceContainer( NULL
)
73 , m_bReadOnly( false )
74 , m_bDisposed( false )
76 , m_nObjectState( embed::EmbedStates::LOADED
)
77 , m_nTargetState( -1 )
78 , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE
)
79 , m_xContext( rxContext
)
81 , m_bEmbeddedScriptSupport( true )
82 , m_bDocumentRecoverySupport( true )
83 , m_bWaitSaveCompleted( false )
85 , m_bLinkHasPassword( false )
86 , m_bHasClonedSize( false )
87 , m_nClonedMapUnit( 0 )
89 // linked object has no own persistence so it is in loaded state starting from creation
90 LinkInit_Impl( aObjProps
, aMediaDescr
, aObjectDescr
);
94 void OCommonEmbeddedObject::CommonInit_Impl( const uno::Sequence
< beans::NamedValue
>& aObjectProps
)
96 OSL_ENSURE( m_xContext
.is(), "No ServiceFactory is provided!\n" );
97 if ( !m_xContext
.is() )
98 throw uno::RuntimeException();
100 m_pDocHolder
= new DocumentHolder( m_xContext
, this );
101 m_pDocHolder
->acquire();
103 // parse configuration entries
104 // TODO/LATER: in future UI names can be also provided here
105 for ( sal_Int32 nInd
= 0; nInd
< aObjectProps
.getLength(); nInd
++ )
107 if ( aObjectProps
[nInd
].Name
== "ClassID" )
108 aObjectProps
[nInd
].Value
>>= m_aClassID
;
109 else if ( aObjectProps
[nInd
].Name
== "ObjectDocumentServiceName" )
110 aObjectProps
[nInd
].Value
>>= m_aDocServiceName
;
111 else if ( aObjectProps
[nInd
].Name
== "ObjectDocumentFilterName" )
112 aObjectProps
[nInd
].Value
>>= m_aPresetFilterName
;
113 else if ( aObjectProps
[nInd
].Name
== "ObjectMiscStatus" )
114 aObjectProps
[nInd
].Value
>>= m_nMiscStatus
;
115 else if ( aObjectProps
[nInd
].Name
== "ObjectVerbs" )
116 aObjectProps
[nInd
].Value
>>= m_aObjectVerbs
;
119 if ( m_aClassID
.getLength() != 16 /*|| !m_aDocServiceName.getLength()*/ )
120 throw uno::RuntimeException(); // something goes really wrong
123 m_aAcceptedStates
.realloc( NUM_SUPPORTED_STATES
);
125 m_aAcceptedStates
[0] = embed::EmbedStates::LOADED
;
126 m_aAcceptedStates
[1] = embed::EmbedStates::RUNNING
;
127 m_aAcceptedStates
[2] = embed::EmbedStates::INPLACE_ACTIVE
;
128 m_aAcceptedStates
[3] = embed::EmbedStates::UI_ACTIVE
;
129 m_aAcceptedStates
[4] = embed::EmbedStates::ACTIVE
;
132 // intermediate states
133 // In the following table the first index points to starting state,
134 // the second one to the target state, and the sequence referenced by
135 // first two indexes contains intermediate states, that should be
136 // passed by object to reach the target state.
137 // If the sequence is empty that means that indirect switch from start
138 // state to the target state is forbidden, only if direct switch is possible
139 // the state can be reached.
141 m_pIntermediateStatesSeqs
[0][2].realloc( 1 );
142 m_pIntermediateStatesSeqs
[0][2][0] = embed::EmbedStates::RUNNING
;
144 m_pIntermediateStatesSeqs
[0][3].realloc( 2 );
145 m_pIntermediateStatesSeqs
[0][3][0] = embed::EmbedStates::RUNNING
;
146 m_pIntermediateStatesSeqs
[0][3][1] = embed::EmbedStates::INPLACE_ACTIVE
;
148 m_pIntermediateStatesSeqs
[0][4].realloc( 1 );
149 m_pIntermediateStatesSeqs
[0][4][0] = embed::EmbedStates::RUNNING
;
151 m_pIntermediateStatesSeqs
[1][3].realloc( 1 );
152 m_pIntermediateStatesSeqs
[1][3][0] = embed::EmbedStates::INPLACE_ACTIVE
;
154 m_pIntermediateStatesSeqs
[2][0].realloc( 1 );
155 m_pIntermediateStatesSeqs
[2][0][0] = embed::EmbedStates::RUNNING
;
157 m_pIntermediateStatesSeqs
[3][0].realloc( 2 );
158 m_pIntermediateStatesSeqs
[3][0][0] = embed::EmbedStates::INPLACE_ACTIVE
;
159 m_pIntermediateStatesSeqs
[3][0][1] = embed::EmbedStates::RUNNING
;
161 m_pIntermediateStatesSeqs
[3][1].realloc( 1 );
162 m_pIntermediateStatesSeqs
[3][1][0] = embed::EmbedStates::INPLACE_ACTIVE
;
164 m_pIntermediateStatesSeqs
[4][0].realloc( 1 );
165 m_pIntermediateStatesSeqs
[4][0][0] = embed::EmbedStates::RUNNING
;
168 sal_Int32 nVerbTableSize
= 0;
169 for ( sal_Int32 nVerbInd
= 0; nVerbInd
< m_aObjectVerbs
.getLength(); nVerbInd
++ )
171 if ( m_aObjectVerbs
[nVerbInd
].VerbID
== embed::EmbedVerbs::MS_OLEVERB_PRIMARY
)
173 m_aVerbTable
.realloc( ++nVerbTableSize
);
174 m_aVerbTable
[nVerbTableSize
- 1].realloc( 2 );
175 m_aVerbTable
[nVerbTableSize
- 1][0] = m_aObjectVerbs
[nVerbInd
].VerbID
;
176 m_aVerbTable
[nVerbTableSize
- 1][1] = embed::EmbedStates::UI_ACTIVE
;
178 else if ( m_aObjectVerbs
[nVerbInd
].VerbID
== embed::EmbedVerbs::MS_OLEVERB_SHOW
)
180 m_aVerbTable
.realloc( ++nVerbTableSize
);
181 m_aVerbTable
[nVerbTableSize
- 1].realloc( 2 );
182 m_aVerbTable
[nVerbTableSize
- 1][0] = m_aObjectVerbs
[nVerbInd
].VerbID
;
183 m_aVerbTable
[nVerbTableSize
- 1][1] = embed::EmbedStates::UI_ACTIVE
;
185 else if ( m_aObjectVerbs
[nVerbInd
].VerbID
== embed::EmbedVerbs::MS_OLEVERB_OPEN
)
187 m_aVerbTable
.realloc( ++nVerbTableSize
);
188 m_aVerbTable
[nVerbTableSize
- 1].realloc( 2 );
189 m_aVerbTable
[nVerbTableSize
- 1][0] = m_aObjectVerbs
[nVerbInd
].VerbID
;
190 m_aVerbTable
[nVerbTableSize
- 1][1] = embed::EmbedStates::ACTIVE
;
192 else if ( m_aObjectVerbs
[nVerbInd
].VerbID
== embed::EmbedVerbs::MS_OLEVERB_IPACTIVATE
)
194 m_aVerbTable
.realloc( ++nVerbTableSize
);
195 m_aVerbTable
[nVerbTableSize
- 1].realloc( 2 );
196 m_aVerbTable
[nVerbTableSize
- 1][0] = m_aObjectVerbs
[nVerbInd
].VerbID
;
197 m_aVerbTable
[nVerbTableSize
- 1][1] = embed::EmbedStates::INPLACE_ACTIVE
;
199 else if ( m_aObjectVerbs
[nVerbInd
].VerbID
== embed::EmbedVerbs::MS_OLEVERB_UIACTIVATE
)
201 m_aVerbTable
.realloc( ++nVerbTableSize
);
202 m_aVerbTable
[nVerbTableSize
- 1].realloc( 2 );
203 m_aVerbTable
[nVerbTableSize
- 1][0] = m_aObjectVerbs
[nVerbInd
].VerbID
;
204 m_aVerbTable
[nVerbTableSize
- 1][1] = embed::EmbedStates::UI_ACTIVE
;
206 else if ( m_aObjectVerbs
[nVerbInd
].VerbID
== embed::EmbedVerbs::MS_OLEVERB_HIDE
)
208 m_aVerbTable
.realloc( ++nVerbTableSize
);
209 m_aVerbTable
[nVerbTableSize
- 1].realloc( 2 );
210 m_aVerbTable
[nVerbTableSize
- 1][0] = m_aObjectVerbs
[nVerbInd
].VerbID
;
211 m_aVerbTable
[nVerbTableSize
- 1][1] = embed::EmbedStates::RUNNING
;
217 void OCommonEmbeddedObject::LinkInit_Impl(
218 const uno::Sequence
< beans::NamedValue
>& aObjectProps
,
219 const uno::Sequence
< beans::PropertyValue
>& aMediaDescr
,
220 const uno::Sequence
< beans::PropertyValue
>& aObjectDescr
)
222 // setPersistance has no effect on own links, so the complete initialization must be done here
224 for ( sal_Int32 nInd
= 0; nInd
< aMediaDescr
.getLength(); nInd
++ )
225 if ( aMediaDescr
[nInd
].Name
== "URL" )
226 aMediaDescr
[nInd
].Value
>>= m_aLinkURL
;
227 else if ( aMediaDescr
[nInd
].Name
== "FilterName" )
228 aMediaDescr
[nInd
].Value
>>= m_aLinkFilterName
;
230 OSL_ENSURE( m_aLinkURL
.getLength() && m_aLinkFilterName
.getLength(), "Filter and URL must be provided!\n" );
233 if ( m_aLinkFilterName
.getLength() )
235 ::comphelper::MimeConfigurationHelper
aHelper( m_xContext
);
236 OUString aExportFilterName
= aHelper
.GetExportFilterFromImportFilter( m_aLinkFilterName
);
237 m_bReadOnly
= !( aExportFilterName
.equals( m_aLinkFilterName
) );
240 m_aDocMediaDescriptor
= GetValuableArgs_Impl( aMediaDescr
, false );
242 uno::Reference
< frame::XDispatchProviderInterceptor
> xDispatchInterceptor
;
243 for ( sal_Int32 nObjInd
= 0; nObjInd
< aObjectDescr
.getLength(); nObjInd
++ )
244 if ( aObjectDescr
[nObjInd
].Name
== "OutplaceDispatchInterceptor" )
246 aObjectDescr
[nObjInd
].Value
>>= xDispatchInterceptor
;
249 else if ( aObjectDescr
[nObjInd
].Name
== "Parent" )
251 aObjectDescr
[nObjInd
].Value
>>= m_xParent
;
254 CommonInit_Impl( aObjectProps
);
256 if ( xDispatchInterceptor
.is() )
257 m_pDocHolder
->SetOutplaceDispatchInterceptor( xDispatchInterceptor
);
261 OCommonEmbeddedObject::~OCommonEmbeddedObject()
263 if ( m_pInterfaceContainer
|| m_pDocHolder
)
267 lang::EventObject
aSource( static_cast< ::cppu::OWeakObject
* >( this ) );
269 if ( m_pInterfaceContainer
)
271 m_pInterfaceContainer
->disposeAndClear( aSource
);
273 delete m_pInterfaceContainer
;
274 m_pInterfaceContainer
= NULL
;
276 } catch( const uno::Exception
& ) {}
281 m_pDocHolder
->CloseFrame();
283 m_pDocHolder
->CloseDocument( true, true );
284 } catch ( const uno::Exception
& ) {}
285 m_pDocHolder
->FreeOffice();
287 m_pDocHolder
->release();
290 } catch( const uno::Exception
& ) {}
295 void OCommonEmbeddedObject::requestPositioning( const awt::Rectangle
& aRect
)
297 // the method is called in case object is inplace active and the object window was resized
299 OSL_ENSURE( m_xClientSite
.is(), "The client site must be set for inplace active object!\n" );
300 if ( m_xClientSite
.is() )
302 uno::Reference
< embed::XInplaceClient
> xInplaceClient( m_xClientSite
, uno::UNO_QUERY
);
304 OSL_ENSURE( xInplaceClient
.is(), "The client site must support XInplaceClient to allow inplace activation!\n" );
305 if ( xInplaceClient
.is() )
308 xInplaceClient
->changedPlacement( aRect
);
310 catch( const uno::Exception
& )
312 OSL_FAIL( "Exception on request to resize!\n" );
319 void OCommonEmbeddedObject::PostEvent_Impl( const OUString
& aEventName
)
321 if ( m_pInterfaceContainer
)
323 ::cppu::OInterfaceContainerHelper
* pIC
= m_pInterfaceContainer
->getContainer(
324 cppu::UnoType
<document::XEventListener
>::get());
327 document::EventObject aEvent
;
328 aEvent
.EventName
= aEventName
;
329 aEvent
.Source
= uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >( this ) );
330 // For now all the events are sent as object events
331 // aEvent.Source = ( xSource.is() ? xSource
332 // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) );
333 ::cppu::OInterfaceIteratorHelper
aIt( *pIC
);
334 while( aIt
.hasMoreElements() )
338 static_cast<document::XEventListener
*>(aIt
.next())->notifyEvent( aEvent
);
340 catch( const uno::RuntimeException
& )
345 // the listener could dispose the object.
354 uno::Any SAL_CALL
OCommonEmbeddedObject::queryInterface( const uno::Type
& rType
)
355 throw( uno::RuntimeException
, std::exception
)
359 if ( rType
== cppu::UnoType
<embed::XEmbeddedObject
>::get() )
361 void * p
= static_cast< embed::XEmbeddedObject
* >( this );
362 return uno::Any( &p
, rType
);
364 else if (rType
== cppu::UnoType
<embed::XEmbedPersist2
>::get())
366 void* p
= static_cast<embed::XEmbedPersist2
*>(this);
367 return uno::Any(&p
, rType
);
370 aReturn
<<= ::cppu::queryInterface(
372 static_cast< embed::XInplaceObject
* >( this ),
373 static_cast< embed::XVisualObject
* >( this ),
374 static_cast< embed::XCommonEmbedPersist
* >( static_cast< embed::XEmbedPersist
* >( this ) ),
375 static_cast< embed::XEmbedPersist
* >( this ),
376 static_cast< embed::XLinkageSupport
* >( this ),
377 static_cast< embed::XStateChangeBroadcaster
* >( this ),
378 static_cast< embed::XClassifiedObject
* >( this ),
379 static_cast< embed::XComponentSupplier
* >( this ),
380 static_cast< util::XCloseable
* >( this ),
381 static_cast< container::XChild
* >( this ),
382 static_cast< chart2::XDefaultSizeTransmitter
* >( this ),
383 static_cast< document::XEventBroadcaster
* >( this ) );
385 if ( aReturn
.hasValue() )
388 return ::cppu::OWeakObject::queryInterface( rType
) ;
393 void SAL_CALL
OCommonEmbeddedObject::acquire()
396 ::cppu::OWeakObject::acquire() ;
400 void SAL_CALL
OCommonEmbeddedObject::release()
403 ::cppu::OWeakObject::release() ;
407 uno::Sequence
< uno::Type
> SAL_CALL
OCommonEmbeddedObject::getTypes()
408 throw( uno::RuntimeException
)
410 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
412 if ( !pTypeCollection
)
414 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
415 if ( !pTypeCollection
)
419 static ::cppu::OTypeCollection
aTypeCollection(
420 cppu::UnoType
<lang::XTypeProvider
>::get(),
421 cppu::UnoType
<embed::XEmbeddedObject
>::get(),
422 cppu::UnoType
<embed::XInplaceObject
>::get(),
423 cppu::UnoType
<embed::XCommonEmbedPersist
>::get(),
424 cppu::UnoType
<container::XChild
>::get(),
425 cppu::UnoType
<embed::XLinkageSupport
>::get());
427 pTypeCollection
= &aTypeCollection
;
431 static ::cppu::OTypeCollection
aTypeCollection(
432 cppu::UnoType
<lang::XTypeProvider
>::get(),
433 cppu::UnoType
<embed::XEmbeddedObject
>::get(),
434 cppu::UnoType
<embed::XInplaceObject
>::get(),
435 cppu::UnoType
<embed::XCommonEmbedPersist
>::get(),
436 cppu::UnoType
<container::XChild
>::get(),
437 cppu::UnoType
<embed::XEmbedPersist
>::get(),
438 cppu::UnoType
<embed::XEmbedPersist2
>::get());
440 pTypeCollection
= &aTypeCollection
;
445 return pTypeCollection
->getTypes() ;
449 uno::Sequence
< sal_Int8
> SAL_CALL
OCommonEmbeddedObject::getClassID()
450 throw ( uno::RuntimeException
, std::exception
)
453 throw lang::DisposedException();
458 OUString SAL_CALL
OCommonEmbeddedObject::getClassName()
459 throw ( uno::RuntimeException
, std::exception
)
462 throw lang::DisposedException();
467 void SAL_CALL
OCommonEmbeddedObject::setClassInfo(
468 const uno::Sequence
< sal_Int8
>& /*aClassID*/, const OUString
& /*aClassName*/ )
469 throw ( lang::NoSupportException
,
470 uno::RuntimeException
, std::exception
)
472 // the object class info can not be changed explicitly
473 throw lang::NoSupportException(); //TODO:
477 uno::Reference
< util::XCloseable
> SAL_CALL
OCommonEmbeddedObject::getComponent()
478 throw ( uno::RuntimeException
, std::exception
)
480 ::osl::MutexGuard
aGuard( m_aMutex
);
482 throw lang::DisposedException(); // TODO
485 if ( m_nObjectState
== -1 )
487 // the object is still not loaded
488 throw uno::RuntimeException( "Can't store object without persistence!",
489 static_cast< ::cppu::OWeakObject
* >(this) );
492 return uno::Reference
< util::XCloseable
>( m_pDocHolder
->GetComponent(), uno::UNO_QUERY
);
496 void SAL_CALL
OCommonEmbeddedObject::addStateChangeListener( const uno::Reference
< embed::XStateChangeListener
>& xListener
)
497 throw ( uno::RuntimeException
, std::exception
)
499 ::osl::MutexGuard
aGuard( m_aMutex
);
501 throw lang::DisposedException(); // TODO
503 if ( !m_pInterfaceContainer
)
504 m_pInterfaceContainer
= new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex
);
506 m_pInterfaceContainer
->addInterface( cppu::UnoType
<embed::XStateChangeListener
>::get(),
511 void SAL_CALL
OCommonEmbeddedObject::removeStateChangeListener(
512 const uno::Reference
< embed::XStateChangeListener
>& xListener
)
513 throw (uno::RuntimeException
, std::exception
)
515 ::osl::MutexGuard
aGuard( m_aMutex
);
516 if ( m_pInterfaceContainer
)
517 m_pInterfaceContainer
->removeInterface( cppu::UnoType
<embed::XStateChangeListener
>::get(),
522 void SAL_CALL
OCommonEmbeddedObject::close( sal_Bool bDeliverOwnership
)
523 throw ( util::CloseVetoException
,
524 uno::RuntimeException
, std::exception
)
526 ::osl::MutexGuard
aGuard( m_aMutex
);
528 throw lang::DisposedException(); // TODO
530 uno::Reference
< uno::XInterface
> xSelfHold( static_cast< ::cppu::OWeakObject
* >( this ) );
531 lang::EventObject
aSource( static_cast< ::cppu::OWeakObject
* >( this ) );
533 if ( m_pInterfaceContainer
)
535 ::cppu::OInterfaceContainerHelper
* pContainer
=
536 m_pInterfaceContainer
->getContainer( cppu::UnoType
<util::XCloseListener
>::get());
537 if ( pContainer
!= NULL
)
539 ::cppu::OInterfaceIteratorHelper
pIterator(*pContainer
);
540 while (pIterator
.hasMoreElements())
544 static_cast<util::XCloseListener
*>(pIterator
.next())->queryClosing( aSource
, bDeliverOwnership
);
546 catch( const uno::RuntimeException
& )
553 pContainer
= m_pInterfaceContainer
->getContainer(
554 cppu::UnoType
<util::XCloseListener
>::get());
555 if ( pContainer
!= NULL
)
557 ::cppu::OInterfaceIteratorHelper
pCloseIterator(*pContainer
);
558 while (pCloseIterator
.hasMoreElements())
562 static_cast<util::XCloseListener
*>(pCloseIterator
.next())->notifyClosing( aSource
);
564 catch( const uno::RuntimeException
& )
566 pCloseIterator
.remove();
571 m_pInterfaceContainer
->disposeAndClear( aSource
);
574 m_bDisposed
= true; // the object is disposed now for outside
576 // it is possible that the document can not be closed, in this case if the argument is false
577 // the exception will be thrown otherwise in addition to exception the object must register itself
578 // as termination listener and listen for document events
582 m_pDocHolder
->CloseFrame();
585 m_pDocHolder
->CloseDocument( bDeliverOwnership
, bDeliverOwnership
);
587 catch( const uno::Exception
& )
589 if ( bDeliverOwnership
)
591 m_pDocHolder
->release();
599 m_pDocHolder
->FreeOffice();
601 m_pDocHolder
->release();
605 // TODO: for now the storage will be disposed by the object, but after the document
606 // will use the storage, the storage will be disposed by the document and recreated by the object
607 if ( m_xObjectStorage
.is() )
609 uno::Reference
< lang::XComponent
> xComp( m_xObjectStorage
, uno::UNO_QUERY
);
610 OSL_ENSURE( xComp
.is(), "Storage does not support XComponent!\n" );
616 } catch ( const uno::Exception
& ) {}
619 m_xObjectStorage
.clear();
620 m_xRecoveryStorage
.clear();
623 m_bClosed
= true; // the closing succeeded
627 void SAL_CALL
OCommonEmbeddedObject::addCloseListener( const uno::Reference
< util::XCloseListener
>& xListener
)
628 throw ( uno::RuntimeException
, std::exception
)
630 ::osl::MutexGuard
aGuard( m_aMutex
);
632 throw lang::DisposedException(); // TODO
634 if ( !m_pInterfaceContainer
)
635 m_pInterfaceContainer
= new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex
);
637 m_pInterfaceContainer
->addInterface( cppu::UnoType
<util::XCloseListener
>::get(), xListener
);
641 void SAL_CALL
OCommonEmbeddedObject::removeCloseListener( const uno::Reference
< util::XCloseListener
>& xListener
)
642 throw (uno::RuntimeException
, std::exception
)
644 ::osl::MutexGuard
aGuard( m_aMutex
);
645 if ( m_pInterfaceContainer
)
646 m_pInterfaceContainer
->removeInterface( cppu::UnoType
<util::XCloseListener
>::get(),
651 void SAL_CALL
OCommonEmbeddedObject::addEventListener( const uno::Reference
< document::XEventListener
>& xListener
)
652 throw ( uno::RuntimeException
, std::exception
)
654 ::osl::MutexGuard
aGuard( m_aMutex
);
656 throw lang::DisposedException(); // TODO
658 if ( !m_pInterfaceContainer
)
659 m_pInterfaceContainer
= new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex
);
661 m_pInterfaceContainer
->addInterface( cppu::UnoType
<document::XEventListener
>::get(), xListener
);
665 void SAL_CALL
OCommonEmbeddedObject::removeEventListener( const uno::Reference
< document::XEventListener
>& xListener
)
666 throw ( uno::RuntimeException
, std::exception
)
668 ::osl::MutexGuard
aGuard( m_aMutex
);
669 if ( m_pInterfaceContainer
)
670 m_pInterfaceContainer
->removeInterface( cppu::UnoType
<document::XEventListener
>::get(),
674 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */