Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/embed/EmbedUpdateModes.hpp>
30 : : #include <com/sun/star/embed/EmbedStates.hpp>
31 : : #include <com/sun/star/lang/XComponent.hpp>
32 : : #include <com/sun/star/lang/DisposedException.hpp>
33 : :
34 : : #include <cppuhelper/interfacecontainer.h>
35 : :
36 : : #include <oleembobj.hxx>
37 : : #include <olecomponent.hxx>
38 : :
39 : : #include "ownview.hxx"
40 : :
41 : : using namespace ::com::sun::star;
42 : :
43 : : sal_Bool KillFile_Impl( const ::rtl::OUString& aURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory );
44 : :
45 : :
46 : : //------------------------------------------------------
47 : 0 : OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory,
48 : : const uno::Sequence< sal_Int8 >& aClassID,
49 : : const ::rtl::OUString& aClassName )
50 : : : m_pOleComponent( NULL )
51 : : , m_pInterfaceContainer( NULL )
52 : : , m_bReadOnly( sal_False )
53 : : , m_bDisposed( sal_False )
54 : : , m_nObjectState( -1 )
55 : : , m_nTargetState( -1 )
56 : : , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE )
57 : : , m_xFactory( xFactory )
58 : : , m_aClassID( aClassID )
59 : : , m_aClassName( aClassName )
60 : : , m_bWaitSaveCompleted( sal_False )
61 : : , m_bNewVisReplInStream( sal_True )
62 : : , m_bStoreLoaded( sal_False )
63 : : , m_bVisReplInitialized( sal_False )
64 : : , m_bVisReplInStream( sal_False )
65 : : , m_bStoreVisRepl( sal_False )
66 : : , m_bIsLink( sal_False )
67 : : , m_bHasCachedSize( sal_False )
68 : : , m_nCachedAspect( 0 )
69 : : , m_bHasSizeToSet( sal_False )
70 : : , m_nAspectToSet( 0 )
71 : : , m_bGotStatus( sal_False )
72 : : , m_nStatus( 0 )
73 : : , m_nStatusAspect( 0 )
74 : : , m_pOwnView( NULL )
75 : : , m_bFromClipboard( sal_False )
76 [ # # ][ # # ]: 0 : , m_bTriedConversion( sal_False )
[ # # ]
77 : : {
78 : 0 : }
79 : :
80 : : //------------------------------------------------------
81 : : // In case of loading from persistent entry the classID of the object
82 : : // will be retrieved from the entry, during construction it is unknown
83 : 0 : OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, sal_Bool bLink )
84 : : : m_pOleComponent( NULL )
85 : : , m_pInterfaceContainer( NULL )
86 : : , m_bReadOnly( sal_False )
87 : : , m_bDisposed( sal_False )
88 : : , m_nObjectState( -1 )
89 : : , m_nTargetState( -1 )
90 : : , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE )
91 : : , m_xFactory( xFactory )
92 : : , m_bWaitSaveCompleted( sal_False )
93 : : , m_bNewVisReplInStream( sal_True )
94 : : , m_bStoreLoaded( sal_False )
95 : : , m_bVisReplInitialized( sal_False )
96 : : , m_bVisReplInStream( sal_False )
97 : : , m_bStoreVisRepl( sal_False )
98 : : , m_bIsLink( bLink )
99 : : , m_bHasCachedSize( sal_False )
100 : : , m_nCachedAspect( 0 )
101 : : , m_bHasSizeToSet( sal_False )
102 : : , m_nAspectToSet( 0 )
103 : : , m_bGotStatus( sal_False )
104 : : , m_nStatus( 0 )
105 : : , m_nStatusAspect( 0 )
106 : : , m_pOwnView( NULL )
107 : : , m_bFromClipboard( sal_False )
108 [ # # ][ # # ]: 0 : , m_bTriedConversion( sal_False )
[ # # ]
109 : : {
110 : 0 : }
111 : : #ifdef WNT
112 : : //------------------------------------------------------
113 : : // this constructor let object be initialized from clipboard
114 : : OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
115 : : : m_pOleComponent( NULL )
116 : : , m_pInterfaceContainer( NULL )
117 : : , m_bReadOnly( sal_False )
118 : : , m_bDisposed( sal_False )
119 : : , m_nObjectState( -1 )
120 : : , m_nTargetState( -1 )
121 : : , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE )
122 : : , m_xFactory( xFactory )
123 : : , m_bWaitSaveCompleted( sal_False )
124 : : , m_bNewVisReplInStream( sal_True )
125 : : , m_bStoreLoaded( sal_False )
126 : : , m_bVisReplInitialized( sal_False )
127 : : , m_bVisReplInStream( sal_False )
128 : : , m_bStoreVisRepl( sal_False )
129 : : , m_bIsLink( sal_False )
130 : : , m_bHasCachedSize( sal_False )
131 : : , m_nCachedAspect( 0 )
132 : : , m_bHasSizeToSet( sal_False )
133 : : , m_nAspectToSet( 0 )
134 : : , m_bGotStatus( sal_False )
135 : : , m_nStatus( 0 )
136 : : , m_nStatusAspect( 0 )
137 : : , m_pOwnView( NULL )
138 : : , m_bFromClipboard( sal_True )
139 : : , m_bTriedConversion( sal_False )
140 : : {
141 : : }
142 : : #endif
143 : : //------------------------------------------------------
144 [ # # ][ # # ]: 0 : OleEmbeddedObject::~OleEmbeddedObject()
[ # # ]
145 : : {
146 : : OSL_ENSURE( !m_pInterfaceContainer && !m_pOleComponent && !m_xObjectStream.is(),
147 : : "The object is not closed! DISASTER is possible!" );
148 : :
149 [ # # ][ # # ]: 0 : if ( m_pOleComponent || m_pInterfaceContainer || m_xObjectStream.is() )
[ # # ][ # # ]
150 : : {
151 : : // the component must be cleaned during closing
152 : 0 : m_refCount++; // to avoid crash
153 : : try {
154 [ # # ]: 0 : Dispose();
155 [ # # ]: 0 : } catch( const uno::Exception& ) {}
156 : : }
157 : :
158 [ # # ]: 0 : if ( !m_aTempURL.isEmpty() )
159 [ # # ]: 0 : KillFile_Impl( m_aTempURL, m_xFactory );
160 : :
161 [ # # ]: 0 : if ( !m_aTempDumpURL.isEmpty() )
162 [ # # ]: 0 : KillFile_Impl( m_aTempDumpURL, m_xFactory );
163 [ # # ][ # # ]: 0 : }
164 : :
165 : : //------------------------------------------------------
166 : 0 : void OleEmbeddedObject::MakeEventListenerNotification_Impl( const ::rtl::OUString& aEventName )
167 : : {
168 [ # # ]: 0 : if ( m_pInterfaceContainer )
169 : : {
170 : : ::cppu::OInterfaceContainerHelper* pContainer =
171 : : m_pInterfaceContainer->getContainer(
172 : 0 : ::getCppuType( ( const uno::Reference< document::XEventListener >*) NULL ) );
173 [ # # ]: 0 : if ( pContainer != NULL )
174 : : {
175 [ # # ][ # # ]: 0 : document::EventObject aEvent( static_cast< ::cppu::OWeakObject* >( this ), aEventName );
[ # # ]
176 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
177 [ # # ]: 0 : while (pIterator.hasMoreElements())
178 : : {
179 : : try
180 : : {
181 [ # # ][ # # ]: 0 : ((document::XEventListener*)pIterator.next())->notifyEvent( aEvent );
182 : : }
183 [ # # ]: 0 : catch( const uno::RuntimeException& )
184 : : {
185 : : }
186 [ # # ][ # # ]: 0 : }
187 : : }
188 : : }
189 : 0 : }
190 : : #ifdef WNT
191 : : //----------------------------------------------
192 : : void OleEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState )
193 : : {
194 : : if ( m_pInterfaceContainer )
195 : : {
196 : : ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer(
197 : : ::getCppuType( ( const uno::Reference< embed::XStateChangeListener >*) NULL ) );
198 : : if ( pContainer != NULL )
199 : : {
200 : : lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
201 : : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
202 : :
203 : : while (pIterator.hasMoreElements())
204 : : {
205 : : if ( bBeforeChange )
206 : : {
207 : : try
208 : : {
209 : : ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState );
210 : : }
211 : : catch( const uno::Exception& )
212 : : {
213 : : // even if the listener complains ignore it for now
214 : : }
215 : : }
216 : : else
217 : : {
218 : : try
219 : : {
220 : : ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState );
221 : : }
222 : : catch( const uno::Exception& )
223 : : {
224 : : // if anything happened it is problem of listener, ignore it
225 : : }
226 : : }
227 : : }
228 : : }
229 : : }
230 : : }
231 : : #endif
232 : : //------------------------------------------------------
233 : 0 : void OleEmbeddedObject::GetRidOfComponent()
234 : : {
235 : : #ifdef WNT
236 : : if ( m_pOleComponent )
237 : : {
238 : : if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
239 : : SaveObject_Impl();
240 : :
241 : : m_pOleComponent->removeCloseListener( m_xClosePreventer );
242 : : try
243 : : {
244 : : m_pOleComponent->close( sal_False );
245 : : }
246 : : catch( const uno::Exception& )
247 : : {
248 : : // TODO: there should be a special listener to wait for component closing
249 : : // and to notify object, may be object itself can be such a listener
250 : : m_pOleComponent->addCloseListener( m_xClosePreventer );
251 : : throw;
252 : : }
253 : :
254 : : m_pOleComponent->disconnectEmbeddedObject();
255 : : m_pOleComponent->release();
256 : : m_pOleComponent = NULL;
257 : : }
258 : : #endif
259 : 0 : }
260 : :
261 : : //------------------------------------------------------
262 : 0 : void OleEmbeddedObject::Dispose()
263 : : {
264 [ # # ]: 0 : if ( m_pInterfaceContainer )
265 : : {
266 [ # # ][ # # ]: 0 : lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
267 [ # # ]: 0 : m_pInterfaceContainer->disposeAndClear( aSource );
268 [ # # ][ # # ]: 0 : delete m_pInterfaceContainer;
269 [ # # ][ # # ]: 0 : m_pInterfaceContainer = NULL;
270 : : }
271 : :
272 [ # # ]: 0 : if ( m_pOwnView )
273 : : {
274 : 0 : m_pOwnView->Close();
275 : 0 : m_pOwnView->release();
276 : 0 : m_pOwnView = NULL;
277 : : }
278 : :
279 [ # # ]: 0 : if ( m_pOleComponent )
280 : : try {
281 : 0 : GetRidOfComponent();
282 : : } catch( const uno::Exception& )
283 : : {
284 : : m_bDisposed = true;
285 : : throw; // TODO: there should be a special listener that will close object when
286 : : // component is finally closed
287 : : }
288 : :
289 [ # # ]: 0 : if ( m_xObjectStream.is() )
290 : : {
291 [ # # ]: 0 : uno::Reference< lang::XComponent > xComp( m_xObjectStream, uno::UNO_QUERY );
292 : : OSL_ENSURE( xComp.is(), "Storage stream doesn't support XComponent!\n" );
293 : :
294 [ # # ]: 0 : if ( xComp.is() )
295 : : {
296 : : try {
297 [ # # ][ # # ]: 0 : xComp->dispose();
298 [ # # ]: 0 : } catch( const uno::Exception& ) {}
299 : : }
300 [ # # ]: 0 : m_xObjectStream = uno::Reference< io::XStream >();
301 : : }
302 : :
303 [ # # ]: 0 : m_xParentStorage = uno::Reference< embed::XStorage >();
304 : :
305 : 0 : m_bDisposed = true;
306 : 0 : }
307 : :
308 : : //------------------------------------------------------
309 : 0 : uno::Sequence< sal_Int8 > SAL_CALL OleEmbeddedObject::getClassID()
310 : : throw ( uno::RuntimeException )
311 : : {
312 : : // begin wrapping related part ====================
313 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
314 [ # # ]: 0 : if ( xWrappedObject.is() )
315 : : {
316 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
317 [ # # ][ # # ]: 0 : return xWrappedObject->getClassID();
318 : : }
319 : : // end wrapping related part ====================
320 : :
321 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
322 [ # # ]: 0 : if ( m_bDisposed )
323 [ # # ]: 0 : throw lang::DisposedException(); // TODO
324 : :
325 [ # # ][ # # ]: 0 : return m_aClassID;
326 : : }
327 : :
328 : : //------------------------------------------------------
329 : 0 : ::rtl::OUString SAL_CALL OleEmbeddedObject::getClassName()
330 : : throw ( uno::RuntimeException )
331 : : {
332 : : // begin wrapping related part ====================
333 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
334 [ # # ]: 0 : if ( xWrappedObject.is() )
335 : : {
336 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
337 [ # # ][ # # ]: 0 : return xWrappedObject->getClassName();
338 : : }
339 : : // end wrapping related part ====================
340 : :
341 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
342 [ # # ]: 0 : if ( m_bDisposed )
343 [ # # ]: 0 : throw lang::DisposedException(); // TODO
344 : :
345 [ # # ]: 0 : return m_aClassName;
346 : : }
347 : :
348 : : //------------------------------------------------------
349 : 0 : void SAL_CALL OleEmbeddedObject::setClassInfo(
350 : : const uno::Sequence< sal_Int8 >& aClassID, const ::rtl::OUString& aClassName )
351 : : throw ( lang::NoSupportException,
352 : : uno::RuntimeException )
353 : : {
354 : : // begin wrapping related part ====================
355 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
356 [ # # ]: 0 : if ( xWrappedObject.is() )
357 : : {
358 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
359 [ # # ][ # # ]: 0 : xWrappedObject->setClassInfo( aClassID, aClassName );
360 : 0 : return;
361 : : }
362 : : // end wrapping related part ====================
363 : :
364 : : // the object class info can not be changed explicitly
365 [ # # ]: 0 : throw lang::NoSupportException(); //TODO:
366 : : }
367 : :
368 : : //------------------------------------------------------
369 : 0 : uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent()
370 : : throw ( uno::RuntimeException )
371 : : {
372 : : // begin wrapping related part ====================
373 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
374 [ # # ]: 0 : if ( xWrappedObject.is() )
375 : : {
376 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
377 [ # # ][ # # ]: 0 : return xWrappedObject->getComponent();
378 : : }
379 : : // end wrapping related part ====================
380 : :
381 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
382 [ # # ]: 0 : if ( m_bDisposed )
383 [ # # ]: 0 : throw lang::DisposedException(); // TODO
384 : :
385 [ # # ]: 0 : if ( m_nObjectState == -1 ) // || m_nObjectState == embed::EmbedStates::LOADED )
386 : : {
387 : : // the object is still not running
388 : : throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object is not loaded!\n" )),
389 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
[ # # ]
390 : : }
391 : :
392 [ # # ]: 0 : if ( !m_pOleComponent )
393 : : {
394 : : // TODO/LATER: Is it correct???
395 : 0 : return uno::Reference< util::XCloseable >();
396 : : // throw uno::RuntimeException(); // TODO
397 : : }
398 : :
399 [ # # ][ # # ]: 0 : return uno::Reference< util::XCloseable >( static_cast< ::cppu::OWeakObject* >( m_pOleComponent ), uno::UNO_QUERY );
400 : : }
401 : :
402 : : //----------------------------------------------
403 : 0 : void SAL_CALL OleEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
404 : : throw ( uno::RuntimeException )
405 : : {
406 : : // begin wrapping related part ====================
407 [ # # ]: 0 : uno::Reference< embed::XStateChangeBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
408 [ # # ]: 0 : if ( xWrappedObject.is() )
409 : : {
410 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
411 [ # # ][ # # ]: 0 : xWrappedObject->addStateChangeListener( xListener );
412 : 0 : return;
413 : : }
414 : : // end wrapping related part ====================
415 : :
416 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
417 [ # # ]: 0 : if ( m_bDisposed )
418 [ # # ]: 0 : throw lang::DisposedException(); // TODO
419 : :
420 [ # # ]: 0 : if ( !m_pInterfaceContainer )
421 [ # # ]: 0 : m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
422 : :
423 [ # # ]: 0 : m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
424 [ # # ][ # # ]: 0 : xListener );
[ # # ]
425 : : }
426 : :
427 : : //----------------------------------------------
428 : 0 : void SAL_CALL OleEmbeddedObject::removeStateChangeListener(
429 : : const uno::Reference< embed::XStateChangeListener >& xListener )
430 : : throw (uno::RuntimeException)
431 : : {
432 : : // begin wrapping related part ====================
433 [ # # ]: 0 : uno::Reference< embed::XStateChangeBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
434 [ # # ]: 0 : if ( xWrappedObject.is() )
435 : : {
436 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
437 [ # # ][ # # ]: 0 : xWrappedObject->removeStateChangeListener( xListener );
438 : 0 : return;
439 : : }
440 : : // end wrapping related part ====================
441 : :
442 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
443 [ # # ]: 0 : if ( m_pInterfaceContainer )
444 [ # # ]: 0 : m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
445 [ # # ][ # # ]: 0 : xListener );
[ # # ]
446 : : }
447 : :
448 : :
449 : : //----------------------------------------------
450 : 0 : void SAL_CALL OleEmbeddedObject::close( sal_Bool bDeliverOwnership )
451 : : throw ( util::CloseVetoException,
452 : : uno::RuntimeException )
453 : : {
454 : : // begin wrapping related part ====================
455 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
456 [ # # ]: 0 : if ( xWrappedObject.is() )
457 : : {
458 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
459 [ # # ][ # # ]: 0 : xWrappedObject->close( bDeliverOwnership );
460 : 0 : return;
461 : : }
462 : : // end wrapping related part ====================
463 : :
464 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
465 [ # # ]: 0 : if ( m_bDisposed )
466 [ # # ]: 0 : throw lang::DisposedException(); // TODO
467 : :
468 [ # # ]: 0 : uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
469 [ # # ][ # # ]: 0 : lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
470 : :
471 [ # # ]: 0 : if ( m_pInterfaceContainer )
472 : : {
473 : : ::cppu::OInterfaceContainerHelper* pContainer =
474 [ # # ][ # # ]: 0 : m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
475 [ # # ]: 0 : if ( pContainer != NULL )
476 : : {
477 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
478 [ # # ]: 0 : while (pIterator.hasMoreElements())
479 : : {
480 : : try
481 : : {
482 [ # # ][ # # ]: 0 : ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
483 : : }
484 [ # # # # ]: 0 : catch( const uno::RuntimeException& )
485 : : {
486 [ # # ]: 0 : pIterator.remove();
487 : : }
488 [ # # ]: 0 : }
489 : : }
490 : :
491 : : pContainer = m_pInterfaceContainer->getContainer(
492 [ # # ][ # # ]: 0 : ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
493 [ # # ]: 0 : if ( pContainer != NULL )
494 : : {
495 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
496 [ # # ]: 0 : while (pCloseIterator.hasMoreElements())
497 : : {
498 : : try
499 : : {
500 [ # # ][ # # ]: 0 : ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
501 : : }
502 [ # # # # ]: 0 : catch( const uno::RuntimeException& )
503 : : {
504 [ # # ]: 0 : pCloseIterator.remove();
505 : : }
506 [ # # ]: 0 : }
507 : : }
508 : : }
509 : :
510 [ # # ][ # # ]: 0 : Dispose();
[ # # ][ # # ]
511 : : }
512 : :
513 : : //----------------------------------------------
514 : 0 : void SAL_CALL OleEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
515 : : throw ( uno::RuntimeException )
516 : : {
517 : : // begin wrapping related part ====================
518 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
519 [ # # ]: 0 : if ( xWrappedObject.is() )
520 : : {
521 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
522 [ # # ][ # # ]: 0 : xWrappedObject->addCloseListener( xListener );
523 : 0 : return;
524 : : }
525 : : // end wrapping related part ====================
526 : :
527 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
528 [ # # ]: 0 : if ( m_bDisposed )
529 [ # # ]: 0 : throw lang::DisposedException(); // TODO
530 : :
531 [ # # ]: 0 : if ( !m_pInterfaceContainer )
532 [ # # ]: 0 : m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
533 : :
534 [ # # ][ # # ]: 0 : m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener );
[ # # ][ # # ]
535 : : }
536 : :
537 : : //----------------------------------------------
538 : 0 : void SAL_CALL OleEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
539 : : throw (uno::RuntimeException)
540 : : {
541 : : // begin wrapping related part ====================
542 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
543 [ # # ]: 0 : if ( xWrappedObject.is() )
544 : : {
545 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
546 [ # # ][ # # ]: 0 : xWrappedObject->removeCloseListener( xListener );
547 : 0 : return;
548 : : }
549 : : // end wrapping related part ====================
550 : :
551 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
552 [ # # ]: 0 : if ( m_bDisposed )
553 [ # # ]: 0 : throw lang::DisposedException(); // TODO
554 : :
555 [ # # ]: 0 : if ( m_pInterfaceContainer )
556 [ # # ]: 0 : m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ),
557 [ # # ][ # # ]: 0 : xListener );
[ # # ]
558 : : }
559 : :
560 : : //------------------------------------------------------
561 : 0 : void SAL_CALL OleEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
562 : : throw ( uno::RuntimeException )
563 : : {
564 : : // begin wrapping related part ====================
565 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
566 [ # # ]: 0 : if ( xWrappedObject.is() )
567 : : {
568 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
569 [ # # ][ # # ]: 0 : xWrappedObject->addEventListener( xListener );
570 : 0 : return;
571 : : }
572 : : // end wrapping related part ====================
573 : :
574 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
575 [ # # ]: 0 : if ( m_bDisposed )
576 [ # # ]: 0 : throw lang::DisposedException(); // TODO
577 : :
578 [ # # ]: 0 : if ( !m_pInterfaceContainer )
579 [ # # ]: 0 : m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
580 : :
581 [ # # ][ # # ]: 0 : m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener );
[ # # ][ # # ]
582 : : }
583 : :
584 : : //------------------------------------------------------
585 : 0 : void SAL_CALL OleEmbeddedObject::removeEventListener(
586 : : const uno::Reference< document::XEventListener >& xListener )
587 : : throw ( uno::RuntimeException )
588 : : {
589 : : // begin wrapping related part ====================
590 : 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
591 [ # # ]: 0 : if ( xWrappedObject.is() )
592 : : {
593 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
594 [ # # ][ # # ]: 0 : xWrappedObject->removeEventListener( xListener );
595 : 0 : return;
596 : : }
597 : : // end wrapping related part ====================
598 : :
599 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
600 [ # # ]: 0 : if ( m_bDisposed )
601 [ # # ]: 0 : throw lang::DisposedException(); // TODO
602 : :
603 [ # # ]: 0 : if ( m_pInterfaceContainer )
604 [ # # ]: 0 : m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ),
605 [ # # ][ # # ]: 0 : xListener );
[ # # ]
606 : : }
607 : :
608 : : // XInplaceObject ( wrapper related implementation )
609 : : //------------------------------------------------------
610 : 0 : void SAL_CALL OleEmbeddedObject::setObjectRectangles( const awt::Rectangle& aPosRect,
611 : : const awt::Rectangle& aClipRect )
612 : : throw ( embed::WrongStateException,
613 : : uno::Exception,
614 : : uno::RuntimeException )
615 : : {
616 : : // begin wrapping related part ====================
617 [ # # ]: 0 : uno::Reference< embed::XInplaceObject > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
618 [ # # ]: 0 : if ( xWrappedObject.is() )
619 : : {
620 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
621 [ # # ][ # # ]: 0 : xWrappedObject->setObjectRectangles( aPosRect, aClipRect );
622 : 0 : return;
623 : : }
624 : : // end wrapping related part ====================
625 : :
626 [ # # ]: 0 : throw embed::WrongStateException();
627 : : }
628 : :
629 : : //------------------------------------------------------
630 : 0 : void SAL_CALL OleEmbeddedObject::enableModeless( sal_Bool bEnable )
631 : : throw ( embed::WrongStateException,
632 : : uno::Exception,
633 : : uno::RuntimeException )
634 : : {
635 : : // begin wrapping related part ====================
636 [ # # ]: 0 : uno::Reference< embed::XInplaceObject > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
637 [ # # ]: 0 : if ( xWrappedObject.is() )
638 : : {
639 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
640 [ # # ][ # # ]: 0 : xWrappedObject->enableModeless( bEnable );
641 : 0 : return;
642 : : }
643 : : // end wrapping related part ====================
644 : :
645 [ # # ]: 0 : throw embed::WrongStateException();
646 : : }
647 : :
648 : : //------------------------------------------------------
649 : 0 : void SAL_CALL OleEmbeddedObject::translateAccelerators(
650 : : const uno::Sequence< awt::KeyEvent >& aKeys )
651 : : throw ( embed::WrongStateException,
652 : : uno::RuntimeException )
653 : : {
654 : : // begin wrapping related part ====================
655 [ # # ]: 0 : uno::Reference< embed::XInplaceObject > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
656 [ # # ]: 0 : if ( xWrappedObject.is() )
657 : : {
658 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
659 [ # # ][ # # ]: 0 : xWrappedObject->translateAccelerators( aKeys );
660 : 0 : return;
661 [ # # ]: 0 : }
662 : : // end wrapping related part ====================
663 : :
664 : : }
665 : :
666 : : // XChild
667 : : //------------------------------------------------------
668 : 0 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL OleEmbeddedObject::getParent() throw (::com::sun::star::uno::RuntimeException)
669 : : {
670 : : // begin wrapping related part ====================
671 [ # # ]: 0 : uno::Reference< container::XChild > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
672 [ # # ]: 0 : if ( xWrappedObject.is() )
673 : : {
674 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
675 [ # # ][ # # ]: 0 : return xWrappedObject->getParent();
676 : : }
677 : : // end wrapping related part ====================
678 : :
679 : 0 : return m_xParent;
680 : : }
681 : :
682 : : //------------------------------------------------------
683 : 0 : void SAL_CALL OleEmbeddedObject::setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xParent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException)
684 : : {
685 : : // begin wrapping related part ====================
686 [ # # ]: 0 : uno::Reference< container::XChild > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
687 [ # # ]: 0 : if ( xWrappedObject.is() )
688 : : {
689 : : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
690 [ # # ][ # # ]: 0 : xWrappedObject->setParent( xParent );
691 : 0 : return;
692 : : }
693 : : // end wrapping related part ====================
694 : :
695 [ # # ][ # # ]: 0 : m_xParent = xParent;
696 : : }
697 : :
698 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|