LCOV - code coverage report
Current view: top level - embeddedobj/source/commonembedding - miscobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 202 298 67.8 %
Date: 2012-08-25 Functions: 17 24 70.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 173 538 32.2 %

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

Generated by: LCOV version 1.10