LCOV - code coverage report
Current view: top level - embeddedobj/source/msole - olemisc.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 125 204 61.3 %
Date: 2015-06-13 12:38:46 Functions: 15 23 65.2 %
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 <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           2 : 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           2 : , m_bTriedConversion( false )
     106             : {
     107           2 : }
     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           6 : OleEmbeddedObject::~OleEmbeddedObject()
     142             : {
     143             :     OSL_ENSURE( !m_pInterfaceContainer && !m_pOleComponent && !m_xObjectStream.is(),
     144             :                     "The object is not closed! DISASTER is possible!" );
     145             : 
     146           2 :     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           2 :     if ( !m_aTempURL.isEmpty() )
     156           0 :            KillFile_Impl( m_aTempURL, m_xFactory );
     157             : 
     158           2 :     if ( !m_aTempDumpURL.isEmpty() )
     159           0 :            KillFile_Impl( m_aTempDumpURL, m_xFactory );
     160           4 : }
     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           1 : void OleEmbeddedObject::Dispose()
     260             : {
     261           1 :     if ( m_pInterfaceContainer )
     262             :     {
     263           1 :         lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     264           1 :         m_pInterfaceContainer->disposeAndClear( aSource );
     265           1 :         delete m_pInterfaceContainer;
     266           1 :         m_pInterfaceContainer = NULL;
     267             :     }
     268             : 
     269           1 :     if ( m_pOwnView )
     270             :     {
     271           0 :         m_pOwnView->Close();
     272           0 :         m_pOwnView->release();
     273           0 :         m_pOwnView = NULL;
     274             :     }
     275             : 
     276           1 :     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           1 :     if ( m_xObjectStream.is() )
     287             :     {
     288           1 :         uno::Reference< lang::XComponent > xComp( m_xObjectStream, uno::UNO_QUERY );
     289             :         OSL_ENSURE( xComp.is(), "Storage stream doesn't support XComponent!\n" );
     290             : 
     291           1 :         if ( xComp.is() )
     292             :         {
     293             :             try {
     294           1 :                 xComp->dispose();
     295           0 :             } catch( const uno::Exception& ) {}
     296             :         }
     297           1 :         m_xObjectStream = uno::Reference< io::XStream >();
     298             :     }
     299             : 
     300           1 :     m_xParentStorage = uno::Reference< embed::XStorage >();
     301             : 
     302           1 :     m_bDisposed = true;
     303           1 : }
     304             : 
     305             : 
     306           6 : uno::Sequence< sal_Int8 > SAL_CALL OleEmbeddedObject::getClassID()
     307             :         throw ( uno::RuntimeException, std::exception )
     308             : {
     309             :     // begin wrapping related part ====================
     310           6 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     311           6 :     if ( xWrappedObject.is() )
     312             :     {
     313             :         // the object was converted to OOo embedded object, the current implementation is now only a wrapper
     314           1 :         return xWrappedObject->getClassID();
     315             :     }
     316             :     // end wrapping related part ====================
     317             : 
     318          10 :     ::osl::MutexGuard aGuard( m_aMutex );
     319           5 :     if ( m_bDisposed )
     320           0 :         throw lang::DisposedException(); // TODO
     321             : 
     322          11 :     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           6 : uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent()
     367             :         throw ( uno::RuntimeException, std::exception )
     368             : {
     369             :     // begin wrapping related part ====================
     370           6 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     371           6 :     if ( xWrappedObject.is() )
     372             :     {
     373             :         // the object was converted to OOo embedded object, the current implementation is now only a wrapper
     374           4 :         return xWrappedObject->getComponent();
     375             :     }
     376             :     // end wrapping related part ====================
     377             : 
     378           4 :     ::osl::MutexGuard aGuard( m_aMutex );
     379           2 :     if ( m_bDisposed )
     380           0 :         throw lang::DisposedException(); // TODO
     381             : 
     382           2 :     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           8 :     return uno::Reference< util::XCloseable >();
     399             :     // throw uno::RuntimeException(); // TODO
     400             : }
     401             : 
     402             : 
     403           4 : void SAL_CALL OleEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
     404             :     throw ( uno::RuntimeException, std::exception )
     405             : {
     406             :     // begin wrapping related part ====================
     407           4 :     uno::Reference< embed::XStateChangeBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
     408           4 :     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           4 :         return;
     413             :     }
     414             :     // end wrapping related part ====================
     415             : 
     416           8 :     ::osl::MutexGuard aGuard( m_aMutex );
     417           4 :     if ( m_bDisposed )
     418           0 :         throw lang::DisposedException(); // TODO
     419             : 
     420           4 :     if ( !m_pInterfaceContainer )
     421           2 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     422             : 
     423           4 :     m_pInterfaceContainer->addInterface( cppu::UnoType<embed::XStateChangeListener>::get(),
     424          12 :                                                         xListener );
     425             : }
     426             : 
     427             : 
     428           4 : 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           4 :     uno::Reference< embed::XStateChangeBroadcaster > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
     434           4 :     if ( xWrappedObject.is() )
     435             :     {
     436             :         // the object was converted to OOo embedded object, the current implementation is now only a wrapper
     437           2 :         xWrappedObject->removeStateChangeListener( xListener );
     438           6 :         return;
     439             :     }
     440             :     // end wrapping related part ====================
     441             : 
     442           4 :     ::osl::MutexGuard aGuard( m_aMutex );
     443           2 :     if ( m_pInterfaceContainer )
     444           2 :         m_pInterfaceContainer->removeInterface( cppu::UnoType<embed::XStateChangeListener>::get(),
     445           6 :                                                 xListener );
     446             : }
     447             : 
     448             : 
     449             : 
     450           3 : void SAL_CALL OleEmbeddedObject::close( sal_Bool bDeliverOwnership )
     451             :     throw ( util::CloseVetoException,
     452             :             uno::RuntimeException, std::exception )
     453             : {
     454             :     // begin wrapping related part ====================
     455           3 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     456           3 :     if ( xWrappedObject.is() )
     457             :     {
     458             :         // the object was converted to OOo embedded object, the current implementation is now only a wrapper
     459           1 :         xWrappedObject->close( bDeliverOwnership );
     460           3 :         return;
     461             :     }
     462             :     // end wrapping related part ====================
     463             : 
     464           4 :     ::osl::MutexGuard aGuard( m_aMutex );
     465           2 :     if ( m_bDisposed )
     466           0 :         throw lang::DisposedException(); // TODO
     467             : 
     468           4 :     uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
     469           4 :     lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     470             : 
     471           2 :     if ( m_pInterfaceContainer )
     472             :     {
     473             :         ::cppu::OInterfaceContainerHelper* pContainer =
     474           2 :             m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get());
     475           2 :         if ( pContainer != NULL )
     476             :         {
     477           2 :             ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
     478           4 :             while (pIterator.hasMoreElements())
     479             :             {
     480             :                 try
     481             :                 {
     482           1 :                     static_cast<util::XCloseListener*>(pIterator.next())->queryClosing( aSource, bDeliverOwnership );
     483             :                 }
     484           0 :                 catch( const uno::RuntimeException& )
     485             :                 {
     486           0 :                     pIterator.remove();
     487             :                 }
     488           2 :             }
     489             :         }
     490             : 
     491             :         pContainer = m_pInterfaceContainer->getContainer(
     492           1 :                                     cppu::UnoType<util::XCloseListener>::get());
     493           1 :         if ( pContainer != NULL )
     494             :         {
     495           1 :             ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
     496           2 :             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           1 :             }
     507             :         }
     508             :     }
     509             : 
     510           3 :     Dispose();
     511             : }
     512             : 
     513             : 
     514           2 : void SAL_CALL OleEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     515             :     throw ( uno::RuntimeException, std::exception )
     516             : {
     517             :     // begin wrapping related part ====================
     518           2 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     519           2 :     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           2 :         return;
     524             :     }
     525             :     // end wrapping related part ====================
     526             : 
     527           4 :     ::osl::MutexGuard aGuard( m_aMutex );
     528           2 :     if ( m_bDisposed )
     529           0 :         throw lang::DisposedException(); // TODO
     530             : 
     531           2 :     if ( !m_pInterfaceContainer )
     532           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     533             : 
     534           4 :     m_pInterfaceContainer->addInterface( cppu::UnoType<util::XCloseListener>::get(), xListener );
     535             : }
     536             : 
     537             : 
     538           2 : void SAL_CALL OleEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     539             :     throw (uno::RuntimeException, std::exception)
     540             : {
     541             :     // begin wrapping related part ====================
     542           2 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     543           2 :     if ( xWrappedObject.is() )
     544             :     {
     545             :         // the object was converted to OOo embedded object, the current implementation is now only a wrapper
     546           1 :         xWrappedObject->removeCloseListener( xListener );
     547           3 :         return;
     548             :     }
     549             :     // end wrapping related part ====================
     550             : 
     551           2 :     ::osl::MutexGuard aGuard( m_aMutex );
     552           1 :     if ( m_bDisposed )
     553           0 :         throw lang::DisposedException(); // TODO
     554             : 
     555           1 :     if ( m_pInterfaceContainer )
     556           1 :         m_pInterfaceContainer->removeInterface( cppu::UnoType<util::XCloseListener>::get(),
     557           3 :                                                 xListener );
     558             : }
     559             : 
     560             : 
     561           4 : void SAL_CALL OleEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
     562             :         throw ( uno::RuntimeException, std::exception )
     563             : {
     564             :     // begin wrapping related part ====================
     565           4 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     566           4 :     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           4 :         return;
     571             :     }
     572             :     // end wrapping related part ====================
     573             : 
     574           8 :     ::osl::MutexGuard aGuard( m_aMutex );
     575           4 :     if ( m_bDisposed )
     576           0 :         throw lang::DisposedException(); // TODO
     577             : 
     578           4 :     if ( !m_pInterfaceContainer )
     579           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     580             : 
     581           8 :     m_pInterfaceContainer->addInterface( cppu::UnoType<document::XEventListener>::get(), xListener );
     582             : }
     583             : 
     584             : 
     585           4 : 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           4 :     uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject;
     591           4 :     if ( xWrappedObject.is() )
     592             :     {
     593             :         // the object was converted to OOo embedded object, the current implementation is now only a wrapper
     594           2 :         xWrappedObject->removeEventListener( xListener );
     595           6 :         return;
     596             :     }
     597             :     // end wrapping related part ====================
     598             : 
     599           4 :     ::osl::MutexGuard aGuard( m_aMutex );
     600           2 :     if ( m_bDisposed )
     601           0 :         throw lang::DisposedException(); // TODO
     602             : 
     603           2 :     if ( m_pInterfaceContainer )
     604           2 :         m_pInterfaceContainer->removeInterface( cppu::UnoType<document::XEventListener>::get(),
     605           6 :                                                 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           2 : 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           2 :     uno::Reference< container::XChild > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
     672           2 :     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           2 :     return m_xParent;
     680             : }
     681             : 
     682             : 
     683           4 : 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           4 :     uno::Reference< container::XChild > xWrappedObject( m_xWrappedObject, uno::UNO_QUERY );
     687           4 :     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           4 :         return;
     692             :     }
     693             :     // end wrapping related part ====================
     694             : 
     695           4 :     m_xParent = xParent;
     696             : }
     697             : 
     698             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11