Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <sal/config.h>
21 :
22 : #include <cassert>
23 :
24 : #include <com/sun/star/embed/EmbedUpdateModes.hpp>
25 : #include <com/sun/star/embed/EmbedStates.hpp>
26 : #include <com/sun/star/lang/XComponent.hpp>
27 : #include <com/sun/star/lang/DisposedException.hpp>
28 :
29 : #include <cppuhelper/interfacecontainer.h>
30 :
31 : #include <oleembobj.hxx>
32 : #include <olepersist.hxx>
33 :
34 : #include "ownview.hxx"
35 :
36 : #if defined WNT
37 : #include <olecomponent.hxx>
38 : #endif
39 :
40 : using namespace ::com::sun::star;
41 :
42 :
43 :
44 0 : OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory,
45 : const uno::Sequence< sal_Int8 >& aClassID,
46 : const OUString& aClassName )
47 : : m_pOleComponent( NULL )
48 : , m_pInterfaceContainer( NULL )
49 : , m_bReadOnly( false )
50 : , m_bDisposed( 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( false )
58 : , m_bNewVisReplInStream( true )
59 : , m_bStoreLoaded( false )
60 : , m_bVisReplInitialized( false )
61 : , m_bVisReplInStream( false )
62 : , m_bStoreVisRepl( false )
63 : , m_bIsLink( false )
64 : , m_bHasCachedSize( false )
65 : , m_nCachedAspect( 0 )
66 : , m_bHasSizeToSet( false )
67 : , m_nAspectToSet( 0 )
68 : , m_bGotStatus( false )
69 : , m_nStatus( 0 )
70 : , m_nStatusAspect( 0 )
71 : , m_pOwnView( NULL )
72 : , m_bFromClipboard( false )
73 0 : , m_bTriedConversion( false )
74 : {
75 0 : }
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
80 0 : OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, bool bLink )
81 : : m_pOleComponent( NULL )
82 : , m_pInterfaceContainer( NULL )
83 : , m_bReadOnly( false )
84 : , m_bDisposed( false )
85 : , m_nObjectState( -1 )
86 : , m_nTargetState( -1 )
87 : , m_nUpdateMode( embed::EmbedUpdateModes::ALWAYS_UPDATE )
88 : , m_xFactory( xFactory )
89 : , m_bWaitSaveCompleted( false )
90 : , m_bNewVisReplInStream( true )
91 : , m_bStoreLoaded( false )
92 : , m_bVisReplInitialized( false )
93 : , m_bVisReplInStream( false )
94 : , m_bStoreVisRepl( false )
95 : , m_bIsLink( bLink )
96 : , m_bHasCachedSize( false )
97 : , m_nCachedAspect( 0 )
98 : , m_bHasSizeToSet( false )
99 : , m_nAspectToSet( 0 )
100 : , m_bGotStatus( false )
101 : , m_nStatus( 0 )
102 : , m_nStatusAspect( 0 )
103 : , m_pOwnView( NULL )
104 : , m_bFromClipboard( false )
105 0 : , m_bTriedConversion( false )
106 : {
107 0 : }
108 : #ifdef WNT
109 :
110 : // this constructor let object be initialized from clipboard
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( 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 :
141 0 : OleEmbeddedObject::~OleEmbeddedObject()
142 : {
143 : OSL_ENSURE( !m_pInterfaceContainer && !m_pOleComponent && !m_xObjectStream.is(),
144 : "The object is not closed! DISASTER is possible!" );
145 :
146 0 : if ( m_pOleComponent || m_pInterfaceContainer || m_xObjectStream.is() )
147 : {
148 : // the component must be cleaned during closing
149 0 : m_refCount++; // to avoid crash
150 : try {
151 0 : Dispose();
152 0 : } catch( const uno::Exception& ) {}
153 : }
154 :
155 0 : if ( !m_aTempURL.isEmpty() )
156 0 : KillFile_Impl( m_aTempURL, m_xFactory );
157 :
158 0 : if ( !m_aTempDumpURL.isEmpty() )
159 0 : KillFile_Impl( m_aTempDumpURL, m_xFactory );
160 0 : }
161 :
162 :
163 0 : void OleEmbeddedObject::MakeEventListenerNotification_Impl( const OUString& aEventName )
164 : {
165 0 : if ( m_pInterfaceContainer )
166 : {
167 : ::cppu::OInterfaceContainerHelper* pContainer =
168 : m_pInterfaceContainer->getContainer(
169 0 : cppu::UnoType<document::XEventListener>::get());
170 0 : if ( pContainer != NULL )
171 : {
172 0 : document::EventObject aEvent( static_cast< ::cppu::OWeakObject* >( this ), aEventName );
173 0 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
174 0 : while (pIterator.hasMoreElements())
175 : {
176 : try
177 : {
178 0 : static_cast<document::XEventListener*>(pIterator.next())->notifyEvent( aEvent );
179 : }
180 0 : catch( const uno::RuntimeException& )
181 : {
182 : }
183 0 : }
184 : }
185 : }
186 0 : }
187 : #ifdef WNT
188 :
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 : cppu::UnoType<embed::XStateChangeListener>::get());
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( const 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( const uno::Exception& )
220 : {
221 : // if anything happened it is problem of listener, ignore it
222 : }
223 : }
224 : }
225 : }
226 : }
227 : }
228 : #endif
229 :
230 0 : 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( const 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 0 : }
257 :
258 :
259 0 : void OleEmbeddedObject::Dispose()
260 : {
261 0 : if ( m_pInterfaceContainer )
262 : {
263 0 : lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
264 0 : m_pInterfaceContainer->disposeAndClear( aSource );
265 0 : delete m_pInterfaceContainer;
266 0 : m_pInterfaceContainer = NULL;
267 : }
268 :
269 0 : if ( m_pOwnView )
270 : {
271 0 : m_pOwnView->Close();
272 0 : m_pOwnView->release();
273 0 : m_pOwnView = NULL;
274 : }
275 :
276 0 : if ( m_pOleComponent )
277 : try {
278 0 : GetRidOfComponent();
279 : } catch( const 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 0 : if ( m_xObjectStream.is() )
287 : {
288 0 : uno::Reference< lang::XComponent > xComp( m_xObjectStream, uno::UNO_QUERY );
289 : OSL_ENSURE( xComp.is(), "Storage stream doesn't support XComponent!\n" );
290 :
291 0 : if ( xComp.is() )
292 : {
293 : try {
294 0 : xComp->dispose();
295 0 : } catch( const uno::Exception& ) {}
296 : }
297 0 : m_xObjectStream = uno::Reference< io::XStream >();
298 : }
299 :
300 0 : m_xParentStorage = uno::Reference< embed::XStorage >();
301 :
302 0 : m_bDisposed = true;
303 0 : }
304 :
305 :
306 0 : uno::Sequence< sal_Int8 > SAL_CALL OleEmbeddedObject::getClassID()
307 : throw ( uno::RuntimeException, std::exception )
308 : {
309 : // begin wrapping related part ====================
310 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
311 0 : if ( xWrappedObject.is() )
312 : {
313 : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
314 0 : return xWrappedObject->getClassID();
315 : }
316 : // end wrapping related part ====================
317 :
318 0 : ::osl::MutexGuard aGuard( m_aMutex );
319 0 : if ( m_bDisposed )
320 0 : throw lang::DisposedException(); // TODO
321 :
322 0 : return m_aClassID;
323 : }
324 :
325 :
326 0 : OUString SAL_CALL OleEmbeddedObject::getClassName()
327 : throw ( uno::RuntimeException, std::exception )
328 : {
329 : // begin wrapping related part ====================
330 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
331 0 : if ( xWrappedObject.is() )
332 : {
333 : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
334 0 : return xWrappedObject->getClassName();
335 : }
336 : // end wrapping related part ====================
337 :
338 0 : ::osl::MutexGuard aGuard( m_aMutex );
339 0 : if ( m_bDisposed )
340 0 : throw lang::DisposedException(); // TODO
341 :
342 0 : return m_aClassName;
343 : }
344 :
345 :
346 0 : void SAL_CALL OleEmbeddedObject::setClassInfo(
347 : const uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName )
348 : throw ( lang::NoSupportException,
349 : uno::RuntimeException, std::exception )
350 : {
351 : // begin wrapping related part ====================
352 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
353 0 : if ( xWrappedObject.is() )
354 : {
355 : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
356 0 : xWrappedObject->setClassInfo( aClassID, aClassName );
357 0 : return;
358 : }
359 : // end wrapping related part ====================
360 :
361 : // the object class info can not be changed explicitly
362 0 : throw lang::NoSupportException(); //TODO:
363 : }
364 :
365 :
366 0 : uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent()
367 : throw ( uno::RuntimeException, std::exception )
368 : {
369 : // begin wrapping related part ====================
370 0 : uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
371 0 : if ( xWrappedObject.is() )
372 : {
373 : // the object was converted to OOo embedded object, the current implementation is now only a wrapper
374 0 : return xWrappedObject->getComponent();
375 : }
376 : // end wrapping related part ====================
377 :
378 0 : ::osl::MutexGuard aGuard( m_aMutex );
379 0 : if ( m_bDisposed )
380 0 : throw lang::DisposedException(); // TODO
381 :
382 0 : if ( m_nObjectState == -1 ) // || m_nObjectState == embed::EmbedStates::LOADED )
383 : {
384 : // the object is still not running
385 : throw uno::RuntimeException( "The object is not loaded!",
386 0 : static_cast< ::cppu::OWeakObject* >(this) );
387 : }
388 :
389 : #if defined WNT
390 : if (m_pOleComponent != 0)
391 : {
392 : return uno::Reference< util::XCloseable >( static_cast< ::cppu::OWeakObject* >( m_pOleComponent ), uno::UNO_QUERY );
393 : }
394 : #endif
395 :
396 : assert(m_pOleComponent == 0);
397 : // TODO/LATER: Is it correct???
398 0 : return uno::Reference< util::XCloseable >();
399 : // throw uno::RuntimeException(); // TODO
400 : }
401 :
402 :
403 0 : void SAL_CALL OleEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
404 : throw ( uno::RuntimeException, std::exception )
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( cppu::UnoType<embed::XStateChangeListener>::get(),
424 0 : xListener );
425 : }
426 :
427 :
428 0 : void SAL_CALL OleEmbeddedObject::removeStateChangeListener(
429 : const uno::Reference< embed::XStateChangeListener >& xListener )
430 : throw (uno::RuntimeException, std::exception)
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( cppu::UnoType<embed::XStateChangeListener>::get(),
445 0 : xListener );
446 : }
447 :
448 :
449 :
450 0 : void SAL_CALL OleEmbeddedObject::close( sal_Bool bDeliverOwnership )
451 : throw ( util::CloseVetoException,
452 : uno::RuntimeException, std::exception )
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( cppu::UnoType<util::XCloseListener>::get());
475 0 : if ( pContainer != NULL )
476 : {
477 0 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
478 0 : while (pIterator.hasMoreElements())
479 : {
480 : try
481 : {
482 0 : static_cast<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 : cppu::UnoType<util::XCloseListener>::get());
493 0 : if ( pContainer != NULL )
494 : {
495 0 : ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
496 0 : while (pCloseIterator.hasMoreElements())
497 : {
498 : try
499 : {
500 0 : static_cast<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, std::exception )
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( cppu::UnoType<util::XCloseListener>::get(), xListener );
535 : }
536 :
537 :
538 0 : void SAL_CALL OleEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
539 : throw (uno::RuntimeException, std::exception)
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( cppu::UnoType<util::XCloseListener>::get(),
557 0 : xListener );
558 : }
559 :
560 :
561 0 : void SAL_CALL OleEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
562 : throw ( uno::RuntimeException, std::exception )
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( cppu::UnoType<document::XEventListener>::get(), xListener );
582 : }
583 :
584 :
585 0 : void SAL_CALL OleEmbeddedObject::removeEventListener(
586 : const uno::Reference< document::XEventListener >& xListener )
587 : throw ( uno::RuntimeException, std::exception )
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( cppu::UnoType<document::XEventListener>::get(),
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, std::exception )
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, std::exception )
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, std::exception )
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, std::exception)
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, std::exception)
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: */
|