LCOV - code coverage report
Current view: top level - embeddedobj/source/commonembedding - miscobj.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 293 0.0 %
Date: 2014-04-14 Functions: 0 24 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 <commonembobj.hxx>
      21             : #include <com/sun/star/embed/EmbedStates.hpp>
      22             : #include <com/sun/star/embed/EmbedVerbs.hpp>
      23             : #include <com/sun/star/embed/XStorage.hpp>
      24             : #include <com/sun/star/embed/EmbedUpdateModes.hpp>
      25             : #include <com/sun/star/embed/XInplaceClient.hpp>
      26             : #include <com/sun/star/lang/DisposedException.hpp>
      27             : #include <com/sun/star/beans/NamedValue.hpp>
      28             : 
      29             : #include <cppuhelper/typeprovider.hxx>
      30             : #include <cppuhelper/interfacecontainer.h>
      31             : #include <comphelper/mimeconfighelper.hxx>
      32             : #include <comphelper/processfactory.hxx>
      33             : 
      34             : #include "closepreventer.hxx"
      35             : #include "intercept.hxx"
      36             : 
      37             : using namespace ::com::sun::star;
      38             : 
      39             : 
      40             : uno::Sequence< beans::PropertyValue > GetValuableArgs_Impl( const uno::Sequence< beans::PropertyValue >& aMedDescr,
      41             :                                                             sal_Bool bCanUseDocumentBaseURL );
      42             : 
      43             : 
      44           0 : OCommonEmbeddedObject::OCommonEmbeddedObject( const uno::Reference< uno::XComponentContext >& rxContext,
      45             :                                                 const uno::Sequence< beans::NamedValue >& aObjProps )
      46             : : m_pDocHolder( NULL )
      47             : , m_pInterfaceContainer( NULL )
      48             : , m_bReadOnly( sal_False )
      49             : , m_bDisposed( sal_False )
      50             : , m_bClosed( sal_False )
      51             : , m_nObjectState( -1 )
      52             : , m_nTargetState( -1 )
      53             : , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE )
      54             : , m_xContext( rxContext )
      55             : , m_nMiscStatus( 0 )
      56             : , m_bEmbeddedScriptSupport( sal_True )
      57             : , m_bDocumentRecoverySupport( sal_True )
      58             : , m_bWaitSaveCompleted( sal_False )
      59             : , m_bIsLink( sal_False )
      60             : , m_bLinkHasPassword( sal_False )
      61             : , m_bHasClonedSize( sal_False )
      62           0 : , m_nClonedMapUnit( 0 )
      63             : {
      64           0 :     CommonInit_Impl( aObjProps );
      65           0 : }
      66             : 
      67             : 
      68           0 : OCommonEmbeddedObject::OCommonEmbeddedObject(
      69             :         const uno::Reference< uno::XComponentContext >& rxContext,
      70             :         const uno::Sequence< beans::NamedValue >& aObjProps,
      71             :         const uno::Sequence< beans::PropertyValue >& aMediaDescr,
      72             :         const uno::Sequence< beans::PropertyValue >& aObjectDescr )
      73             : : m_pDocHolder( NULL )
      74             : , m_pInterfaceContainer( NULL )
      75             : , m_bReadOnly( sal_False )
      76             : , m_bDisposed( sal_False )
      77             : , m_bClosed( sal_False )
      78             : , m_nObjectState( embed::EmbedStates::LOADED )
      79             : , m_nTargetState( -1 )
      80             : , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE )
      81             : , m_xContext( rxContext )
      82             : , m_nMiscStatus( 0 )
      83             : , m_bEmbeddedScriptSupport( sal_True )
      84             : , m_bDocumentRecoverySupport( sal_True )
      85             : , m_bWaitSaveCompleted( sal_False )
      86             : , m_bIsLink( sal_True )
      87             : , m_bLinkHasPassword( sal_False )
      88             : , m_bHasClonedSize( sal_False )
      89           0 : , m_nClonedMapUnit( 0 )
      90             : {
      91             :     // linked object has no own persistence so it is in loaded state starting from creation
      92           0 :     LinkInit_Impl( aObjProps, aMediaDescr, aObjectDescr );
      93           0 : }
      94             : 
      95             : 
      96           0 : void OCommonEmbeddedObject::CommonInit_Impl( const uno::Sequence< beans::NamedValue >& aObjectProps )
      97             : {
      98             :     OSL_ENSURE( m_xContext.is(), "No ServiceFactory is provided!\n" );
      99           0 :     if ( !m_xContext.is() )
     100           0 :         throw uno::RuntimeException();
     101             : 
     102           0 :     m_pDocHolder = new DocumentHolder( m_xContext, this );
     103           0 :     m_pDocHolder->acquire();
     104             : 
     105             :     // parse configuration entries
     106             :     // TODO/LATER: in future UI names can be also provided here
     107           0 :     for ( sal_Int32 nInd = 0; nInd < aObjectProps.getLength(); nInd++ )
     108             :     {
     109           0 :         if ( aObjectProps[nInd].Name == "ClassID" )
     110           0 :             aObjectProps[nInd].Value >>= m_aClassID;
     111           0 :         else if ( aObjectProps[nInd].Name == "ObjectDocumentServiceName" )
     112           0 :             aObjectProps[nInd].Value >>= m_aDocServiceName;
     113           0 :         else if ( aObjectProps[nInd].Name == "ObjectDocumentFilterName" )
     114           0 :             aObjectProps[nInd].Value >>= m_aPresetFilterName;
     115           0 :         else if ( aObjectProps[nInd].Name == "ObjectMiscStatus" )
     116           0 :             aObjectProps[nInd].Value >>= m_nMiscStatus;
     117           0 :         else if ( aObjectProps[nInd].Name == "ObjectVerbs" )
     118           0 :             aObjectProps[nInd].Value >>= m_aObjectVerbs;
     119             :     }
     120             : 
     121           0 :     if ( m_aClassID.getLength() != 16 /*|| !m_aDocServiceName.getLength()*/ )
     122           0 :         throw uno::RuntimeException(); // something goes really wrong
     123             : 
     124             :     // accepted states
     125           0 :     m_aAcceptedStates.realloc( NUM_SUPPORTED_STATES );
     126             : 
     127           0 :     m_aAcceptedStates[0] = embed::EmbedStates::LOADED;
     128           0 :     m_aAcceptedStates[1] = embed::EmbedStates::RUNNING;
     129           0 :     m_aAcceptedStates[2] = embed::EmbedStates::INPLACE_ACTIVE;
     130           0 :     m_aAcceptedStates[3] = embed::EmbedStates::UI_ACTIVE;
     131           0 :     m_aAcceptedStates[4] = embed::EmbedStates::ACTIVE;
     132             : 
     133             : 
     134             :     // intermediate states
     135             :     // In the following table the first index points to starting state,
     136             :     // the second one to the target state, and the sequence referenced by
     137             :     // first two indexes contains intermediate states, that should be
     138             :     // passed by object to reach the target state.
     139             :     // If the sequence is empty that means that indirect switch from start
     140             :     // state to the target state is forbidden, only if direct switch is possible
     141             :     // the state can be reached.
     142             : 
     143           0 :     m_pIntermediateStatesSeqs[0][2].realloc( 1 );
     144           0 :     m_pIntermediateStatesSeqs[0][2][0] = embed::EmbedStates::RUNNING;
     145             : 
     146           0 :     m_pIntermediateStatesSeqs[0][3].realloc( 2 );
     147           0 :     m_pIntermediateStatesSeqs[0][3][0] = embed::EmbedStates::RUNNING;
     148           0 :     m_pIntermediateStatesSeqs[0][3][1] = embed::EmbedStates::INPLACE_ACTIVE;
     149             : 
     150           0 :     m_pIntermediateStatesSeqs[0][4].realloc( 1 );
     151           0 :     m_pIntermediateStatesSeqs[0][4][0] = embed::EmbedStates::RUNNING;
     152             : 
     153           0 :     m_pIntermediateStatesSeqs[1][3].realloc( 1 );
     154           0 :     m_pIntermediateStatesSeqs[1][3][0] = embed::EmbedStates::INPLACE_ACTIVE;
     155             : 
     156           0 :     m_pIntermediateStatesSeqs[2][0].realloc( 1 );
     157           0 :     m_pIntermediateStatesSeqs[2][0][0] = embed::EmbedStates::RUNNING;
     158             : 
     159           0 :     m_pIntermediateStatesSeqs[3][0].realloc( 2 );
     160           0 :     m_pIntermediateStatesSeqs[3][0][0] = embed::EmbedStates::INPLACE_ACTIVE;
     161           0 :     m_pIntermediateStatesSeqs[3][0][1] = embed::EmbedStates::RUNNING;
     162             : 
     163           0 :     m_pIntermediateStatesSeqs[3][1].realloc( 1 );
     164           0 :     m_pIntermediateStatesSeqs[3][1][0] = embed::EmbedStates::INPLACE_ACTIVE;
     165             : 
     166           0 :     m_pIntermediateStatesSeqs[4][0].realloc( 1 );
     167           0 :     m_pIntermediateStatesSeqs[4][0][0] = embed::EmbedStates::RUNNING;
     168             : 
     169             :     // verbs table
     170           0 :     sal_Int32 nVerbTableSize = 0;
     171           0 :     for ( sal_Int32 nVerbInd = 0; nVerbInd < m_aObjectVerbs.getLength(); nVerbInd++ )
     172             :     {
     173           0 :         if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_PRIMARY )
     174             :         {
     175           0 :             m_aVerbTable.realloc( ++nVerbTableSize );
     176           0 :             m_aVerbTable[nVerbTableSize - 1].realloc( 2 );
     177           0 :             m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID;
     178           0 :             m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE;
     179             :         }
     180           0 :         else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_SHOW )
     181             :         {
     182           0 :             m_aVerbTable.realloc( ++nVerbTableSize );
     183           0 :             m_aVerbTable[nVerbTableSize - 1].realloc( 2 );
     184           0 :             m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID;
     185           0 :             m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE;
     186             :         }
     187           0 :         else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN )
     188             :         {
     189           0 :             m_aVerbTable.realloc( ++nVerbTableSize );
     190           0 :             m_aVerbTable[nVerbTableSize - 1].realloc( 2 );
     191           0 :             m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID;
     192           0 :             m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::ACTIVE;
     193             :         }
     194           0 :         else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_IPACTIVATE )
     195             :         {
     196           0 :             m_aVerbTable.realloc( ++nVerbTableSize );
     197           0 :             m_aVerbTable[nVerbTableSize - 1].realloc( 2 );
     198           0 :             m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID;
     199           0 :             m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::INPLACE_ACTIVE;
     200             :         }
     201           0 :         else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_UIACTIVATE )
     202             :         {
     203           0 :             m_aVerbTable.realloc( ++nVerbTableSize );
     204           0 :             m_aVerbTable[nVerbTableSize - 1].realloc( 2 );
     205           0 :             m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID;
     206           0 :             m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE;
     207             :         }
     208           0 :         else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_HIDE )
     209             :         {
     210           0 :             m_aVerbTable.realloc( ++nVerbTableSize );
     211           0 :             m_aVerbTable[nVerbTableSize - 1].realloc( 2 );
     212           0 :             m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID;
     213           0 :             m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::RUNNING;
     214             :         }
     215             :     }
     216           0 : }
     217             : 
     218             : 
     219           0 : void OCommonEmbeddedObject::LinkInit_Impl(
     220             :                                 const uno::Sequence< beans::NamedValue >& aObjectProps,
     221             :                                 const uno::Sequence< beans::PropertyValue >& aMediaDescr,
     222             :                                 const uno::Sequence< beans::PropertyValue >& aObjectDescr )
     223             : {
     224             :     // setPersistance has no effect on own links, so the complete initialization must be done here
     225             : 
     226           0 :     for ( sal_Int32 nInd = 0; nInd < aMediaDescr.getLength(); nInd++ )
     227           0 :         if ( aMediaDescr[nInd].Name == "URL" )
     228           0 :             aMediaDescr[nInd].Value >>= m_aLinkURL;
     229           0 :         else if ( aMediaDescr[nInd].Name == "FilterName" )
     230           0 :             aMediaDescr[nInd].Value >>= m_aLinkFilterName;
     231             : 
     232             :     OSL_ENSURE( m_aLinkURL.getLength() && m_aLinkFilterName.getLength(), "Filter and URL must be provided!\n" );
     233             : 
     234           0 :     m_bReadOnly = sal_True;
     235           0 :     if ( m_aLinkFilterName.getLength() )
     236             :     {
     237           0 :         ::comphelper::MimeConfigurationHelper aHelper( m_xContext );
     238           0 :         OUString aExportFilterName = aHelper.GetExportFilterFromImportFilter( m_aLinkFilterName );
     239           0 :         m_bReadOnly = !( aExportFilterName.equals( m_aLinkFilterName ) );
     240             :     }
     241             : 
     242           0 :     m_aDocMediaDescriptor = GetValuableArgs_Impl( aMediaDescr, sal_False );
     243             : 
     244           0 :     uno::Reference< frame::XDispatchProviderInterceptor > xDispatchInterceptor;
     245           0 :     for ( sal_Int32 nObjInd = 0; nObjInd < aObjectDescr.getLength(); nObjInd++ )
     246           0 :         if ( aObjectDescr[nObjInd].Name == "OutplaceDispatchInterceptor" )
     247             :         {
     248           0 :             aObjectDescr[nObjInd].Value >>= xDispatchInterceptor;
     249           0 :             break;
     250             :         }
     251           0 :         else if ( aObjectDescr[nObjInd].Name == "Parent" )
     252             :         {
     253           0 :             aObjectDescr[nObjInd].Value >>= m_xParent;
     254             :         }
     255             : 
     256           0 :     CommonInit_Impl( aObjectProps );
     257             : 
     258           0 :     if ( xDispatchInterceptor.is() )
     259           0 :         m_pDocHolder->SetOutplaceDispatchInterceptor( xDispatchInterceptor );
     260           0 : }
     261             : 
     262             : 
     263           0 : OCommonEmbeddedObject::~OCommonEmbeddedObject()
     264             : {
     265           0 :     if ( m_pInterfaceContainer || m_pDocHolder )
     266             :     {
     267           0 :         m_refCount++;
     268             :         try {
     269           0 :             lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     270             : 
     271           0 :             if ( m_pInterfaceContainer )
     272             :             {
     273           0 :                 m_pInterfaceContainer->disposeAndClear( aSource );
     274             : 
     275           0 :                 delete m_pInterfaceContainer;
     276           0 :                 m_pInterfaceContainer = NULL;
     277           0 :             }
     278           0 :         } catch( const uno::Exception& ) {}
     279             : 
     280             :         try {
     281           0 :             if ( m_pDocHolder )
     282             :             {
     283           0 :                 m_pDocHolder->CloseFrame();
     284             :                 try {
     285           0 :                     m_pDocHolder->CloseDocument( sal_True, sal_True );
     286           0 :                 } catch ( const uno::Exception& ) {}
     287           0 :                 m_pDocHolder->FreeOffice();
     288             : 
     289           0 :                 m_pDocHolder->release();
     290           0 :                 m_pDocHolder = NULL;
     291             :             }
     292           0 :         } catch( const uno::Exception& ) {}
     293             :     }
     294           0 : }
     295             : 
     296             : 
     297           0 : void OCommonEmbeddedObject::requestPositioning( const awt::Rectangle& aRect )
     298             : {
     299             :     // the method is called in case object is inplace active and the object window was resized
     300             : 
     301             :     OSL_ENSURE( m_xClientSite.is(), "The client site must be set for inplace active object!\n" );
     302           0 :     if ( m_xClientSite.is() )
     303             :     {
     304           0 :         uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
     305             : 
     306             :         OSL_ENSURE( xInplaceClient.is(), "The client site must support XInplaceClient to allow inplace activation!\n" );
     307           0 :         if ( xInplaceClient.is() )
     308             :         {
     309             :             try {
     310           0 :                 xInplaceClient->changedPlacement( aRect );
     311             :             }
     312           0 :             catch( const uno::Exception& )
     313             :             {
     314             :                 OSL_FAIL( "Exception on request to resize!\n" );
     315             :             }
     316           0 :         }
     317             :     }
     318           0 : }
     319             : 
     320             : 
     321           0 : void OCommonEmbeddedObject::PostEvent_Impl( const OUString& aEventName )
     322             : {
     323           0 :     if ( m_pInterfaceContainer )
     324             :     {
     325             :         ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer(
     326           0 :                                             ::getCppuType((const uno::Reference< document::XEventListener >*)0) );
     327           0 :         if( pIC )
     328             :         {
     329           0 :             document::EventObject aEvent;
     330           0 :             aEvent.EventName = aEventName;
     331           0 :             aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) );
     332             :             // For now all the events are sent as object events
     333             :             // aEvent.Source = ( xSource.is() ? xSource
     334             :             //                       : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) );
     335           0 :             ::cppu::OInterfaceIteratorHelper aIt( *pIC );
     336           0 :             while( aIt.hasMoreElements() )
     337             :             {
     338             :                 try
     339             :                 {
     340           0 :                     ((document::XEventListener *)aIt.next())->notifyEvent( aEvent );
     341             :                 }
     342           0 :                 catch( const uno::RuntimeException& )
     343             :                 {
     344           0 :                     aIt.remove();
     345             :                 }
     346             : 
     347             :                 // the listener could dispose the object.
     348           0 :                 if ( m_bDisposed )
     349           0 :                     return;
     350           0 :             }
     351             :         }
     352             :     }
     353             : }
     354             : 
     355             : 
     356           0 : uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType )
     357             :         throw( uno::RuntimeException, std::exception )
     358             : {
     359           0 :     uno::Any aReturn;
     360             : 
     361           0 :     if ( rType == ::getCppuType( (uno::Reference< embed::XEmbeddedObject > const *)0 ))
     362             :     {
     363           0 :         void * p = static_cast< embed::XEmbeddedObject * >( this );
     364           0 :         return uno::Any( &p, rType );
     365             :     }
     366             :     else
     367           0 :         aReturn <<= ::cppu::queryInterface(
     368             :                     rType,
     369             :                     static_cast< embed::XInplaceObject* >( this ),
     370             :                     static_cast< embed::XVisualObject* >( this ),
     371             :                     static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ),
     372             :                     static_cast< embed::XEmbedPersist* >( this ),
     373             :                     static_cast< embed::XLinkageSupport* >( this ),
     374             :                     static_cast< embed::XStateChangeBroadcaster* >( this ),
     375             :                     static_cast< embed::XClassifiedObject* >( this ),
     376             :                     static_cast< embed::XComponentSupplier* >( this ),
     377             :                     static_cast< util::XCloseable* >( this ),
     378             :                     static_cast< container::XChild* >( this ),
     379             :                     static_cast< chart2::XDefaultSizeTransmitter* >( this ),
     380           0 :                     static_cast< document::XEventBroadcaster* >( this ) );
     381             : 
     382           0 :     if ( aReturn.hasValue() )
     383           0 :         return aReturn;
     384             :     else
     385           0 :         return ::cppu::OWeakObject::queryInterface( rType ) ;
     386             : 
     387             : }
     388             : 
     389             : 
     390           0 : void SAL_CALL OCommonEmbeddedObject::acquire()
     391             :         throw()
     392             : {
     393           0 :     ::cppu::OWeakObject::acquire() ;
     394           0 : }
     395             : 
     396             : 
     397           0 : void SAL_CALL OCommonEmbeddedObject::release()
     398             :         throw()
     399             : {
     400           0 :     ::cppu::OWeakObject::release() ;
     401           0 : }
     402             : 
     403             : 
     404           0 : uno::Sequence< uno::Type > SAL_CALL OCommonEmbeddedObject::getTypes()
     405             :         throw( uno::RuntimeException )
     406             : {
     407             :     static ::cppu::OTypeCollection* pTypeCollection = NULL;
     408             : 
     409           0 :     if ( !pTypeCollection )
     410             :     {
     411           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     412           0 :         if ( !pTypeCollection )
     413             :         {
     414           0 :             if ( m_bIsLink )
     415             :             {
     416             :                 static ::cppu::OTypeCollection aTypeCollection(
     417           0 :                                             ::getCppuType( (const uno::Reference< lang::XTypeProvider >*)NULL ),
     418           0 :                                             ::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ),
     419           0 :                                             ::getCppuType( (const uno::Reference< embed::XInplaceObject >*)NULL ),
     420           0 :                                             ::getCppuType( (const uno::Reference< embed::XCommonEmbedPersist >*)NULL ),
     421           0 :                                             ::getCppuType( (const uno::Reference< container::XChild >*)NULL ),
     422           0 :                                             ::getCppuType( (const uno::Reference< embed::XLinkageSupport >*)NULL ) );
     423             : 
     424           0 :                 pTypeCollection = &aTypeCollection ;
     425             :             }
     426             :             else
     427             :             {
     428             :                    static ::cppu::OTypeCollection aTypeCollection(
     429           0 :                                             ::getCppuType( (const uno::Reference< lang::XTypeProvider >*)NULL ),
     430           0 :                                             ::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ),
     431           0 :                                             ::getCppuType( (const uno::Reference< embed::XInplaceObject >*)NULL ),
     432           0 :                                             ::getCppuType( (const uno::Reference< embed::XCommonEmbedPersist >*)NULL ),
     433           0 :                                             ::getCppuType( (const uno::Reference< container::XChild >*)NULL ),
     434           0 :                                             ::getCppuType( (const uno::Reference< embed::XEmbedPersist >*)NULL ) );
     435             : 
     436           0 :                 pTypeCollection = &aTypeCollection ;
     437             :             }
     438           0 :         }
     439             :     }
     440             : 
     441           0 :     return pTypeCollection->getTypes() ;
     442             : 
     443             : }
     444             : 
     445             : 
     446           0 : uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getImplementationId()
     447             :         throw( uno::RuntimeException )
     448             : {
     449           0 :     return css::uno::Sequence<sal_Int8>();
     450             : }
     451             : 
     452             : 
     453           0 : uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getClassID()
     454             :         throw ( uno::RuntimeException, std::exception )
     455             : {
     456           0 :     if ( m_bDisposed )
     457           0 :         throw lang::DisposedException();
     458             : 
     459           0 :     return m_aClassID;
     460             : }
     461             : 
     462             : 
     463           0 : OUString SAL_CALL OCommonEmbeddedObject::getClassName()
     464             :         throw ( uno::RuntimeException, std::exception )
     465             : {
     466           0 :     if ( m_bDisposed )
     467           0 :         throw lang::DisposedException();
     468             : 
     469           0 :     return m_aClassName;
     470             : }
     471             : 
     472             : 
     473           0 : void SAL_CALL OCommonEmbeddedObject::setClassInfo(
     474             :                 const uno::Sequence< sal_Int8 >& /*aClassID*/, const OUString& /*aClassName*/ )
     475             :         throw ( lang::NoSupportException,
     476             :                 uno::RuntimeException, std::exception )
     477             : {
     478             :     // the object class info can not be changed explicitly
     479           0 :     throw lang::NoSupportException(); //TODO:
     480             : }
     481             : 
     482             : 
     483           0 : uno::Reference< util::XCloseable > SAL_CALL OCommonEmbeddedObject::getComponent()
     484             :         throw ( uno::RuntimeException, std::exception )
     485             : {
     486           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     487           0 :     if ( m_bDisposed )
     488           0 :         throw lang::DisposedException(); // TODO
     489             : 
     490             :     // add an exception
     491           0 :     if ( m_nObjectState == -1 )
     492             :     {
     493             :         // the object is still not loaded
     494             :         throw uno::RuntimeException( OUString( "Can't store object without persistence!\n" ),
     495           0 :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     496             :     }
     497             : 
     498           0 :     return uno::Reference< util::XCloseable >( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
     499             : }
     500             : 
     501             : 
     502           0 : void SAL_CALL OCommonEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
     503             :     throw ( uno::RuntimeException, std::exception )
     504             : {
     505           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     506           0 :     if ( m_bDisposed )
     507           0 :         throw lang::DisposedException(); // TODO
     508             : 
     509           0 :     if ( !m_pInterfaceContainer )
     510           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     511             : 
     512           0 :     m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
     513           0 :                                                         xListener );
     514           0 : }
     515             : 
     516             : 
     517           0 : void SAL_CALL OCommonEmbeddedObject::removeStateChangeListener(
     518             :                     const uno::Reference< embed::XStateChangeListener >& xListener )
     519             :     throw (uno::RuntimeException, std::exception)
     520             : {
     521           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     522           0 :     if ( m_pInterfaceContainer )
     523           0 :         m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
     524           0 :                                                 xListener );
     525           0 : }
     526             : 
     527             : 
     528           0 : void SAL_CALL OCommonEmbeddedObject::close( sal_Bool bDeliverOwnership )
     529             :     throw ( util::CloseVetoException,
     530             :             uno::RuntimeException, std::exception )
     531             : {
     532           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     533           0 :     if ( m_bClosed )
     534           0 :         throw lang::DisposedException(); // TODO
     535             : 
     536           0 :     uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
     537           0 :     lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     538             : 
     539           0 :     if ( m_pInterfaceContainer )
     540             :     {
     541             :         ::cppu::OInterfaceContainerHelper* pContainer =
     542           0 :             m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
     543           0 :         if ( pContainer != NULL )
     544             :         {
     545           0 :             ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
     546           0 :             while (pIterator.hasMoreElements())
     547             :             {
     548             :                 try
     549             :                 {
     550           0 :                     ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
     551             :                 }
     552           0 :                 catch( const uno::RuntimeException& )
     553             :                 {
     554           0 :                     pIterator.remove();
     555             :                 }
     556           0 :             }
     557             :         }
     558             : 
     559             :         pContainer = m_pInterfaceContainer->getContainer(
     560           0 :                                     ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
     561           0 :         if ( pContainer != NULL )
     562             :         {
     563           0 :             ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
     564           0 :             while (pCloseIterator.hasMoreElements())
     565             :             {
     566             :                 try
     567             :                 {
     568           0 :                     ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
     569             :                 }
     570           0 :                 catch( const uno::RuntimeException& )
     571             :                 {
     572           0 :                     pCloseIterator.remove();
     573             :                 }
     574           0 :             }
     575             :         }
     576             : 
     577           0 :         m_pInterfaceContainer->disposeAndClear( aSource );
     578             :     }
     579             : 
     580           0 :     m_bDisposed = sal_True; // the object is disposed now for outside
     581             : 
     582             :     // it is possible that the document can not be closed, in this case if the argument is false
     583             :     // the exception will be thrown otherwise in addition to exception the object must register itself
     584             :     // as termination listener and listen for document events
     585             : 
     586           0 :     if ( m_pDocHolder )
     587             :     {
     588           0 :         m_pDocHolder->CloseFrame();
     589             : 
     590             :         try {
     591           0 :             m_pDocHolder->CloseDocument( bDeliverOwnership, bDeliverOwnership );
     592             :         }
     593           0 :         catch( const uno::Exception& )
     594             :         {
     595           0 :             if ( bDeliverOwnership )
     596             :             {
     597           0 :                 m_pDocHolder->release();
     598           0 :                 m_pDocHolder = NULL;
     599           0 :                 m_bClosed = sal_True;
     600             :             }
     601             : 
     602           0 :             throw;
     603             :         }
     604             : 
     605           0 :         m_pDocHolder->FreeOffice();
     606             : 
     607           0 :         m_pDocHolder->release();
     608           0 :         m_pDocHolder = NULL;
     609             :     }
     610             : 
     611             :     // TODO: for now the storage will be disposed by the object, but after the document
     612             :     // will use the storage, the storage will be disposed by the document and recreated by the object
     613           0 :     if ( m_xObjectStorage.is() )
     614             :     {
     615           0 :         uno::Reference< lang::XComponent > xComp( m_xObjectStorage, uno::UNO_QUERY );
     616             :         OSL_ENSURE( xComp.is(), "Storage does not support XComponent!\n" );
     617             : 
     618           0 :         if ( xComp.is() )
     619             :         {
     620             :             try {
     621           0 :                 xComp->dispose();
     622           0 :             } catch ( const uno::Exception& ) {}
     623             :         }
     624             : 
     625           0 :         m_xObjectStorage.clear();
     626           0 :         m_xRecoveryStorage.clear();
     627             :     }
     628             : 
     629           0 :     m_bClosed = sal_True; // the closing succeeded
     630           0 : }
     631             : 
     632             : 
     633           0 : void SAL_CALL OCommonEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     634             :     throw ( uno::RuntimeException, std::exception )
     635             : {
     636           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     637           0 :     if ( m_bDisposed )
     638           0 :         throw lang::DisposedException(); // TODO
     639             : 
     640           0 :     if ( !m_pInterfaceContainer )
     641           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     642             : 
     643           0 :     m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener );
     644           0 : }
     645             : 
     646             : 
     647           0 : void SAL_CALL OCommonEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     648             :     throw (uno::RuntimeException, std::exception)
     649             : {
     650           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     651           0 :     if ( m_pInterfaceContainer )
     652           0 :         m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ),
     653           0 :                                                 xListener );
     654           0 : }
     655             : 
     656             : 
     657           0 : void SAL_CALL OCommonEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
     658             :         throw ( uno::RuntimeException, std::exception )
     659             : {
     660           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     661           0 :     if ( m_bDisposed )
     662           0 :         throw lang::DisposedException(); // TODO
     663             : 
     664           0 :     if ( !m_pInterfaceContainer )
     665           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     666             : 
     667           0 :     m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener );
     668           0 : }
     669             : 
     670             : 
     671           0 : void SAL_CALL OCommonEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
     672             :         throw ( uno::RuntimeException, std::exception )
     673             : {
     674           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     675           0 :     if ( m_pInterfaceContainer )
     676           0 :         m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ),
     677           0 :                                                 xListener );
     678           0 : }
     679             : 
     680             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10