LCOV - code coverage report
Current view: top level - libreoffice/stoc/source/registry_tdprovider - tdprovider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 103 164 62.8 %
Date: 2012-12-27 Functions: 19 26 73.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <osl/diagnose.h>
      21             : #include <osl/mutex.hxx>
      22             : #include <uno/dispatcher.h>
      23             : #include <uno/mapping.hxx>
      24             : #include <cppuhelper/factory.hxx>
      25             : #include <cppuhelper/compbase4.hxx>
      26             : #include <cppuhelper/implbase2.hxx>
      27             : #include <cppuhelper/typeprovider.hxx>
      28             : 
      29             : #include <cppuhelper/weakref.hxx>
      30             : 
      31             : #include <com/sun/star/lang/XServiceInfo.hpp>
      32             : #include <com/sun/star/lang/XComponent.hpp>
      33             : #include <com/sun/star/lang/XTypeProvider.hpp>
      34             : #include <com/sun/star/lang/XInitialization.hpp>
      35             : #include <com/sun/star/registry/XSimpleRegistry.hpp>
      36             : #include <com/sun/star/registry/XRegistryKey.hpp>
      37             : #include <com/sun/star/beans/XPropertySet.hpp>
      38             : #include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp>
      39             : #include "com/sun/star/uno/RuntimeException.hpp"
      40             : 
      41             : #include "registry/reader.hxx"
      42             : #include "registry/version.h"
      43             : #include "base.hxx"
      44             : #include "rdbtdp_tdenumeration.hxx"
      45             : #include "structtypedescription.hxx"
      46             : 
      47             : #define SERVICENAME "com.sun.star.reflection.TypeDescriptionProvider"
      48             : #define IMPLNAME    "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"
      49             : 
      50             : using namespace com::sun::star;
      51             : using namespace com::sun::star::beans;
      52             : using namespace com::sun::star::registry;
      53             : 
      54             : extern rtl_StandardModuleCount g_moduleCount;
      55             : 
      56             : namespace stoc_bootstrap
      57             : {
      58         259 : uno::Sequence< OUString > rdbtdp_getSupportedServiceNames()
      59             : {
      60         259 :     Sequence< OUString > seqNames(1);
      61         259 :     seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
      62         259 :     return seqNames;
      63             : }
      64             : 
      65        3368 : OUString rdbtdp_getImplementationName()
      66             : {
      67        3368 :     return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
      68             : }
      69             : }
      70             : 
      71             : namespace stoc_rdbtdp
      72             : {
      73         290 : struct MutexHolder
      74             : {
      75             :     Mutex _aComponentMutex;
      76             : };
      77             : //==================================================================================================
      78             : class ProviderImpl
      79             :     : public MutexHolder
      80             :     , public WeakComponentImplHelper4< XServiceInfo,
      81             :                                        XHierarchicalNameAccess,
      82             :                                        XTypeDescriptionEnumerationAccess,
      83             :                                        XInitialization >
      84             : {
      85             :     // XHierarchicalNameAccess + XTypeDescriptionEnumerationAccess wrapper
      86             :     // first asking the tdmgr instance, then looking up locally
      87          54 :     class TypeDescriptionManagerWrapper
      88             :         : public ::cppu::WeakImplHelper2<
      89             :             container::XHierarchicalNameAccess,
      90             :             reflection::XTypeDescriptionEnumerationAccess>
      91             :     {
      92             :         com::sun::star::uno::Reference<container::XHierarchicalNameAccess>
      93             :         m_xTDMgr;
      94             :         com::sun::star::uno::Reference<container::XHierarchicalNameAccess>
      95             :         m_xThisProvider;
      96             :     public:
      97          35 :         TypeDescriptionManagerWrapper( ProviderImpl * pProvider )
      98          35 :             : m_xTDMgr( pProvider->_xContext->getValueByName(
      99             :                             OUString( RTL_CONSTASCII_USTRINGPARAM(
     100             :                                           "/singletons/com.sun.star.reflection."
     101          35 :                                           "theTypeDescriptionManager") ) ),
     102             :                         UNO_QUERY_THROW ),
     103          70 :               m_xThisProvider( pProvider )
     104          35 :             {}
     105             :         // XHierarchicalNameAccess
     106             :         virtual Any SAL_CALL getByHierarchicalName( OUString const & name )
     107             :             throw (container::NoSuchElementException, RuntimeException);
     108             :         virtual sal_Bool SAL_CALL hasByHierarchicalName( OUString const & name )
     109             :             throw (RuntimeException);
     110             : 
     111             :         // XTypeDescriptionEnumerationAccess
     112             :         virtual uno::Reference<
     113             :             reflection::XTypeDescriptionEnumeration > SAL_CALL
     114             :         createTypeDescriptionEnumeration(
     115             :             const ::rtl::OUString& moduleName,
     116             :             const uno::Sequence< uno::TypeClass >& types,
     117             :             reflection::TypeDescriptionSearchDepth depth )
     118             :                 throw ( reflection::NoSuchTypeNameException,
     119             :                         reflection::InvalidTypeNameException,
     120             :                         uno::RuntimeException );
     121             :     };
     122             :     friend class TypeDescriptionManagerWrapper;
     123             : 
     124             :     com::sun::star::uno::Reference< XComponentContext >              _xContext;
     125             :     com::sun::star::uno::WeakReference<XHierarchicalNameAccess> _xTDMgr;
     126             :     com::sun::star::uno::Reference< XHierarchicalNameAccess > getTDMgr() SAL_THROW(());
     127             : 
     128             :     RegistryKeyList                             _aBaseKeys;
     129             : 
     130             : protected:
     131             :     virtual void SAL_CALL disposing();
     132             : 
     133             : public:
     134             :     ProviderImpl( const com::sun::star::uno::Reference< XComponentContext > & xContext );
     135             :     virtual ~ProviderImpl();
     136             : 
     137             :     // XInitialization
     138             :     virtual void SAL_CALL initialize( const Sequence< Any > & args ) throw (Exception, RuntimeException);
     139             : 
     140             :     // XServiceInfo
     141             :     virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
     142             :     virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
     143             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
     144             : 
     145             :     // XHierarchicalNameAccess
     146             :     Any getByHierarchicalNameImpl( const OUString & rName );
     147             : 
     148             :     virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
     149             :     virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
     150             : 
     151             :     // XTypeDescriptionEnumerationAccess
     152             :     virtual ::com::sun::star::uno::Reference<
     153             :         ::com::sun::star::reflection::XTypeDescriptionEnumeration > SAL_CALL
     154             :     createTypeDescriptionEnumeration(
     155             :         const ::rtl::OUString& moduleName,
     156             :         const ::com::sun::star::uno::Sequence<
     157             :             ::com::sun::star::uno::TypeClass >& types,
     158             :         ::com::sun::star::reflection::TypeDescriptionSearchDepth depth )
     159             :             throw ( ::com::sun::star::reflection::NoSuchTypeNameException,
     160             :                     ::com::sun::star::reflection::InvalidTypeNameException,
     161             :                     ::com::sun::star::uno::RuntimeException );
     162             : };
     163             : //__________________________________________________________________________________________________
     164         259 : ProviderImpl::ProviderImpl( const com::sun::star::uno::Reference< XComponentContext > & xContext )
     165             :     : WeakComponentImplHelper4<
     166             :         XServiceInfo, XHierarchicalNameAccess,
     167             :         XTypeDescriptionEnumerationAccess, XInitialization >( _aComponentMutex )
     168         259 :     , _xContext( xContext )
     169             : {
     170         259 :     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
     171         259 : }
     172             : //__________________________________________________________________________________________________
     173          93 : ProviderImpl::~ProviderImpl()
     174             : {
     175          31 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
     176          62 : }
     177             : 
     178             : //______________________________________________________________________________
     179        9733 : Any ProviderImpl::TypeDescriptionManagerWrapper::getByHierarchicalName(
     180             :     OUString const & name ) throw (container::NoSuchElementException,
     181             :                                    RuntimeException)
     182             : {
     183             :     try
     184             :     {
     185             :         // first try tdmgr:
     186        9733 :         return m_xTDMgr->getByHierarchicalName( name );
     187             :     }
     188           0 :     catch (container::NoSuchElementException &)
     189             :     {
     190             :         // then lookup locally:
     191           0 :         return m_xThisProvider->getByHierarchicalName( name );
     192             :     }
     193             : }
     194             : 
     195             : //______________________________________________________________________________
     196           0 : sal_Bool ProviderImpl::TypeDescriptionManagerWrapper::hasByHierarchicalName(
     197             :     OUString const & name ) throw (RuntimeException)
     198             : {
     199           0 :     return m_xTDMgr->hasByHierarchicalName( name ) || m_xThisProvider->hasByHierarchicalName( name );
     200             : }
     201             : 
     202             : //______________________________________________________________________________
     203             : uno::Reference< reflection::XTypeDescriptionEnumeration > SAL_CALL
     204           0 : ProviderImpl::TypeDescriptionManagerWrapper::createTypeDescriptionEnumeration(
     205             :         const ::rtl::OUString& moduleName,
     206             :         const uno::Sequence< uno::TypeClass >& types,
     207             :         reflection::TypeDescriptionSearchDepth depth )
     208             :     throw ( reflection::NoSuchTypeNameException,
     209             :             reflection::InvalidTypeNameException,
     210             :             uno::RuntimeException )
     211             : {
     212             :     try
     213             :     {
     214             :         // first try tdmgr:
     215             :         uno::Reference< reflection::XTypeDescriptionEnumerationAccess > xTDEA(
     216           0 :             m_xTDMgr, uno::UNO_QUERY_THROW );
     217             :         return
     218           0 :             xTDEA->createTypeDescriptionEnumeration( moduleName, types, depth );
     219             :     }
     220           0 :     catch (reflection::NoSuchTypeNameException &)
     221             :     {
     222             :         // then lookup locally:
     223             :         uno::Reference< reflection::XTypeDescriptionEnumerationAccess > xTDEA(
     224           0 :             m_xThisProvider, uno::UNO_QUERY_THROW );
     225             :         return
     226           0 :             xTDEA->createTypeDescriptionEnumeration( moduleName, types, depth );
     227             :     }
     228             : }
     229             : 
     230             : //__________________________________________________________________________________________________
     231        4147 : com::sun::star::uno::Reference< XHierarchicalNameAccess > ProviderImpl::getTDMgr()
     232             :     SAL_THROW(())
     233             : {
     234             :     // harden weak reference:
     235             :     com::sun::star::uno::Reference<container::XHierarchicalNameAccess> xTDMgr(
     236        4147 :         _xTDMgr );
     237        4147 :     if (! xTDMgr.is())
     238             :     {
     239          35 :         xTDMgr.set( new TypeDescriptionManagerWrapper(this) );
     240             :         {
     241          35 :         MutexGuard guard( _aComponentMutex );
     242          35 :         _xTDMgr = xTDMgr;
     243             :         }
     244             :     }
     245        4147 :     return xTDMgr;
     246             : }
     247             : 
     248             : //__________________________________________________________________________________________________
     249          31 : void ProviderImpl::disposing()
     250             : {
     251          31 :     _xContext.clear();
     252             : 
     253         186 :     for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() );
     254         124 :           iPos != _aBaseKeys.end(); ++iPos )
     255             :     {
     256          31 :         (*iPos)->closeKey();
     257             :     }
     258          31 :     _aBaseKeys.clear();
     259          31 : }
     260             : 
     261             : // XInitialization
     262             : //__________________________________________________________________________________________________
     263         259 : void ProviderImpl::initialize(
     264             :     const Sequence< Any > & args )
     265             :     throw (Exception, RuntimeException)
     266             : {
     267             :     // registries to read from
     268         259 :     Any const * pRegistries = args.getConstArray();
     269         518 :     for ( sal_Int32 nPos = 0; nPos < args.getLength(); ++nPos )
     270             :     {
     271         259 :         com::sun::star::uno::Reference< XSimpleRegistry > xRegistry( pRegistries[ nPos ], UNO_QUERY );
     272         259 :         if (xRegistry.is() && xRegistry->isValid())
     273             :         {
     274         518 :             com::sun::star::uno::Reference< XRegistryKey > xKey( xRegistry->getRootKey()->openKey(
     275         259 :                 OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR") ) ) );
     276         259 :             if (xKey.is() && xKey->isValid())
     277             :             {
     278         259 :                 _aBaseKeys.push_back( xKey );
     279         259 :             }
     280             :         }
     281         259 :     }
     282         259 : }
     283             : 
     284             : // XServiceInfo
     285             : //__________________________________________________________________________________________________
     286           0 : OUString ProviderImpl::getImplementationName()
     287             :     throw(::com::sun::star::uno::RuntimeException)
     288             : {
     289           0 :     return stoc_bootstrap::rdbtdp_getImplementationName();
     290             : }
     291             : //__________________________________________________________________________________________________
     292           0 : sal_Bool ProviderImpl::supportsService( const OUString & rServiceName )
     293             :     throw(::com::sun::star::uno::RuntimeException)
     294             : {
     295           0 :     const Sequence< OUString > & rSNL = getSupportedServiceNames();
     296           0 :     const OUString * pArray = rSNL.getConstArray();
     297           0 :     for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
     298             :     {
     299           0 :         if (pArray[nPos] == rServiceName)
     300           0 :             return sal_True;
     301             :     }
     302           0 :     return sal_False;
     303             : }
     304             : //__________________________________________________________________________________________________
     305           0 : Sequence< OUString > ProviderImpl::getSupportedServiceNames()
     306             :     throw(::com::sun::star::uno::RuntimeException)
     307             : {
     308           0 :     return stoc_bootstrap::rdbtdp_getSupportedServiceNames();
     309             : }
     310             : 
     311             : // XHierarchicalNameAccess
     312             : //__________________________________________________________________________________________________
     313        4148 : Any ProviderImpl::getByHierarchicalNameImpl( const OUString & rName )
     314             : {
     315        4148 :     Any aRet;
     316             : 
     317             :     // read from registry
     318        4148 :     OUString aKey( rName.replace( '.', '/' ) );
     319       33186 :     for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() );
     320       24890 :           !aRet.hasValue() && iPos != _aBaseKeys.end(); ++iPos )
     321             :     {
     322             :         try
     323             :         {
     324        4148 :             com::sun::star::uno::Reference< XRegistryKey > xBaseKey( *iPos );
     325        4148 :             com::sun::star::uno::Reference< XRegistryKey > xKey( xBaseKey->openKey( aKey ) );
     326        4148 :             if (xKey.is())
     327             :             {
     328             :                 // closes key in it's dtor (which is
     329             :                 // called even in case of exceptions).
     330        4147 :                 RegistryKeyCloser aCloser( xKey );
     331             : 
     332        4147 :                 if ( xKey->isValid() )
     333             :                 {
     334        4147 :                     if (xKey->getValueType() == RegistryValueType_BINARY)
     335             :                     {
     336        4147 :                         Sequence< sal_Int8 > aBytes( xKey->getBinaryValue() );
     337             :                         com::sun::star::uno::Reference< XTypeDescription > xTD(
     338             :                             createTypeDescription( aBytes,
     339             :                                                    getTDMgr(),
     340        4147 :                                                    true ) );
     341        4147 :                         if ( xTD.is() )
     342        4147 :                             aRet <<= xTD;
     343             :                     }
     344        4147 :                 }
     345             :             }
     346             :             else // might be a constant
     347             :             {
     348           1 :                 sal_Int32 nIndex = aKey.lastIndexOf( '/' );
     349           1 :                 if (nIndex > 0)
     350             :                 {
     351             :                     // open module
     352           0 :                     com::sun::star::uno::Reference< XRegistryKey > xKey2( xBaseKey->openKey( aKey.copy( 0, nIndex ) ) );
     353           0 :                     if (xKey2.is())
     354             :                     {
     355             :                         // closes key in it's dtor (which is
     356             :                         // called even in case of exceptions).
     357           0 :                         RegistryKeyCloser aCloser( xKey2 );
     358             : 
     359           0 :                         if ( xKey2->isValid() )
     360             :                         {
     361           0 :                             if (xKey2->getValueType() == RegistryValueType_BINARY)
     362             :                             {
     363           0 :                                 Sequence< sal_Int8 > aBytes( xKey2->getBinaryValue() );
     364             :                                 typereg::Reader aReader(
     365           0 :                                     aBytes.getConstArray(), aBytes.getLength(),
     366           0 :                                     false, TYPEREG_VERSION_1);
     367             : 
     368           0 :                                 if (aReader.getTypeClass() == RT_TYPE_MODULE ||
     369           0 :                                     aReader.getTypeClass() == RT_TYPE_CONSTANTS ||
     370           0 :                                     aReader.getTypeClass() == RT_TYPE_ENUM)
     371             :                                 {
     372           0 :                                     OUString aFieldName( aKey.copy( nIndex+1, aKey.getLength() - nIndex -1 ) );
     373           0 :                                     sal_Int16 nPos = aReader.getFieldCount();
     374           0 :                                     while (nPos--)
     375             :                                     {
     376           0 :                                         if (aFieldName.equals(
     377           0 :                                                 aReader.getFieldName(nPos)))
     378           0 :                                             break;
     379             :                                     }
     380           0 :                                     if (nPos >= 0)
     381             :                                         aRet = getRTValue(
     382           0 :                                             aReader.getFieldValue(nPos));
     383           0 :                                 }
     384             :                             }
     385           0 :                         }
     386           0 :                     }
     387             :                 }
     388        4148 :             }
     389             :         }
     390           0 :         catch ( InvalidRegistryException const & )
     391             :         {
     392             :             OSL_FAIL( "ProviderImpl::getByHierarchicalName "
     393             :                         "- Caught InvalidRegistryException!" );
     394             : 
     395             :             // openKey, closeKey, getValueType, getBinaryValue, isValid
     396             : 
     397             :             // Don't stop iteration in this case.
     398             :         }
     399           0 :         catch ( NoSuchElementException const & )
     400             :         {
     401             :         }
     402             :     }
     403        4148 :     return aRet;
     404             : }
     405             : 
     406        4148 : Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName )
     407             :     throw(::com::sun::star::uno::RuntimeException, com::sun::star::container::NoSuchElementException)
     408             : {
     409        4148 :     Any aRet( getByHierarchicalNameImpl( rName ) );
     410             : 
     411        4148 :     if ( !aRet.hasValue() )
     412             :         throw NoSuchElementException(
     413           1 :             rName, static_cast< cppu::OWeakObject * >( this  ) );
     414             : 
     415        4148 :     return aRet;
     416             : }
     417             : 
     418             : //__________________________________________________________________________________________________
     419           0 : sal_Bool ProviderImpl::hasByHierarchicalName( const OUString & rName )
     420             :     throw(::com::sun::star::uno::RuntimeException)
     421             : {
     422           0 :     return getByHierarchicalNameImpl( rName ).hasValue();
     423             : }
     424             : 
     425             : // XTypeDescriptionEnumerationAccess
     426             : //__________________________________________________________________________________________________
     427             : // virtual
     428             : com::sun::star::uno::Reference< XTypeDescriptionEnumeration > SAL_CALL
     429           0 : ProviderImpl::createTypeDescriptionEnumeration(
     430             :         const OUString & moduleName,
     431             :         const Sequence< TypeClass > & types,
     432             :         TypeDescriptionSearchDepth depth )
     433             :     throw ( NoSuchTypeNameException,
     434             :             InvalidTypeNameException,
     435             :             RuntimeException )
     436             : {
     437             :     return com::sun::star::uno::Reference< XTypeDescriptionEnumeration >(
     438             :         TypeDescriptionEnumerationImpl::createInstance( getTDMgr(),
     439             :                                                         moduleName,
     440             :                                                         types,
     441             :                                                         depth,
     442           0 :                                                         _aBaseKeys ).get() );
     443             : }
     444             : 
     445             : //__________________________________________________________________________________________________
     446             : // global helper function
     447             : 
     448        8912 : com::sun::star::uno::Reference< XTypeDescription > resolveTypedefs(
     449             :     com::sun::star::uno::Reference< XTypeDescription > const & type)
     450             : {
     451        8912 :     com::sun::star::uno::Reference< XTypeDescription > resolved(type);
     452       17824 :     while (resolved->getTypeClass() == TypeClass_TYPEDEF) {
     453             :         resolved = com::sun::star::uno::Reference< XIndirectTypeDescription >(
     454           0 :             resolved, UNO_QUERY_THROW)->getReferencedType();
     455             :     }
     456        8912 :     return resolved;
     457             : }
     458             : 
     459        4147 : com::sun::star::uno::Reference< XTypeDescription > createTypeDescription(
     460             :     const Sequence< sal_Int8 > & rData,
     461             :     const com::sun::star::uno::Reference< XHierarchicalNameAccess > & xNameAccess,
     462             :     bool bReturnEmptyRefForUnknownType )
     463             : {
     464             :     typereg::Reader aReader(
     465        4147 :         rData.getConstArray(), rData.getLength(), false, TYPEREG_VERSION_1);
     466             : 
     467        4147 :     OUString aName( aReader.getTypeName().replace( '/', '.' ) );
     468             : 
     469        4147 :     switch (aReader.getTypeClass())
     470             :     {
     471             :         case RT_TYPE_INTERFACE:
     472             :         {
     473        3210 :             sal_uInt16 n = aReader.getSuperTypeCount();
     474        3210 :             com::sun::star::uno::Sequence< rtl::OUString > aBaseTypeNames(n);
     475        6674 :             {for (sal_uInt16 i = 0; i < n; ++i) {
     476        3464 :                 aBaseTypeNames[i] = aReader.getSuperTypeName(i).replace(
     477        6928 :                     '/', '.');
     478             :             }}
     479        3210 :             sal_uInt16 n2 = aReader.getReferenceCount();
     480             :             com::sun::star::uno::Sequence< rtl::OUString >
     481        3210 :                 aOptionalBaseTypeNames(n2);
     482        3210 :             {for (sal_uInt16 i = 0; i < n2; ++i) {
     483             :                 OSL_ASSERT(
     484             :                     aReader.getReferenceSort(i) == RT_REF_SUPPORTS
     485             :                     && aReader.getReferenceFlags(i) == RT_ACCESS_OPTIONAL);
     486           0 :                 aOptionalBaseTypeNames[i] = aReader.getReferenceTypeName(i);
     487             :             }}
     488             :             return com::sun::star::uno::Reference< XTypeDescription >(
     489             :                 new InterfaceTypeDescriptionImpl( xNameAccess,
     490             :                                                   aName,
     491             :                                                   aBaseTypeNames,
     492             :                                                   aOptionalBaseTypeNames,
     493             :                                                   rData,
     494        3210 :                                                   aReader.isPublished() ) );
     495             :         }
     496             : 
     497             :         case RT_TYPE_MODULE:
     498             :         {
     499             :             com::sun::star::uno::Reference<
     500             :                 XTypeDescriptionEnumerationAccess > xTDEA(
     501           0 :                     xNameAccess, UNO_QUERY );
     502             : 
     503             :             OSL_ENSURE( xTDEA.is(),
     504             :                         "No XTypeDescriptionEnumerationAccess!" );
     505             : 
     506             :             return com::sun::star::uno::Reference< XTypeDescription >(
     507           0 :                 new ModuleTypeDescriptionImpl( xTDEA, aName ) );
     508             :         }
     509             : 
     510             :         case RT_TYPE_STRUCT:
     511             :             {
     512         584 :                 rtl::OUString superTypeName;
     513         584 :                 if (aReader.getSuperTypeCount() == 1) {
     514             :                     superTypeName = aReader.getSuperTypeName(0).replace(
     515          76 :                         '/', '.');
     516             :                 }
     517             :                 return com::sun::star::uno::Reference< XTypeDescription >(
     518             :                     new stoc::registry_tdprovider::StructTypeDescription(
     519             :                         xNameAccess, aName, superTypeName, rData,
     520         584 :                         aReader.isPublished()));
     521             :             }
     522             : 
     523             :         case RT_TYPE_ENUM:
     524             :             return com::sun::star::uno::Reference< XTypeDescription >(
     525             :                 new EnumTypeDescriptionImpl( xNameAccess,
     526             :                                              aName,
     527             :                                              getRTValueAsInt32(
     528         216 :                                                 aReader.getFieldValue( 0 ) ),
     529         108 :                                              rData, aReader.isPublished() ) );
     530             : 
     531             :         case RT_TYPE_EXCEPTION:
     532             :             {
     533         216 :                 rtl::OUString superTypeName;
     534         216 :                 if (aReader.getSuperTypeCount() == 1) {
     535             :                     superTypeName = aReader.getSuperTypeName(0).replace(
     536         197 :                         '/', '.');
     537             :                 }
     538             :                 return com::sun::star::uno::Reference< XTypeDescription >(
     539             :                     new CompoundTypeDescriptionImpl(
     540             :                         xNameAccess, TypeClass_EXCEPTION, aName, superTypeName,
     541         216 :                         rData, aReader.isPublished()));
     542             :             }
     543             : 
     544             :         case RT_TYPE_TYPEDEF:
     545             :             return com::sun::star::uno::Reference< XTypeDescription >(
     546             :                 new TypedefTypeDescriptionImpl( xNameAccess,
     547             :                                                 aName,
     548             :                                                 aReader.getSuperTypeName(0)
     549             :                                                     .replace( '/', '.' ),
     550          29 :                                                 aReader.isPublished() ) );
     551             :         case RT_TYPE_SERVICE:
     552             :             return com::sun::star::uno::Reference< XTypeDescription >(
     553             :                 new ServiceTypeDescriptionImpl(
     554           0 :                     xNameAccess, aName, rData, aReader.isPublished() ) );
     555             : 
     556             :         case RT_TYPE_CONSTANTS:
     557             :             return com::sun::star::uno::Reference< XTypeDescription >(
     558             :                 new ConstantsTypeDescriptionImpl(
     559           0 :                     aName, rData, aReader.isPublished() ) );
     560             : 
     561             :         case RT_TYPE_SINGLETON:
     562             :             return com::sun::star::uno::Reference< XTypeDescription >(
     563             :                 new SingletonTypeDescriptionImpl( xNameAccess,
     564             :                                                   aName,
     565             :                                                   aReader.getSuperTypeName(0)
     566             :                                                     .replace( '/', '.' ),
     567           0 :                                                   aReader.isPublished() ) );
     568             :         case RT_TYPE_INVALID:
     569             :         case RT_TYPE_OBJECT:      // deprecated and not used
     570             :         case RT_TYPE_UNION:       // deprecated and not used
     571             :             OSL_FAIL( "createTypeDescription - Unsupported Type!" );
     572           0 :             break;
     573             : 
     574             :         default:
     575             :             OSL_FAIL( "createTypeDescription - Unknown Type!" );
     576           0 :             break;
     577             :     }
     578             : 
     579             :     // Unknown type.
     580             : 
     581           0 :     if ( bReturnEmptyRefForUnknownType )
     582           0 :         return com::sun::star::uno::Reference< XTypeDescription >();
     583             : 
     584             :     return com::sun::star::uno::Reference< XTypeDescription >(
     585           0 :                 new TypeDescriptionImpl( TypeClass_UNKNOWN, aName ) );
     586             : }
     587             : 
     588             : }
     589             : 
     590             : namespace stoc_bootstrap
     591             : {
     592             : //==================================================================================================
     593         259 : com::sun::star::uno::Reference< XInterface > SAL_CALL ProviderImpl_create(
     594             :     com::sun::star::uno::Reference< XComponentContext > const & xContext )
     595             :     throw(::com::sun::star::uno::Exception)
     596             : {
     597         259 :     return com::sun::star::uno::Reference< XInterface >( *new stoc_rdbtdp::ProviderImpl( xContext ) );
     598             : }
     599             : }
     600             : 
     601             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10