LCOV - code coverage report
Current view: top level - stoc/source/proxy_factory - proxyfac.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 124 155 80.0 %
Date: 2012-08-25 Functions: 19 23 82.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 99 196 50.5 %

           Branch data     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                 :            : 
      21                 :            : #include "osl/diagnose.h"
      22                 :            : #include "osl/interlck.h"
      23                 :            : #include "osl/doublecheckedlocking.h"
      24                 :            : #include "osl/mutex.hxx"
      25                 :            : #include "rtl/ref.hxx"
      26                 :            : #include "uno/dispatcher.hxx"
      27                 :            : #include "uno/data.h"
      28                 :            : #include "uno/mapping.hxx"
      29                 :            : #include "uno/environment.hxx"
      30                 :            : #include "typelib/typedescription.hxx"
      31                 :            : #include "cppuhelper/exc_hlp.hxx"
      32                 :            : #include "cppuhelper/implbase2.hxx"
      33                 :            : #include "cppuhelper/implementationentry.hxx"
      34                 :            : #include "cppuhelper/factory.hxx"
      35                 :            : #include "com/sun/star/lang/XServiceInfo.hpp"
      36                 :            : #include "com/sun/star/registry/XRegistryKey.hpp"
      37                 :            : #include "com/sun/star/reflection/XProxyFactory.hpp"
      38                 :            : #include "com/sun/star/uno/RuntimeException.hpp"
      39                 :            : 
      40                 :            : #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
      41                 :            : #define SERVICE_NAME "com.sun.star.reflection.ProxyFactory"
      42                 :            : #define IMPL_NAME "com.sun.star.comp.reflection.ProxyFactory"
      43                 :            : 
      44                 :            : 
      45                 :            : using namespace ::com::sun::star;
      46                 :            : using namespace ::com::sun::star::uno;
      47                 :            : using ::rtl::OUString;
      48                 :            : 
      49                 :            : 
      50                 :            : namespace
      51                 :            : {
      52                 :            : 
      53                 :            : static rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
      54                 :            : 
      55                 :         28 : static OUString proxyfac_getImplementationName()
      56                 :            : {
      57                 :         28 :     return OUSTR(IMPL_NAME);
      58                 :            : }
      59                 :            : 
      60                 :         28 : static Sequence< OUString > proxyfac_getSupportedServiceNames()
      61                 :            : {
      62         [ +  - ]:         28 :     OUString str_name = OUSTR(SERVICE_NAME);
      63         [ +  - ]:         28 :     return Sequence< OUString >( &str_name, 1 );
      64                 :            : }
      65                 :            : 
      66                 :            : //==============================================================================
      67                 :            : struct FactoryImpl : public ::cppu::WeakImplHelper2< lang::XServiceInfo,
      68                 :            :                                                      reflection::XProxyFactory >
      69                 :            : {
      70                 :            :     Environment m_uno_env;
      71                 :            :     Environment m_cpp_env;
      72                 :            :     Mapping m_uno2cpp;
      73                 :            :     Mapping m_cpp2uno;
      74                 :            : 
      75                 :            :     UnoInterfaceReference binuno_queryInterface(
      76                 :            :         UnoInterfaceReference const & unoI,
      77                 :            :         typelib_InterfaceTypeDescription * pTypeDescr );
      78                 :            : 
      79                 :            :     FactoryImpl();
      80                 :            :     virtual ~FactoryImpl();
      81                 :            : 
      82                 :            :     // XServiceInfo
      83                 :            :     virtual OUString SAL_CALL getImplementationName()
      84                 :            :         throw (RuntimeException);
      85                 :            :     virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName )
      86                 :            :         throw (RuntimeException);
      87                 :            :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
      88                 :            :         throw (RuntimeException);
      89                 :            : 
      90                 :            :     // XProxyFactory
      91                 :            :     virtual Reference< XAggregation > SAL_CALL createProxy(
      92                 :            :         Reference< XInterface > const & xTarget )
      93                 :            :         throw (RuntimeException);
      94                 :            : };
      95                 :            : 
      96                 :            : //______________________________________________________________________________
      97                 :       2218 : UnoInterfaceReference FactoryImpl::binuno_queryInterface(
      98                 :            :     UnoInterfaceReference const & unoI,
      99                 :            :     typelib_InterfaceTypeDescription * pTypeDescr )
     100                 :            : {
     101                 :            :     // init queryInterface() td
     102                 :            :     static typelib_TypeDescription * s_pQITD = 0;
     103         [ +  + ]:       2218 :     if (s_pQITD == 0)
     104                 :            :     {
     105 [ +  - ][ +  - ]:         15 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     106         [ +  - ]:         15 :         if (s_pQITD == 0)
     107                 :            :         {
     108                 :         15 :             typelib_TypeDescription * pTXInterfaceDescr = 0;
     109 [ +  - ][ +  - ]:         15 :             TYPELIB_DANGER_GET(
         [ -  + ][ +  - ]
         [ -  + ][ #  # ]
     110                 :            :                 &pTXInterfaceDescr,
     111                 :            :                 ::getCppuType( reinterpret_cast< Reference< XInterface >
     112                 :            :                                const * >(0) ).getTypeLibType() );
     113                 :         15 :             typelib_TypeDescription * pQITD = 0;
     114                 :            :             typelib_typedescriptionreference_getDescription(
     115                 :            :                 &pQITD, reinterpret_cast< typelib_InterfaceTypeDescription * >(
     116                 :         15 :                     pTXInterfaceDescr )->ppAllMembers[ 0 ] );
     117 [ -  + ][ +  - ]:         15 :             TYPELIB_DANGER_RELEASE( pTXInterfaceDescr );
     118                 :            :             OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
     119                 :         15 :             s_pQITD = pQITD;
     120         [ +  - ]:         15 :         }
     121                 :            :     }
     122                 :            :     else
     123                 :            :     {
     124                 :            :         OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
     125                 :            :     }
     126                 :            : 
     127                 :            :     void * args[ 1 ];
     128                 :            :     args[ 0 ] = &reinterpret_cast< typelib_TypeDescription * >(
     129                 :       2218 :         pTypeDescr )->pWeakRef;
     130                 :            :     uno_Any ret_val, exc_space;
     131                 :       2218 :     uno_Any * exc = &exc_space;
     132                 :            : 
     133         [ +  - ]:       2218 :     unoI.dispatch( s_pQITD, &ret_val, args, &exc );
     134                 :            : 
     135         [ +  - ]:       2218 :     if (exc == 0)
     136                 :            :     {
     137                 :       2218 :         UnoInterfaceReference ret;
     138         [ +  + ]:       2218 :         if (ret_val.pType->eTypeClass == typelib_TypeClass_INTERFACE)
     139                 :            :         {
     140                 :            :             ret.set( *reinterpret_cast< uno_Interface ** >(ret_val.pData),
     141         [ +  - ]:       1806 :                      SAL_NO_ACQUIRE );
     142                 :       1806 :             typelib_typedescriptionreference_release( ret_val.pType );
     143                 :            :         }
     144                 :            :         else
     145                 :            :         {
     146                 :        412 :             uno_any_destruct( &ret_val, 0 );
     147                 :            :         }
     148 [ +  - ][ +  - ]:       2218 :         return ret;
     149                 :            :     }
     150                 :            :     else
     151                 :            :     {
     152                 :            :         // exception occurred:
     153                 :            :         OSL_ENSURE(
     154                 :            :             typelib_typedescriptionreference_isAssignableFrom(
     155                 :            :                 ::getCppuType( reinterpret_cast<
     156                 :            :                                RuntimeException const * >(0) ).getTypeLibType(),
     157                 :            :                 exc->pType ),
     158                 :            :             "### RuntimeException expected!" );
     159                 :          0 :         Any cpp_exc;
     160                 :            :         uno_type_copyAndConvertData(
     161         [ #  # ]:          0 :             &cpp_exc, exc, ::getCppuType( &cpp_exc ).getTypeLibType(),
     162                 :          0 :             m_uno2cpp.get() );
     163                 :          0 :         uno_any_destruct( exc, 0 );
     164         [ #  # ]:          0 :         ::cppu::throwException( cpp_exc );
     165                 :            :         OSL_ASSERT( 0 ); // way of no return
     166                 :       2218 :         return UnoInterfaceReference(); // for dummy
     167                 :            :     }
     168                 :            : }
     169                 :            : 
     170                 :            : //==============================================================================
     171                 :            : struct ProxyRoot : public ::cppu::OWeakAggObject
     172                 :            : {
     173                 :            :     // XAggregation
     174                 :            :     virtual Any SAL_CALL queryAggregation( Type const & rType )
     175                 :            :         throw (RuntimeException);
     176                 :            : 
     177                 :            :     virtual ~ProxyRoot();
     178                 :            :     inline ProxyRoot( ::rtl::Reference< FactoryImpl > const & factory,
     179                 :            :                       Reference< XInterface > const & xTarget );
     180                 :            : 
     181                 :            :     ::rtl::Reference< FactoryImpl > m_factory;
     182                 :            : 
     183                 :            : private:
     184                 :            :     UnoInterfaceReference m_target;
     185                 :            : };
     186                 :            : 
     187                 :            : //==============================================================================
     188         [ +  - ]:       1388 : struct binuno_Proxy : public uno_Interface
     189                 :            : {
     190                 :            :     oslInterlockedCount m_nRefCount;
     191                 :            :     ::rtl::Reference< ProxyRoot > m_root;
     192                 :            :     UnoInterfaceReference m_target;
     193                 :            :     OUString m_oid;
     194                 :            :     TypeDescription m_typeDescr;
     195                 :            : 
     196                 :            :     inline binuno_Proxy(
     197                 :            :         ::rtl::Reference< ProxyRoot > const & root,
     198                 :            :         UnoInterfaceReference const & target,
     199                 :            :         OUString const & oid, TypeDescription const & typeDescr );
     200                 :            : };
     201                 :            : 
     202                 :            : extern "C"
     203                 :            : {
     204                 :            : 
     205                 :            : //------------------------------------------------------------------------------
     206                 :       1388 : static void SAL_CALL binuno_proxy_free(
     207                 :            :     uno_ExtEnvironment * pEnv, void * pProxy )
     208                 :            : {
     209                 :            :     (void) pEnv; // avoid warning about unused parameter
     210                 :            :     binuno_Proxy * proxy = static_cast< binuno_Proxy * >(
     211                 :       1388 :         reinterpret_cast< uno_Interface * >( pProxy ) );
     212                 :            :     OSL_ASSERT( proxy->m_root->m_factory->m_uno_env.get()->pExtEnv == pEnv );
     213         [ +  - ]:       1388 :     delete proxy;
     214                 :       1388 : }
     215                 :            : 
     216                 :            : //------------------------------------------------------------------------------
     217                 :       5122 : static void SAL_CALL binuno_proxy_acquire( uno_Interface * pUnoI )
     218                 :            : {
     219                 :       5122 :     binuno_Proxy * that = static_cast< binuno_Proxy * >( pUnoI );
     220         [ +  + ]:       5122 :     if (osl_incrementInterlockedCount( &that->m_nRefCount ) == 1)
     221                 :            :     {
     222                 :            :         // rebirth of zombie
     223                 :            :         uno_ExtEnvironment * uno_env =
     224                 :         44 :             that->m_root->m_factory->m_uno_env.get()->pExtEnv;
     225                 :            :         OSL_ASSERT( uno_env != 0 );
     226                 :            :         (*uno_env->registerProxyInterface)(
     227                 :            :             uno_env, reinterpret_cast< void ** >( &pUnoI ), binuno_proxy_free,
     228                 :            :             that->m_oid.pData,
     229                 :            :             reinterpret_cast< typelib_InterfaceTypeDescription * >(
     230                 :         44 :                 that->m_typeDescr.get() ) );
     231                 :            :         OSL_ASSERT( that == static_cast< binuno_Proxy * >( pUnoI ) );
     232                 :            :     }
     233                 :       5122 : }
     234                 :            : 
     235                 :            : //------------------------------------------------------------------------------
     236                 :       6444 : static void SAL_CALL binuno_proxy_release( uno_Interface * pUnoI )
     237                 :            : {
     238                 :       6444 :     binuno_Proxy * that = static_cast< binuno_Proxy * >( pUnoI );
     239         [ +  + ]:       6444 :     if (osl_decrementInterlockedCount( &that->m_nRefCount ) == 0)
     240                 :            :     {
     241                 :            :         uno_ExtEnvironment * uno_env =
     242                 :       1366 :             that->m_root->m_factory->m_uno_env.get()->pExtEnv;
     243                 :            :         OSL_ASSERT( uno_env != 0 );
     244                 :       1366 :         (*uno_env->revokeInterface)( uno_env, pUnoI );
     245                 :            :     }
     246                 :       6444 : }
     247                 :            : 
     248                 :            : //------------------------------------------------------------------------------
     249                 :       2650 : static void SAL_CALL binuno_proxy_dispatch(
     250                 :            :     uno_Interface * pUnoI, const typelib_TypeDescription * pMemberType,
     251                 :            :     void * pReturn, void * pArgs [], uno_Any ** ppException )
     252                 :            : {
     253                 :       2650 :     binuno_Proxy * that = static_cast< binuno_Proxy * >( pUnoI );
     254   [ +  -  -  + ]:       2650 :     switch (reinterpret_cast< typelib_InterfaceMemberTypeDescription const * >(
     255                 :            :                 pMemberType )->nPosition)
     256                 :            :     {
     257                 :            :     case 0: // queryInterface()
     258                 :            :     {
     259                 :            :         try
     260                 :            :         {
     261                 :            :             Type const & rType =
     262                 :        428 :                 *reinterpret_cast< Type const * >( pArgs[ 0 ] );
     263         [ +  - ]:        428 :             Any ret( that->m_root->queryInterface( rType ) );
     264                 :            :             uno_type_copyAndConvertData(
     265         [ +  - ]:        428 :                 pReturn, &ret, ::getCppuType( &ret ).getTypeLibType(),
     266                 :        856 :                 that->m_root->m_factory->m_cpp2uno.get() );
     267                 :        428 :             *ppException = 0; // no exc
     268                 :            :         }
     269         [ #  # ]:          0 :         catch (RuntimeException &)
     270                 :            :         {
     271         [ #  # ]:          0 :             Any exc( ::cppu::getCaughtException() );
     272                 :            :             uno_type_any_constructAndConvert(
     273                 :          0 :                 *ppException, const_cast< void * >(exc.getValue()),
     274                 :            :                 exc.getValueTypeRef(),
     275                 :          0 :                 that->m_root->m_factory->m_cpp2uno.get() );
     276                 :            :         }
     277                 :        428 :         break;
     278                 :            :     }
     279                 :            :     case 1: // acquire()
     280                 :          0 :         binuno_proxy_acquire( pUnoI );
     281                 :          0 :         *ppException = 0; // no exc
     282                 :          0 :         break;
     283                 :            :     case 2: // release()
     284                 :          0 :         binuno_proxy_release( pUnoI );
     285                 :          0 :         *ppException = 0; // no exc
     286                 :          0 :         break;
     287                 :            :     default:
     288                 :       2222 :         that->m_target.dispatch( pMemberType, pReturn, pArgs, ppException );
     289                 :       2222 :         break;
     290                 :            :     }
     291                 :       2650 : }
     292                 :            : 
     293                 :            : }
     294                 :            : 
     295                 :            : //______________________________________________________________________________
     296                 :       1806 : inline binuno_Proxy::binuno_Proxy(
     297                 :            :     ::rtl::Reference< ProxyRoot > const & root,
     298                 :            :     UnoInterfaceReference const & target,
     299                 :            :     OUString const & oid, TypeDescription const & typeDescr )
     300                 :            :     : m_nRefCount( 1 ),
     301                 :            :       m_root( root ),
     302                 :            :       m_target( target ),
     303                 :            :       m_oid( oid ),
     304         [ +  - ]:       1806 :       m_typeDescr( typeDescr )
     305                 :            : {
     306                 :       1806 :     uno_Interface::acquire = binuno_proxy_acquire;
     307                 :       1806 :     uno_Interface::release = binuno_proxy_release;
     308                 :       1806 :     uno_Interface::pDispatcher = binuno_proxy_dispatch;
     309                 :       1806 : }
     310                 :            : 
     311                 :            : //______________________________________________________________________________
     312         [ +  - ]:        265 : ProxyRoot::~ProxyRoot()
     313                 :            : {
     314         [ -  + ]:        530 : }
     315                 :            : 
     316                 :            : //______________________________________________________________________________
     317                 :        683 : inline ProxyRoot::ProxyRoot(
     318                 :            :     ::rtl::Reference< FactoryImpl > const & factory,
     319                 :            :     Reference< XInterface > const & xTarget )
     320                 :        683 :     : m_factory( factory )
     321                 :            : {
     322                 :        683 :     m_factory->m_cpp2uno.mapInterface(
     323         [ +  - ]:        683 :         reinterpret_cast< void ** >( &m_target.m_pUnoI ), xTarget.get(),
     324   [ +  -  +  - ]:       1366 :         ::getCppuType( &xTarget ) );
     325                 :            :     OSL_ENSURE( m_target.is(), "### mapping interface failed!" );
     326                 :        683 : }
     327                 :            : 
     328                 :            : //______________________________________________________________________________
     329                 :       4810 : Any ProxyRoot::queryAggregation( Type const & rType )
     330                 :            :     throw (RuntimeException)
     331                 :            : {
     332                 :       4810 :     Any ret( OWeakAggObject::queryAggregation( rType ) );
     333         [ +  + ]:       4810 :     if (! ret.hasValue())
     334                 :            :     {
     335                 :       2734 :         typelib_TypeDescription * pTypeDescr = 0;
     336 [ +  - ][ -  + ]:       2734 :         TYPELIB_DANGER_GET( &pTypeDescr, rType.getTypeLibType() );
         [ +  - ][ +  + ]
                 [ +  - ]
     337                 :            :         try
     338                 :            :         {
     339                 :       2734 :             Reference< XInterface > xProxy;
     340                 :       2734 :             uno_ExtEnvironment * cpp_env = m_factory->m_cpp_env.get()->pExtEnv;
     341                 :            :             OSL_ASSERT( cpp_env != 0 );
     342                 :            : 
     343                 :            :             // mind a new delegator, calculate current root:
     344                 :            :             Reference< XInterface > xRoot(
     345         [ +  - ]:       2734 :                 static_cast< OWeakObject * >(this), UNO_QUERY_THROW );
     346                 :       2734 :             OUString oid;
     347 [ +  - ][ +  - ]:       2734 :             (*cpp_env->getObjectIdentifier)( cpp_env, &oid.pData, xRoot.get() );
     348                 :            :             OSL_ASSERT( !oid.isEmpty() );
     349                 :            : 
     350                 :            :             (*cpp_env->getRegisteredInterface)(
     351                 :            :                 cpp_env, reinterpret_cast< void ** >( &xProxy ),
     352                 :            :                 oid.pData, reinterpret_cast<
     353         [ +  - ]:       2734 :                 typelib_InterfaceTypeDescription * >(pTypeDescr) );
     354         [ +  + ]:       2734 :             if (! xProxy.is())
     355                 :            :             {
     356                 :            :                 // perform query on target:
     357                 :            :                 UnoInterfaceReference proxy_target(
     358                 :            :                     m_factory->binuno_queryInterface(
     359                 :            :                         m_target, reinterpret_cast<
     360         [ +  - ]:       2218 :                         typelib_InterfaceTypeDescription * >(pTypeDescr) ) );
     361         [ +  + ]:       2218 :                 if (proxy_target.is())
     362                 :            :                 {
     363                 :            :                     // ensure root's object entries:
     364                 :       1806 :                     UnoInterfaceReference root;
     365                 :       1806 :                     m_factory->m_cpp2uno.mapInterface(
     366                 :            :                         reinterpret_cast< void ** >( &root.m_pUnoI ),
     367   [ +  -  +  - ]:       3612 :                         xRoot.get(), ::getCppuType( &xRoot ) );
                 [ +  - ]
     368                 :            : 
     369                 :            :                     UnoInterfaceReference proxy(
     370                 :            :                         // ref count initially 1:
     371         [ +  - ]:       1806 :                         new binuno_Proxy( this, proxy_target, oid, pTypeDescr ),
     372         [ +  - ]:       3612 :                         SAL_NO_ACQUIRE );
     373                 :            :                     uno_ExtEnvironment * uno_env =
     374                 :       1806 :                         m_factory->m_uno_env.get()->pExtEnv;
     375                 :            :                     OSL_ASSERT( uno_env != 0 );
     376                 :            :                     (*uno_env->registerProxyInterface)(
     377                 :            :                         uno_env, reinterpret_cast< void ** >( &proxy.m_pUnoI ),
     378                 :            :                         binuno_proxy_free, oid.pData,
     379                 :            :                         reinterpret_cast< typelib_InterfaceTypeDescription * >(
     380         [ +  - ]:       1806 :                             pTypeDescr ) );
     381                 :            : 
     382                 :       1806 :                     m_factory->m_uno2cpp.mapInterface(
     383                 :            :                         reinterpret_cast< void ** >( &xProxy ),
     384 [ +  - ][ +  - ]:       3612 :                         proxy.get(), pTypeDescr );
                 [ +  - ]
     385         [ +  - ]:       2218 :                 }
     386                 :            :             }
     387         [ +  + ]:       2734 :             if (xProxy.is())
     388                 :       2734 :                 ret.setValue( &xProxy, pTypeDescr );
     389                 :            :         }
     390                 :          0 :         catch (...) // finally
     391                 :            :         {
     392   [ #  #  #  # ]:          0 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     393                 :          0 :             throw;
     394                 :            :         }
     395 [ -  + ][ +  - ]:       2734 :         TYPELIB_DANGER_RELEASE( pTypeDescr );
     396                 :            :     }
     397                 :       4810 :     return ret;
     398                 :            : }
     399                 :            : 
     400                 :            : //##############################################################################
     401                 :            : 
     402                 :            : //______________________________________________________________________________
     403 [ +  - ][ +  - ]:        112 : FactoryImpl::FactoryImpl()
         [ +  - ][ +  - ]
     404                 :            : {
     405         [ +  - ]:        112 :     OUString uno = OUSTR(UNO_LB_UNO);
     406         [ +  - ]:        112 :     OUString cpp = OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
     407                 :            : 
     408                 :            :     uno_getEnvironment(
     409                 :        112 :         reinterpret_cast< uno_Environment ** >( &m_uno_env ), uno.pData, 0 );
     410                 :            :     OSL_ENSURE( m_uno_env.is(), "### cannot get binary uno env!" );
     411                 :            : 
     412                 :            :     uno_getEnvironment(
     413                 :        112 :         reinterpret_cast< uno_Environment ** >( &m_cpp_env ), cpp.pData, 0 );
     414                 :            :     OSL_ENSURE( m_cpp_env.is(), "### cannot get C++ uno env!" );
     415                 :            : 
     416                 :            :     uno_getMapping(
     417                 :            :         reinterpret_cast< uno_Mapping ** >( &m_uno2cpp ),
     418                 :        112 :         m_uno_env.get(), m_cpp_env.get(), 0 );
     419                 :            :     OSL_ENSURE( m_uno2cpp.is(), "### cannot get bridge uno <-> C++!" );
     420                 :            : 
     421                 :            :     uno_getMapping(
     422                 :            :         reinterpret_cast< uno_Mapping ** >( &m_cpp2uno ),
     423                 :        112 :         m_cpp_env.get(), m_uno_env.get(), 0 );
     424                 :            :     OSL_ENSURE( m_cpp2uno.is(), "### cannot get bridge C++ <-> uno!" );
     425                 :            : 
     426         [ +  - ]:        112 :     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
     427                 :        112 : }
     428                 :            : 
     429                 :            : //______________________________________________________________________________
     430 [ +  - ][ +  - ]:         99 : FactoryImpl::~FactoryImpl()
         [ +  - ][ +  - ]
     431                 :            : {
     432         [ +  - ]:         99 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
     433         [ -  + ]:        198 : }
     434                 :            : 
     435                 :            : // XProxyFactory
     436                 :            : //______________________________________________________________________________
     437                 :        683 : Reference< XAggregation > FactoryImpl::createProxy(
     438                 :            :     Reference< XInterface > const & xTarget )
     439                 :            :     throw (RuntimeException)
     440                 :            : {
     441 [ +  - ][ +  - ]:        683 :     return new ProxyRoot( this, xTarget );
                 [ +  - ]
     442                 :            : }
     443                 :            : 
     444                 :            : // XServiceInfo
     445                 :            : //______________________________________________________________________________
     446                 :          0 : OUString FactoryImpl::getImplementationName()
     447                 :            :     throw (RuntimeException)
     448                 :            : {
     449                 :          0 :     return proxyfac_getImplementationName();
     450                 :            : }
     451                 :            : 
     452                 :            : //______________________________________________________________________________
     453                 :          0 : sal_Bool FactoryImpl::supportsService( const OUString & rServiceName )
     454                 :            :     throw (RuntimeException)
     455                 :            : {
     456                 :          0 :     Sequence< OUString > const & rSNL = getSupportedServiceNames();
     457                 :          0 :     OUString const * pArray = rSNL.getConstArray();
     458         [ #  # ]:          0 :     for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
     459                 :            :     {
     460         [ #  # ]:          0 :         if (rServiceName.equals( pArray[ nPos ] ))
     461                 :          0 :             return true;
     462                 :            :     }
     463                 :          0 :     return false;
     464                 :            : }
     465                 :            : 
     466                 :            : //______________________________________________________________________________
     467                 :          0 : Sequence< OUString > FactoryImpl::getSupportedServiceNames()
     468                 :            :     throw(::com::sun::star::uno::RuntimeException)
     469                 :            : {
     470                 :          0 :     return proxyfac_getSupportedServiceNames();
     471                 :            : }
     472                 :            : 
     473                 :            : //==============================================================================
     474                 :        688 : static Reference< XInterface > SAL_CALL proxyfac_create(
     475                 :            :     SAL_UNUSED_PARAMETER Reference< XComponentContext > const & )
     476                 :            :     throw (Exception)
     477                 :            : {
     478                 :        688 :     Reference< XInterface > xRet;
     479                 :            :     {
     480 [ +  - ][ +  - ]:        688 :     ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
     481 [ +  + ][ +  - ]:        688 :     static WeakReference < XInterface > rwInstance;
         [ +  - ][ #  # ]
     482 [ +  - ][ +  - ]:        688 :     xRet = rwInstance;
     483                 :            : 
     484         [ +  + ]:        688 :     if (! xRet.is())
     485                 :            :     {
     486 [ +  - ][ +  - ]:        112 :         xRet = static_cast< ::cppu::OWeakObject * >(new FactoryImpl);
     487         [ +  - ]:        112 :         rwInstance = xRet;
     488         [ +  - ]:        688 :     }
     489                 :            :     }
     490                 :        688 :     return xRet;
     491                 :            : }
     492                 :            : 
     493                 :            : static ::cppu::ImplementationEntry g_entries [] =
     494                 :            : {
     495                 :            :     {
     496                 :            :         proxyfac_create, proxyfac_getImplementationName,
     497                 :            :         proxyfac_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
     498                 :            :         &g_moduleCount.modCnt, 0
     499                 :            :     },
     500                 :            :     { 0, 0, 0, 0, 0, 0 }
     501                 :            : };
     502                 :            : 
     503                 :            : }
     504                 :            : 
     505                 :            : extern "C"
     506                 :            : {
     507                 :            : 
     508                 :          0 : SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_canUnload( TimeValue * pTime )
     509                 :            : {
     510                 :          0 :     return g_moduleCount.canUnload( &g_moduleCount, pTime );
     511                 :            : }
     512                 :            : 
     513                 :         28 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
     514                 :            :     const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
     515                 :            : {
     516                 :            :     return ::cppu::component_getFactoryHelper(
     517                 :         28 :         pImplName, pServiceManager, pRegistryKey, g_entries );
     518                 :            : }
     519                 :            : 
     520                 :            : }
     521                 :            : 
     522                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10