LCOV - code coverage report
Current view: top level - stoc/source/corereflection - crefl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 112 151 74.2 %
Date: 2012-08-25 Functions: 20 27 74.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 129 305 42.3 %

           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                 :            : #include <cppuhelper/queryinterface.hxx>
      21                 :            : #include <cppuhelper/implementationentry.hxx>
      22                 :            : 
      23                 :            : #include <com/sun/star/lang/XComponent.hpp>
      24                 :            : #include <com/sun/star/reflection/XTypeDescription.hpp>
      25                 :            : #include "com/sun/star/uno/RuntimeException.hpp"
      26                 :            : 
      27                 :            : using namespace com::sun::star;
      28                 :            : using namespace com::sun::star::lang;
      29                 :            : using namespace com::sun::star::registry;
      30                 :            : using namespace cppu;
      31                 :            : using namespace osl;
      32                 :            : 
      33                 :            : using ::rtl::OUString;
      34                 :            : using ::rtl::OUStringToOString;
      35                 :            : using ::rtl::OString;
      36                 :            : 
      37                 :            : #include "base.hxx"
      38                 :            : 
      39                 :            : 
      40                 :            : namespace stoc_corefl
      41                 :            : {
      42                 :            : 
      43                 :            : static const sal_Int32 CACHE_SIZE = 256;
      44                 :            : 
      45                 :            : #define SERVICENAME "com.sun.star.reflection.CoreReflection"
      46                 :            : #define IMPLNAME    "com.sun.star.comp.stoc.CoreReflection"
      47                 :            : 
      48                 :            : // can be static, as every client of the core reflection keeps a reference to the
      49                 :            : // core reflection, so refcounting can be done here.
      50                 :            : static rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
      51                 :            : 
      52                 :        199 : static Sequence< OUString > core_getSupportedServiceNames()
      53                 :            : {
      54                 :        199 :     Sequence< OUString > seqNames(1);
      55 [ +  - ][ +  - ]:        199 :     seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
      56                 :        199 :     return seqNames;
      57                 :            : }
      58                 :            : 
      59                 :        199 : static OUString core_getImplementationName()
      60                 :            : {
      61                 :        199 :     return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
      62                 :            : }
      63                 :            : //__________________________________________________________________________________________________
      64                 :       4662 : IdlReflectionServiceImpl::IdlReflectionServiceImpl(
      65                 :            :     const Reference< XComponentContext > & xContext )
      66                 :            :     : OComponentHelper( _aComponentMutex )
      67         [ +  - ]:       4662 :     , _xMgr( xContext->getServiceManager(), UNO_QUERY )
      68 [ +  - ][ +  - ]:       9324 :     , _aElements( CACHE_SIZE )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      69                 :            : {
      70         [ +  - ]:       4662 :     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
      71         [ +  - ]:       4662 :     xContext->getValueByName( OUString( RTL_CONSTASCII_USTRINGPARAM(
      72 [ +  - ][ +  - ]:       4662 :         "/singletons/com.sun.star.reflection.theTypeDescriptionManager") ) ) >>= _xTDMgr;
                 [ +  - ]
      73                 :            :     OSL_ENSURE( _xTDMgr.is(), "### cannot get singleton \"TypeDescriptionManager\" from context!" );
      74                 :       4662 : }
      75                 :            : //__________________________________________________________________________________________________
      76 [ +  - ][ +  - ]:       4132 : IdlReflectionServiceImpl::~IdlReflectionServiceImpl()
         [ +  - ][ +  - ]
      77                 :            : {
      78         [ +  - ]:       4132 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
      79         [ -  + ]:       8264 : }
      80                 :            : 
      81                 :            : // XInterface
      82                 :            : //__________________________________________________________________________________________________
      83                 :      13636 : Any IdlReflectionServiceImpl::queryInterface( const Type & rType )
      84                 :            :     throw(::com::sun::star::uno::RuntimeException)
      85                 :            : {
      86                 :            :     Any aRet( ::cppu::queryInterface(
      87                 :            :         rType,
      88                 :            :         static_cast< XIdlReflection * >( this ),
      89                 :            :         static_cast< XHierarchicalNameAccess * >( this ),
      90         [ +  - ]:      13636 :         static_cast< XServiceInfo * >( this ) ) );
      91                 :            : 
      92 [ +  + ][ +  - ]:      13636 :     return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
      93                 :            : }
      94                 :            : //__________________________________________________________________________________________________
      95                 :     230284 : void IdlReflectionServiceImpl::acquire() throw()
      96                 :            : {
      97                 :     230284 :     OComponentHelper::acquire();
      98                 :     230284 : }
      99                 :            : //__________________________________________________________________________________________________
     100                 :     202914 : void IdlReflectionServiceImpl::release() throw()
     101                 :            : {
     102                 :     202914 :     OComponentHelper::release();
     103                 :     202914 : }
     104                 :            : 
     105                 :            : // XTypeProvider
     106                 :            : //__________________________________________________________________________________________________
     107                 :          0 : Sequence< Type > IdlReflectionServiceImpl::getTypes()
     108                 :            :     throw (::com::sun::star::uno::RuntimeException)
     109                 :            : {
     110                 :            :     static OTypeCollection * s_pTypes = 0;
     111         [ #  # ]:          0 :     if (! s_pTypes)
     112                 :            :     {
     113         [ #  # ]:          0 :         MutexGuard aGuard( _aComponentMutex );
     114         [ #  # ]:          0 :         if (! s_pTypes)
     115                 :            :         {
     116                 :            :             static OTypeCollection s_aTypes(
     117         [ #  # ]:          0 :                 ::getCppuType( (const Reference< XIdlReflection > *)0 ),
     118         [ #  # ]:          0 :                 ::getCppuType( (const Reference< XHierarchicalNameAccess > *)0 ),
     119         [ #  # ]:          0 :                 ::getCppuType( (const Reference< XServiceInfo > *)0 ),
     120 [ #  # ][ #  # ]:          0 :                 OComponentHelper::getTypes() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     121                 :          0 :             s_pTypes = &s_aTypes;
     122         [ #  # ]:          0 :         }
     123                 :            :     }
     124                 :          0 :     return s_pTypes->getTypes();
     125                 :            : }
     126                 :            : //__________________________________________________________________________________________________
     127                 :          0 : Sequence< sal_Int8 > IdlReflectionServiceImpl::getImplementationId()
     128                 :            :     throw (::com::sun::star::uno::RuntimeException)
     129                 :            : {
     130                 :            :     static OImplementationId * s_pId = 0;
     131         [ #  # ]:          0 :     if (! s_pId)
     132                 :            :     {
     133         [ #  # ]:          0 :         MutexGuard aGuard( _aComponentMutex );
     134         [ #  # ]:          0 :         if (! s_pId)
     135                 :            :         {
     136 [ #  # ][ #  # ]:          0 :             static OImplementationId s_aId;
     137                 :          0 :             s_pId = &s_aId;
     138         [ #  # ]:          0 :         }
     139                 :            :     }
     140                 :          0 :     return s_pId->getImplementationId();
     141                 :            : }
     142                 :            : 
     143                 :            : // XComponent
     144                 :            : //__________________________________________________________________________________________________
     145                 :       4368 : void IdlReflectionServiceImpl::dispose()
     146                 :            :     throw(::com::sun::star::uno::RuntimeException)
     147                 :            : {
     148         [ +  - ]:       4368 :     OComponentHelper::dispose();
     149                 :            : 
     150         [ +  - ]:       4368 :     MutexGuard aGuard( _aComponentMutex );
     151 [ +  - ][ +  - ]:       4368 :     _aElements.clear();
     152                 :            : #ifdef TEST_LIST_CLASSES
     153                 :            :     OSL_ENSURE( g_aClassNames.empty(), "### idl classes still alive!" );
     154                 :            :     ClassNameList::const_iterator iPos( g_aClassNames.begin() );
     155                 :            :     while (iPos != g_aClassNames.end())
     156                 :            :     {
     157                 :            :         OUString aName( *iPos );
     158                 :            :         ++iPos;
     159                 :            :     }
     160                 :            : #endif
     161                 :       4368 : }
     162                 :            : 
     163                 :            : // XServiceInfo
     164                 :            : //__________________________________________________________________________________________________
     165                 :          0 : OUString IdlReflectionServiceImpl::getImplementationName()
     166                 :            :     throw(::com::sun::star::uno::RuntimeException)
     167                 :            : {
     168                 :          0 :     return core_getImplementationName();
     169                 :            : }
     170                 :            : //__________________________________________________________________________________________________
     171                 :          0 : sal_Bool IdlReflectionServiceImpl::supportsService( const OUString & rServiceName )
     172                 :            :     throw(::com::sun::star::uno::RuntimeException)
     173                 :            : {
     174                 :          0 :     const Sequence< OUString > & rSNL = getSupportedServiceNames();
     175                 :          0 :     const OUString * pArray = rSNL.getConstArray();
     176         [ #  # ]:          0 :     for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
     177                 :            :     {
     178         [ #  # ]:          0 :         if (pArray[nPos] == rServiceName)
     179                 :          0 :             return sal_True;
     180                 :            :     }
     181                 :          0 :     return sal_False;
     182                 :            : }
     183                 :            : //__________________________________________________________________________________________________
     184                 :          0 : Sequence< OUString > IdlReflectionServiceImpl::getSupportedServiceNames()
     185                 :            :     throw(::com::sun::star::uno::RuntimeException)
     186                 :            : {
     187                 :          0 :     return core_getSupportedServiceNames();
     188                 :            : }
     189                 :            : 
     190                 :            : // XIdlReflection
     191                 :            : //__________________________________________________________________________________________________
     192                 :          0 : Reference< XIdlClass > IdlReflectionServiceImpl::getType( const Any & rObj )
     193                 :            :     throw(::com::sun::star::uno::RuntimeException)
     194                 :            : {
     195         [ #  # ]:          0 :     return (rObj.hasValue() ? forType( rObj.getValueTypeRef() ) : Reference< XIdlClass >());
     196                 :            : }
     197                 :            : 
     198                 :            : //__________________________________________________________________________________________________
     199                 :      25713 : inline Reference< XIdlClass > IdlReflectionServiceImpl::constructClass(
     200                 :            :     typelib_TypeDescription * pTypeDescr )
     201                 :            : {
     202                 :            :     OSL_ENSURE( pTypeDescr->eTypeClass != typelib_TypeClass_TYPEDEF, "### unexpected typedef!" );
     203                 :            : 
     204   [ +  +  +  +  :      25713 :     switch (pTypeDescr->eTypeClass)
                +  +  - ]
     205                 :            :     {
     206                 :            :     case typelib_TypeClass_VOID:
     207                 :            :     case typelib_TypeClass_CHAR:
     208                 :            :     case typelib_TypeClass_BOOLEAN:
     209                 :            :     case typelib_TypeClass_BYTE:
     210                 :            :     case typelib_TypeClass_SHORT:
     211                 :            :     case typelib_TypeClass_UNSIGNED_SHORT:
     212                 :            :     case typelib_TypeClass_LONG:
     213                 :            :     case typelib_TypeClass_UNSIGNED_LONG:
     214                 :            :     case typelib_TypeClass_HYPER:
     215                 :            :     case typelib_TypeClass_UNSIGNED_HYPER:
     216                 :            :     case typelib_TypeClass_FLOAT:
     217                 :            :     case typelib_TypeClass_DOUBLE:
     218                 :            :     case typelib_TypeClass_STRING:
     219                 :            :     case typelib_TypeClass_ANY:
     220 [ +  - ][ +  - ]:       1407 :         return new IdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
                 [ +  - ]
     221                 :            : 
     222                 :            :     case TypeClass_ENUM:
     223 [ +  - ][ +  - ]:        122 :         return new EnumIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
                 [ +  - ]
     224                 :            : 
     225                 :            :     case typelib_TypeClass_STRUCT:
     226                 :            :     case typelib_TypeClass_UNION:
     227                 :            :     case typelib_TypeClass_EXCEPTION:
     228 [ +  - ][ +  - ]:        946 :         return new CompoundIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
                 [ +  - ]
     229                 :            : 
     230                 :            :     case typelib_TypeClass_ARRAY:
     231                 :            :     case typelib_TypeClass_SEQUENCE:
     232 [ +  - ][ +  - ]:       1347 :         return new ArrayIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
                 [ +  - ]
     233                 :            : 
     234                 :            :     case typelib_TypeClass_INTERFACE:
     235 [ +  - ][ +  - ]:      21766 :         return new InterfaceIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
                 [ +  - ]
     236                 :            : 
     237                 :            :     case typelib_TypeClass_TYPE:
     238 [ +  - ][ +  - ]:        125 :         return new IdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
                 [ +  - ]
     239                 :            : 
     240                 :            :     default:
     241                 :            : #if OSL_DEBUG_LEVEL > 1
     242                 :            :         OSL_TRACE( "### corereflection type unsupported: " );
     243                 :            :         OString aName( OUStringToOString( pTypeDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
     244                 :            :         OSL_TRACE( "%s", aName.getStr() );
     245                 :            :         OSL_TRACE( "\n" );
     246                 :            : #endif
     247                 :      25713 :         return Reference< XIdlClass >();
     248                 :            :     }
     249                 :            : }
     250                 :            : //__________________________________________________________________________________________________
     251                 :     438117 : Reference< XIdlClass > IdlReflectionServiceImpl::forName( const OUString & rTypeName )
     252                 :            :     throw(::com::sun::star::uno::RuntimeException)
     253                 :            : {
     254                 :     438117 :     Reference< XIdlClass > xRet;
     255         [ +  - ]:     438117 :     Any aAny( _aElements.getValue( rTypeName ) );
     256                 :            : 
     257         [ +  + ]:     438117 :     if (aAny.hasValue())
     258                 :            :     {
     259         [ +  - ]:     419863 :         if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
     260         [ +  - ]:     419863 :             xRet = *(const Reference< XIdlClass > *)aAny.getValue();
     261                 :            :     }
     262                 :            :     else
     263                 :            :     {
     264                 :            :         // try to get _type_ by name
     265                 :      18254 :         typelib_TypeDescription * pTD = 0;
     266                 :      18254 :         typelib_typedescription_getByName( &pTD, rTypeName.pData );
     267         [ +  - ]:      18254 :         if (pTD)
     268                 :            :         {
     269 [ +  - ][ +  - ]:      18254 :             if ((xRet = constructClass( pTD )).is())
                 [ +  - ]
     270 [ +  - ][ +  - ]:      18254 :                 _aElements.setValue( rTypeName, makeAny( xRet ) ); // update
     271                 :      18254 :             typelib_typedescription_release( pTD );
     272                 :            :         }
     273                 :            :     }
     274                 :            : 
     275                 :     438117 :     return xRet;
     276                 :            : }
     277                 :            : 
     278                 :            : // XHierarchicalNameAccess
     279                 :            : //__________________________________________________________________________________________________
     280                 :        138 : Any IdlReflectionServiceImpl::getByHierarchicalName( const OUString & rName )
     281                 :            :     throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
     282                 :            : {
     283                 :        138 :     Any aRet( _aElements.getValue( rName ) );
     284         [ +  + ]:        138 :     if (! aRet.hasValue())
     285                 :            :     {
     286                 :            :         // first look for constants exclusivly!
     287 [ +  - ][ +  - ]:         24 :         aRet = _xTDMgr->getByHierarchicalName( rName );
     288         [ +  + ]:         24 :         if (aRet.getValueTypeClass() == TypeClass_INTERFACE) // if no constant,
     289                 :            :                                                              // i.e. XTypeDescription for a type
     290                 :            :         {
     291                 :            :             // type retrieved from tdmgr
     292                 :            :             OSL_ASSERT( (*(Reference< XInterface > *)aRet.getValue())->queryInterface(
     293                 :            :                 ::getCppuType( (const Reference< XTypeDescription > *)0 ) ).hasValue() );
     294                 :            : 
     295                 :            :             // if you are interested in a type then CALL forName()!!!
     296                 :            :             // this way is NOT recommended for types, because this method looks for constants first
     297                 :            : 
     298                 :            :             // if td manager found some type, it will be in the cache (hopefully.. we just got it)
     299                 :            :             // so the second retrieving via c typelib callback chain should succeed...
     300                 :            : 
     301                 :            :             // try to get _type_ by name
     302                 :         22 :             typelib_TypeDescription * pTD = 0;
     303                 :         22 :             typelib_typedescription_getByName( &pTD, rName.pData );
     304                 :            : 
     305                 :         22 :             aRet.clear(); // kick XTypeDescription interface
     306                 :            : 
     307         [ +  + ]:         22 :             if (pTD)
     308                 :            :             {
     309         [ +  - ]:         14 :                 Reference< XIdlClass > xIdlClass( constructClass( pTD ) );
     310         [ +  - ]:         14 :                 aRet.setValue( &xIdlClass, ::getCppuType( (const Reference< XIdlClass > *)0 ) );
     311                 :         22 :                 typelib_typedescription_release( pTD );
     312                 :            :             }
     313                 :            :         }
     314                 :            :         // else is constant
     315                 :            : 
     316                 :            :         // update
     317         [ +  + ]:         24 :         if (aRet.hasValue())
     318         [ +  - ]:         16 :             _aElements.setValue( rName, aRet );
     319                 :            :         else
     320                 :            :         {
     321         [ +  - ]:          8 :             throw NoSuchElementException( rName, Reference< XInterface >() );
     322                 :            :         }
     323                 :            :     }
     324                 :        138 :     return aRet;
     325                 :            : }
     326                 :            : //__________________________________________________________________________________________________
     327                 :        128 : sal_Bool IdlReflectionServiceImpl::hasByHierarchicalName( const OUString & rName )
     328                 :            :     throw(::com::sun::star::uno::RuntimeException)
     329                 :            : {
     330                 :            :     try
     331                 :            :     {
     332 [ +  - ][ #  # ]:        128 :         return getByHierarchicalName( rName ).hasValue();
     333                 :            :     }
     334                 :          0 :     catch (NoSuchElementException &)
     335                 :            :     {
     336                 :            :     }
     337                 :          0 :     return sal_False;
     338                 :            : }
     339                 :            : 
     340                 :            : //__________________________________________________________________________________________________
     341                 :      87922 : Reference< XIdlClass > IdlReflectionServiceImpl::forType( typelib_TypeDescription * pTypeDescr )
     342                 :            :     throw(::com::sun::star::uno::RuntimeException)
     343                 :            : {
     344                 :      87922 :     Reference< XIdlClass > xRet;
     345                 :      87922 :     OUString aName( pTypeDescr->pTypeName );
     346         [ +  - ]:      87922 :     Any aAny( _aElements.getValue( aName ) );
     347                 :            : 
     348         [ +  + ]:      87922 :     if (aAny.hasValue())
     349                 :            :     {
     350         [ +  - ]:      80477 :         if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
     351         [ +  - ]:      80477 :             xRet = *(const Reference< XIdlClass > *)aAny.getValue();
     352                 :            :     }
     353                 :            :     else
     354                 :            :     {
     355 [ +  - ][ +  - ]:       7445 :         if (pTypeDescr && (xRet = constructClass( pTypeDescr )).is())
         [ +  - ][ +  - ]
                 [ +  - ]
           [ +  -  #  # ]
     356 [ +  - ][ +  - ]:       7445 :             _aElements.setValue( aName, makeAny( xRet ) ); // update
     357                 :            :     }
     358                 :            : 
     359                 :      87922 :     return xRet;
     360                 :            : }
     361                 :            : //__________________________________________________________________________________________________
     362                 :      73216 : Reference< XIdlClass > IdlReflectionServiceImpl::forType( typelib_TypeDescriptionReference * pRef )
     363                 :            :     throw(::com::sun::star::uno::RuntimeException)
     364                 :            : {
     365                 :      73216 :     typelib_TypeDescription * pTD = 0;
     366 [ +  - ][ -  + ]:      73216 :     TYPELIB_DANGER_GET( &pTD, pRef );
         [ +  - ][ +  + ]
                 [ +  - ]
     367         [ +  - ]:      73216 :     if (pTD)
     368                 :            :     {
     369         [ +  - ]:      73216 :         Reference< XIdlClass > xRet = forType( pTD );
     370 [ +  - ][ -  + ]:      73216 :         TYPELIB_DANGER_RELEASE( pTD );
     371                 :      73216 :         return xRet;
     372                 :            :     }
     373                 :            :     throw RuntimeException(
     374                 :            :         OUString( RTL_CONSTASCII_USTRINGPARAM("IdlReflectionServiceImpl::forType() failed!") ),
     375 [ #  # ][ #  # ]:          0 :         (XWeak *)(OWeakObject *)this );
                 [ #  # ]
     376                 :            : }
     377                 :            : 
     378                 :            : //__________________________________________________________________________________________________
     379                 :       9492 : const Mapping & IdlReflectionServiceImpl::getCpp2Uno()
     380                 :            :     throw(::com::sun::star::uno::RuntimeException)
     381                 :            : {
     382         [ +  + ]:       9492 :     if (! _aCpp2Uno.is())
     383                 :            :     {
     384 [ +  - ][ +  - ]:        197 :         MutexGuard aGuard( getMutexAccess() );
     385         [ +  - ]:        197 :         if (! _aCpp2Uno.is())
     386                 :            :         {
     387                 :            :             _aCpp2Uno = Mapping(
     388                 :            :                 OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
     389 [ +  - ][ +  - ]:        197 :                 OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) );
         [ +  - ][ +  - ]
     390                 :            :             OSL_ENSURE( _aCpp2Uno.is(), "### cannot get c++ to uno mapping!" );
     391         [ -  + ]:        197 :             if (! _aCpp2Uno.is())
     392                 :            :             {
     393                 :            :                 throw RuntimeException(
     394                 :            :                     OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get c++ to uno mapping!") ),
     395 [ #  # ][ #  # ]:          0 :                     (XWeak *)(OWeakObject *)this );
                 [ #  # ]
     396                 :            :             }
     397         [ +  - ]:        197 :         }
     398                 :            :     }
     399                 :       9492 :     return _aCpp2Uno;
     400                 :            : }
     401                 :            : //__________________________________________________________________________________________________
     402                 :       4514 : const Mapping & IdlReflectionServiceImpl::getUno2Cpp()
     403                 :            :     throw(::com::sun::star::uno::RuntimeException)
     404                 :            : {
     405         [ +  + ]:       4514 :     if (! _aUno2Cpp.is())
     406                 :            :     {
     407 [ +  - ][ +  - ]:        197 :         MutexGuard aGuard( getMutexAccess() );
     408         [ +  - ]:        197 :         if (! _aUno2Cpp.is())
     409                 :            :         {
     410                 :            :             _aUno2Cpp = Mapping(
     411                 :            :                 OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
     412 [ +  - ][ +  - ]:        197 :                 OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) );
         [ +  - ][ +  - ]
     413                 :            :             OSL_ENSURE( _aUno2Cpp.is(), "### cannot get uno to c++ mapping!" );
     414         [ -  + ]:        197 :             if (! _aUno2Cpp.is())
     415                 :            :             {
     416                 :            :                 throw RuntimeException(
     417                 :            :                     OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get uno to c++ mapping!") ),
     418 [ #  # ][ #  # ]:          0 :                     (XWeak *)(OWeakObject *)this );
                 [ #  # ]
     419                 :            :             }
     420         [ +  - ]:        197 :         }
     421                 :            :     }
     422                 :       4514 :     return _aUno2Cpp;
     423                 :            : }
     424                 :            : //__________________________________________________________________________________________________
     425                 :       4587 : uno_Interface * IdlReflectionServiceImpl::mapToUno(
     426                 :            :     const Any & rObj, typelib_InterfaceTypeDescription * pTo )
     427                 :            :     throw(::com::sun::star::uno::RuntimeException)
     428                 :            : {
     429                 :       4587 :     Reference< XInterface > xObj;
     430 [ +  - ][ +  - ]:       4587 :     if (extract( rObj, pTo, xObj, this ))
     431 [ +  - ][ +  - ]:       9174 :         return (uno_Interface *)getCpp2Uno().mapInterface( xObj.get(), pTo );
                 [ +  - ]
     432                 :            : 
     433                 :            :     throw RuntimeException(
     434                 :            :         OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
     435 [ #  # ][ #  # ]:       4587 :         (XWeak *)(OWeakObject *)this );
                 [ #  # ]
     436                 :            : }
     437                 :            : 
     438                 :            : //==================================================================================================
     439                 :       4662 : Reference< XInterface > SAL_CALL IdlReflectionServiceImpl_create(
     440                 :            :     const Reference< XComponentContext > & xContext )
     441                 :            :     throw(::com::sun::star::uno::Exception)
     442                 :            : {
     443         [ +  - ]:       4662 :     return Reference< XInterface >( (XWeak *)(OWeakObject *)new IdlReflectionServiceImpl( xContext ) );
     444                 :            : }
     445                 :            : 
     446                 :            : }
     447                 :            : 
     448                 :            : 
     449                 :            : //##################################################################################################
     450                 :            : //##################################################################################################
     451                 :            : //##################################################################################################
     452                 :            : 
     453                 :            : using namespace stoc_corefl;
     454                 :            : 
     455                 :            : static struct ImplementationEntry g_entries[] =
     456                 :            : {
     457                 :            :     {
     458                 :            :         IdlReflectionServiceImpl_create, core_getImplementationName,
     459                 :            :         core_getSupportedServiceNames, createSingleComponentFactory,
     460                 :            :         &g_moduleCount.modCnt , 0
     461                 :            :     },
     462                 :            :     { 0, 0, 0, 0, 0, 0 }
     463                 :            : };
     464                 :            : 
     465                 :            : extern "C"
     466                 :            : {
     467                 :          0 : SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
     468                 :            : {
     469                 :          0 :     return g_moduleCount.canUnload( &g_moduleCount , pTime );
     470                 :            : }
     471                 :            : 
     472                 :            : #ifdef DISABLE_DYNLOADING
     473                 :            : #define component_getFactory reflection_component_getFactory
     474                 :            : #endif
     475                 :            : 
     476                 :            : //==================================================================================================
     477                 :        199 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
     478                 :            :     const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
     479                 :            : {
     480                 :        199 :     return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
     481                 :            : }
     482                 :            : }
     483                 :            : 
     484                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10