LCOV - code coverage report
Current view: top level - libreoffice/embeddedobj/source/msole - olemisc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 206 0.0 %
Date: 2012-12-27 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10