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