LCOV - code coverage report
Current view: top level - stoc/source/registry_tdprovider - rdbtdp_tdenumeration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 116 164 70.7 %
Date: 2012-08-25 Functions: 10 14 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 123 337 36.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                 :            : //=========================================================================
      22                 :            : // Todo:
      23                 :            : //
      24                 :            : // - closeKey() calls (according to JSC not really needed because XRegistry
      25                 :            : //   implementation closes key in it's dtor.
      26                 :            : //
      27                 :            : //=========================================================================
      28                 :            : #include <osl/diagnose.h>
      29                 :            : #include <rtl/ustrbuf.hxx>
      30                 :            : #include "com/sun/star/reflection/XPublished.hpp"
      31                 :            : #include "cppuhelper/implbase1.hxx"
      32                 :            : #include "registry/reader.hxx"
      33                 :            : #include "registry/version.h"
      34                 :            : #include "base.hxx"
      35                 :            : #include "rdbtdp_tdenumeration.hxx"
      36                 :            : 
      37                 :            : using namespace com::sun::star;
      38                 :            : 
      39                 :            : namespace {
      40                 :            : 
      41         [ #  # ]:          0 : class IndividualConstantTypeDescriptionImpl:
      42                 :            :     public cppu::ImplInheritanceHelper1<
      43                 :            :         stoc_rdbtdp::ConstantTypeDescriptionImpl,
      44                 :            :         com::sun::star::reflection::XPublished >
      45                 :            : {
      46                 :            : public:
      47                 :          0 :     IndividualConstantTypeDescriptionImpl(
      48                 :            :         rtl::OUString const & name, com::sun::star::uno::Any const & value,
      49                 :            :         bool published):
      50                 :            :         cppu::ImplInheritanceHelper1<
      51                 :            :             stoc_rdbtdp::ConstantTypeDescriptionImpl,
      52                 :            :             com::sun::star::reflection::XPublished >(name, value),
      53                 :          0 :         m_published(published) {}
      54                 :            : 
      55                 :          0 :     virtual sal_Bool SAL_CALL isPublished()
      56                 :            :         throw (::com::sun::star::uno::RuntimeException)
      57                 :          0 :     { return m_published; }
      58                 :            : 
      59                 :            : private:
      60                 :            :     bool m_published;
      61                 :            : };
      62                 :            : 
      63                 :            : }
      64                 :            : 
      65                 :            : namespace stoc_rdbtdp
      66                 :            : {
      67                 :            : 
      68                 :            : //=========================================================================
      69                 :            : //=========================================================================
      70                 :            : //
      71                 :            : // TypeDescriptionEnumerationImpl Implementation.
      72                 :            : //
      73                 :            : //=========================================================================
      74                 :            : //=========================================================================
      75                 :            : 
      76                 :            : // static
      77                 :            : rtl::Reference< TypeDescriptionEnumerationImpl >
      78                 :          7 : TypeDescriptionEnumerationImpl::createInstance(
      79                 :            :         const uno::Reference< container::XHierarchicalNameAccess > & xTDMgr,
      80                 :            :         const rtl::OUString & rModuleName,
      81                 :            :         const uno::Sequence< uno::TypeClass > & rTypes,
      82                 :            :         reflection::TypeDescriptionSearchDepth eDepth,
      83                 :            :         const RegistryKeyList & rBaseKeys )
      84                 :            :     throw ( reflection::NoSuchTypeNameException,
      85                 :            :             reflection::InvalidTypeNameException,
      86                 :            :             uno::RuntimeException )
      87                 :            : {
      88         [ -  + ]:          7 :     if ( rModuleName.isEmpty() )
      89                 :            :     {
      90                 :            :         // Enumeration for root requested.
      91                 :            :         return rtl::Reference< TypeDescriptionEnumerationImpl >(
      92                 :            :             new TypeDescriptionEnumerationImpl(
      93         [ #  # ]:          0 :                 xTDMgr, rBaseKeys, rTypes, eDepth ) );
      94                 :            :     }
      95                 :            : 
      96         [ +  - ]:          7 :     RegistryKeyList aModuleKeys;
      97                 :            : 
      98                 :          7 :     rtl::OUString aKey( rModuleName.replace( '.', '/' ) );
      99                 :            : 
     100                 :          7 :     bool bOpenKeySucceeded = false;
     101                 :            : 
     102                 :          7 :     const RegistryKeyList::const_iterator end = rBaseKeys.end();
     103                 :          7 :     RegistryKeyList::const_iterator it = rBaseKeys.begin();
     104                 :            : 
     105         [ +  + ]:         14 :     while ( it != end )
     106                 :            :     {
     107                 :          7 :         uno::Reference< registry::XRegistryKey > xKey;
     108                 :            :         try
     109                 :            :         {
     110 [ +  - ][ +  - ]:          7 :             xKey = (*it)->openKey( aKey );
                 [ +  - ]
     111         [ +  + ]:          7 :             if ( xKey.is() )
     112                 :            :             {
     113                 :            :                 // closes key in it's dtor (which is
     114                 :            :                 // called even in case of exceptions).
     115         [ +  - ]:          2 :                 RegistryKeyCloser aCloser( xKey );
     116                 :            : 
     117 [ +  - ][ +  - ]:          2 :                 if ( xKey->isValid() )
                 [ +  - ]
     118                 :            :                 {
     119                 :          2 :                     bOpenKeySucceeded = true;
     120                 :            : 
     121 [ +  - ][ +  - ]:          2 :                     if ( xKey->getValueType()
                 [ +  - ]
     122                 :            :                          == registry::RegistryValueType_BINARY )
     123                 :            :                     {
     124                 :            :                         uno::Sequence< sal_Int8 > aBytes(
     125 [ +  - ][ +  - ]:          2 :                             xKey->getBinaryValue() );
     126                 :            : 
     127                 :            :                         typereg::Reader aReader(
     128                 :          2 :                             aBytes.getConstArray(), aBytes.getLength(), false,
     129         [ +  - ]:          2 :                             TYPEREG_VERSION_1);
     130                 :            : 
     131                 :            :                         rtl::OUString aName(
     132         [ +  - ]:          2 :                             aReader.getTypeName().replace( '/', '.' ) );
     133                 :            : 
     134         [ +  - ]:          2 :                         if ( aReader.getTypeClass() == RT_TYPE_MODULE )
     135                 :            :                         {
     136                 :            :                             // Do not close xKey!
     137         [ +  - ]:          2 :                             aCloser.reset();
     138                 :            : 
     139         [ +  - ]:          2 :                             aModuleKeys.push_back( xKey );
     140         [ +  - ]:          2 :                         }
     141                 :            :                     }
     142                 :            :                 }
     143                 :            :                 else
     144                 :            :                 {
     145                 :            :                     OSL_FAIL(
     146                 :            :                         "TypeDescriptionEnumerationImpl::createInstance "
     147                 :            :                         "- Invalid registry key!" );
     148 [ +  - ][ #  # ]:          2 :                 }
     149                 :            :             }
     150                 :            :         }
     151         [ #  # ]:          0 :         catch ( registry::InvalidRegistryException const & )
     152                 :            :         {
     153                 :            :             // openKey, getValueType, getBinaryValue
     154                 :            : 
     155                 :            :             OSL_FAIL( "TypeDescriptionEnumerationImpl::createInstance "
     156                 :            :                         "- Caught InvalidRegistryException!" );
     157                 :            :         }
     158                 :            : 
     159                 :          7 :         ++it;
     160                 :          7 :     }
     161                 :            : 
     162         [ +  + ]:          7 :     if ( !bOpenKeySucceeded )
     163         [ +  - ]:          5 :         throw reflection::NoSuchTypeNameException();
     164                 :            : 
     165         [ -  + ]:          2 :     if ( aModuleKeys.empty() )
     166         [ #  # ]:          0 :         throw reflection::InvalidTypeNameException();
     167                 :            : 
     168                 :            :     return rtl::Reference< TypeDescriptionEnumerationImpl >(
     169                 :            :         new TypeDescriptionEnumerationImpl(
     170         [ +  - ]:          7 :                 xTDMgr, aModuleKeys, rTypes, eDepth ) );
     171                 :            : }
     172                 :            : 
     173                 :            : //=========================================================================
     174                 :          2 : TypeDescriptionEnumerationImpl::TypeDescriptionEnumerationImpl(
     175                 :            :     const uno::Reference< container::XHierarchicalNameAccess > & xTDMgr,
     176                 :            :     const RegistryKeyList & rModuleKeys,
     177                 :            :     const uno::Sequence< uno::TypeClass > & rTypes,
     178                 :            :     reflection::TypeDescriptionSearchDepth eDepth )
     179                 :            : : m_aModuleKeys( rModuleKeys ),
     180                 :            :   m_aTypes( rTypes ),
     181                 :            :   m_eDepth( eDepth ),
     182 [ +  - ][ +  - ]:          2 :   m_xTDMgr( xTDMgr )
         [ +  - ][ +  - ]
                 [ +  - ]
     183                 :            : {
     184         [ +  - ]:          2 :     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
     185                 :          2 : }
     186                 :            : 
     187                 :            : //=========================================================================
     188                 :            : // virtual
     189 [ +  - ][ +  - ]:          2 : TypeDescriptionEnumerationImpl::~TypeDescriptionEnumerationImpl()
     190                 :            : {
     191                 :          2 :     RegistryKeyList::const_iterator it = m_aModuleKeys.begin();
     192                 :          2 :     RegistryKeyList::const_iterator end = m_aModuleKeys.end();
     193                 :            : /*
     194                 :            :    @@@ in case we enumerate root and queryMore was never called, then
     195                 :            :        m_aModuleKeys contains open root keys which where passed from
     196                 :            :        tdprov and must not be closed by us.
     197                 :            : 
     198                 :            :     while ( it != end )
     199                 :            :     {
     200                 :            :         try
     201                 :            :         {
     202                 :            :             if ( (*it)->isValid() )
     203                 :            :                 (*it)->closeKey();
     204                 :            :         }
     205                 :            :         catch (...)
     206                 :            :         {
     207                 :            :             // No exceptions from dtors, please!
     208                 :            :             OSL_FAIL( "TypeDescriptionEnumerationImpl::~TypeDescriptionEnumerationImpl "
     209                 :            :             "- Caught exception!" );
     210                 :            :         }
     211                 :            : 
     212                 :            :         it++;
     213                 :            :     }
     214                 :            : */
     215                 :          2 :     it = m_aCurrentModuleSubKeys.begin();
     216                 :          2 :     end = m_aCurrentModuleSubKeys.end();
     217         [ -  + ]:          2 :     while ( it != end )
     218                 :            :     {
     219                 :            :         try
     220                 :            :         {
     221 [ #  # ][ #  # ]:          0 :             if ( (*it)->isValid() )
                 [ #  # ]
     222 [ #  # ][ #  # ]:          0 :                 (*it)->closeKey();
     223                 :            :         }
     224         [ #  # ]:          0 :         catch (Exception &)
     225                 :            :         {
     226                 :            :             // No exceptions from dtors, please!
     227                 :            :             OSL_FAIL( "TypeDescriptionEnumerationImpl::~TypeDescriptionEnumerationImpl "
     228                 :            :             "- Caught exception!" );
     229                 :            :         }
     230                 :            : 
     231                 :          0 :         ++it;
     232                 :            :     }
     233                 :            : 
     234         [ +  - ]:          2 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
     235 [ -  + ][ #  # ]:          4 : }
     236                 :            : 
     237                 :            : //=========================================================================
     238                 :            : //
     239                 :            : // XEnumeration (base of XTypeDescriptionEnumeration) methods
     240                 :            : //
     241                 :            : //=========================================================================
     242                 :            : 
     243                 :            : // virtual
     244                 :       4958 : sal_Bool SAL_CALL TypeDescriptionEnumerationImpl::hasMoreElements()
     245                 :            :     throw ( uno::RuntimeException )
     246                 :            : {
     247                 :       4958 :     return queryMore();
     248                 :            : }
     249                 :            : 
     250                 :            : //=========================================================================
     251                 :            : // virtual
     252                 :       1652 : uno::Any SAL_CALL TypeDescriptionEnumerationImpl::nextElement()
     253                 :            :     throw ( container::NoSuchElementException,
     254                 :            :             lang::WrappedTargetException,
     255                 :            :             uno::RuntimeException )
     256                 :            : {
     257         [ +  - ]:       1652 :     return uno::Any( uno::makeAny( nextTypeDescription() ) );
     258                 :            : }
     259                 :            : 
     260                 :            : //=========================================================================
     261                 :            : //
     262                 :            : // XTypeDescriptionEnumeration methods
     263                 :            : //
     264                 :            : //=========================================================================
     265                 :            : 
     266                 :            : // virtual
     267                 :            : uno::Reference< reflection::XTypeDescription > SAL_CALL
     268                 :       1652 : TypeDescriptionEnumerationImpl::nextTypeDescription()
     269                 :            :     throw ( container::NoSuchElementException,
     270                 :            :             uno::RuntimeException )
     271                 :            : {
     272                 :       1652 :     uno::Reference< reflection::XTypeDescription > xTD( queryNext() );
     273                 :            : 
     274         [ +  - ]:       1652 :     if ( xTD.is() )
     275                 :       1652 :         return xTD;
     276                 :            : 
     277                 :            :     throw container::NoSuchElementException(
     278                 :            :         rtl::OUString(
     279                 :            :             RTL_CONSTASCII_USTRINGPARAM("No further elements in enumeration!") ),
     280 [ #  # ][ #  # ]:          0 :         static_cast< cppu::OWeakObject * >( this  ) );
                 [ #  # ]
     281                 :            : }
     282                 :            : 
     283                 :            : //=========================================================================
     284                 :       2090 : bool TypeDescriptionEnumerationImpl::match(
     285                 :            :     RTTypeClass eType1, uno::TypeClass eType2 )
     286                 :            : {
     287   [ +  +  -  -  :       2090 :     switch ( eType1 )
          -  -  +  -  +  
                   -  - ]
     288                 :            :     {
     289                 :            :     case RT_TYPE_INTERFACE:
     290                 :        400 :         return eType2 == uno::TypeClass_INTERFACE;
     291                 :            : 
     292                 :            :     case RT_TYPE_MODULE:
     293                 :         18 :         return eType2 == uno::TypeClass_MODULE;
     294                 :            : 
     295                 :            :     case RT_TYPE_STRUCT:
     296                 :          0 :         return eType2 == uno::TypeClass_STRUCT;
     297                 :            : 
     298                 :            :     case RT_TYPE_ENUM:
     299                 :          0 :         return eType2 == uno::TypeClass_ENUM;
     300                 :            : 
     301                 :            :     case RT_TYPE_EXCEPTION:
     302                 :          0 :         return eType2 == uno::TypeClass_EXCEPTION;
     303                 :            : 
     304                 :            :     case RT_TYPE_TYPEDEF:
     305                 :          0 :         return eType2 == uno::TypeClass_TYPEDEF;
     306                 :            : 
     307                 :            :     case RT_TYPE_SERVICE:
     308                 :         20 :         return eType2 == uno::TypeClass_SERVICE;
     309                 :            : 
     310                 :            :     case RT_TYPE_SINGLETON:
     311                 :          0 :         return eType2 == uno::TypeClass_SINGLETON;
     312                 :            : 
     313                 :            :     case RT_TYPE_CONSTANTS:
     314                 :       1652 :         return eType2 == uno::TypeClass_CONSTANTS;
     315                 :            : 
     316                 :            :     case RT_TYPE_UNION:
     317                 :          0 :         return eType2 == uno::TypeClass_UNION;
     318                 :            : 
     319                 :            :     default:
     320                 :       2090 :         return false;
     321                 :            :     }
     322                 :            : }
     323                 :            : 
     324                 :            : //=========================================================================
     325                 :       6610 : bool TypeDescriptionEnumerationImpl::queryMore()
     326                 :            : {
     327         [ +  - ]:       6610 :     osl::MutexGuard aGuard( m_aMutex );
     328                 :            : 
     329                 :         20 :     for (;;)
     330                 :            :     {
     331 [ +  + ][ -  + ]:       6630 :         if ( !m_aCurrentModuleSubKeys.empty() || !m_aTypeDescs.empty() )
                 [ +  + ]
     332                 :            :         {
     333                 :            :             // Okay, there is at least one more element.
     334                 :       6608 :             return true;
     335                 :            :         }
     336                 :            : 
     337         [ +  + ]:         22 :         if ( m_aModuleKeys.empty() )
     338                 :            :         {
     339                 :            :             // No module keys (therefore no elements) left.
     340                 :          2 :             return false;
     341                 :            :         }
     342                 :            : 
     343                 :            :         // Note: m_aCurrentModuleSubKeys is always empty AND m_aModuleKeys is
     344                 :            :         //       never empty when ariving here.
     345                 :            :         //       ==> select new module key, fill m_aCurrentModuleSubKeys
     346                 :            : 
     347         [ +  - ]:         20 :         uno::Sequence< uno::Reference< registry::XRegistryKey > > aKeys;
     348                 :            :         try
     349                 :            :         {
     350 [ +  - ][ +  - ]:         20 :             aKeys = m_aModuleKeys.front()->openKeys();
         [ +  - ][ +  - ]
                 [ +  - ]
     351         [ +  + ]:       2110 :             for ( sal_Int32 n = 0; n < aKeys.getLength(); ++n )
     352                 :            :             {
     353         [ +  - ]:       2090 :                 uno::Reference< registry::XRegistryKey > xKey = aKeys[ n ];
     354                 :            : 
     355                 :            :                 // closes key in it's dtor (which is
     356                 :            :                 // called even in case of exceptions).
     357         [ +  - ]:       2090 :                 RegistryKeyCloser aCloser( xKey );
     358                 :            : 
     359                 :            :                 try
     360                 :            :                 {
     361 [ +  - ][ +  - ]:       2090 :                     if ( xKey->isValid() )
                 [ +  - ]
     362                 :            :                     {
     363 [ +  - ][ +  - ]:       2090 :                         if ( xKey->getValueType()
                 [ +  - ]
     364                 :            :                                 == registry::RegistryValueType_BINARY )
     365                 :            :                         {
     366                 :       2090 :                             bool bIncludeIt = (m_aTypes.getLength() == 0);
     367                 :            :                             bool bNeedTypeClass =
     368                 :       2090 :                                 ((m_aTypes.getLength() > 0) ||
     369                 :            :                                  (m_eDepth
     370 [ #  # ][ -  + ]:       2090 :                                     == reflection::TypeDescriptionSearchDepth_INFINITE));
     371         [ +  - ]:       2090 :                             if ( bNeedTypeClass )
     372                 :            :                             {
     373                 :            :                                 uno::Sequence< sal_Int8 > aBytes(
     374 [ +  - ][ +  - ]:       2090 :                                     xKey->getBinaryValue() );
     375                 :            : 
     376                 :            :                                 typereg::Reader aReader(
     377                 :       2090 :                                     aBytes.getConstArray(), aBytes.getLength(),
     378         [ +  - ]:       2090 :                                     false, TYPEREG_VERSION_1);
     379                 :            : 
     380                 :       2090 :                                 RTTypeClass eTypeClass = aReader.getTypeClass();
     381                 :            : 
     382                 :            :                                 // Does key match requested types? Empty
     383                 :            :                                 // sequence means include all.
     384         [ +  - ]:       2090 :                                 if ( m_aTypes.getLength() > 0 )
     385                 :            :                                 {
     386         [ +  + ]:       6708 :                                     for ( sal_Int32 m = 0;
     387                 :       2528 :                                           m < m_aTypes.getLength();
     388                 :            :                                           ++m )
     389                 :            :                                     {
     390 [ +  - ][ +  + ]:       2090 :                                         if ( match(eTypeClass, m_aTypes[ m ]) )
     391                 :            :                                         {
     392                 :       1652 :                                             bIncludeIt = true;
     393                 :       1652 :                                             break;
     394                 :            :                                         }
     395                 :            :                                     }
     396                 :            :                                 }
     397                 :            : 
     398         [ +  - ]:       2090 :                                 if ( m_eDepth ==
     399                 :            :                                         reflection::TypeDescriptionSearchDepth_INFINITE )
     400                 :            :                                 {
     401         [ +  + ]:       2090 :                                     if ( eTypeClass == RT_TYPE_MODULE )
     402                 :            :                                     {
     403                 :            :                                         // Do not close xKey!
     404         [ +  - ]:         18 :                                         aCloser.reset();
     405                 :            : 
     406                 :            :                                         // Remember new module key.
     407         [ +  - ]:         18 :                                         m_aModuleKeys.push_back( xKey );
     408                 :            :                                     }
     409 [ +  - ][ #  # ]:       2090 :                                 }
     410                 :            :                             }
     411                 :            : 
     412         [ +  + ]:       2090 :                             if ( bIncludeIt )
     413                 :            :                             {
     414                 :            :                                 // Do not close xKey!
     415         [ +  - ]:       1652 :                                 aCloser.reset();
     416                 :            : 
     417         [ +  - ]:       1652 :                                 m_aCurrentModuleSubKeys.push_back( xKey );
     418                 :            :                             }
     419                 :            :                         }
     420                 :            :                     }
     421                 :            :                     else
     422                 :            :                     {
     423                 :            :                         OSL_FAIL( "TypeDescriptionEnumerationImpl::queryMore "
     424                 :            :                             "- Invalid registry key!" );
     425                 :            :                     }
     426                 :            : 
     427                 :            :                 }
     428         [ #  # ]:          0 :                 catch ( registry::InvalidRegistryException const & )
     429                 :            :                 {
     430                 :            :                     // getValueType, getBinaryValue
     431                 :            : 
     432                 :            :                     OSL_FAIL( "TypeDescriptionEnumerationImpl::queryMore "
     433                 :            :                                 "- Caught InvalidRegistryException!" );
     434                 :            : 
     435                 :            :                     // Don't stop iterating!
     436                 :            :                 }
     437 [ +  - ][ #  # ]:       2090 :             }
     438                 :            :         }
     439   [ #  #  #  # ]:          0 :         catch ( registry::InvalidRegistryException const & )
     440                 :            :         {
     441                 :            :             // openKeys
     442                 :            : 
     443         [ #  # ]:          0 :             for ( sal_Int32 n = 0; n < aKeys.getLength(); ++n )
     444                 :            :             {
     445                 :            :                 try
     446                 :            :                 {
     447   [ #  #  #  #  :          0 :                     aKeys[ n ]->closeKey();
                   #  # ]
     448                 :            :                 }
     449         [ #  # ]:          0 :                 catch ( registry::InvalidRegistryException const & )
     450                 :            :                 {
     451                 :            :                     OSL_FAIL( "TypeDescriptionEnumerationImpl::queryMore "
     452                 :            :                                 "- Caught InvalidRegistryException!" );
     453                 :            :                 }
     454                 :            :             }
     455                 :            :         }
     456                 :            : 
     457                 :            :         /////////////////////////////////////////////////////////////////////
     458                 :            :         // Special handling for constants contained directly in module.
     459                 :            :         /////////////////////////////////////////////////////////////////////
     460                 :            : 
     461                 :            :         // Constants requested?
     462                 :         20 :         bool bIncludeConstants = ( m_aTypes.getLength() == 0 );
     463         [ +  - ]:         20 :         if ( !bIncludeConstants )
     464                 :            :         {
     465         [ +  + ]:         40 :             for ( sal_Int32 m = 0; m < m_aTypes.getLength(); ++m )
     466                 :            :             {
     467 [ +  - ][ -  + ]:         20 :                 if ( m_aTypes[ m ] == uno::TypeClass_CONSTANT )
     468                 :            :                 {
     469                 :          0 :                     bIncludeConstants = true;
     470                 :          0 :                     break;
     471                 :            :                 }
     472                 :            :             }
     473                 :            : 
     474                 :            :         }
     475                 :            : 
     476         [ -  + ]:         20 :         if ( bIncludeConstants )
     477                 :            :         {
     478 [ #  # ][ #  # ]:          0 :             if ( m_aModuleKeys.front()->getValueType()
         [ #  # ][ #  # ]
     479                 :            :                     == registry::RegistryValueType_BINARY )
     480                 :            :             {
     481                 :            :                 try
     482                 :            :                 {
     483                 :            :                     uno::Sequence< sal_Int8 > aBytes(
     484 [ #  # ][ #  # ]:          0 :                         m_aModuleKeys.front()->getBinaryValue() );
                 [ #  # ]
     485                 :            : 
     486                 :            :                     typereg::Reader aReader(
     487                 :          0 :                         aBytes.getConstArray(), aBytes.getLength(), false,
     488         [ #  # ]:          0 :                         TYPEREG_VERSION_1);
     489                 :            : 
     490         [ #  # ]:          0 :                     if ( aReader.getTypeClass() == RT_TYPE_MODULE )
     491                 :            :                     {
     492                 :          0 :                         sal_uInt16 nFields = aReader.getFieldCount();
     493         [ #  # ]:          0 :                         while ( nFields-- )
     494                 :            :                         {
     495                 :            :                             rtl::OUStringBuffer aName(
     496 [ #  # ][ #  # ]:          0 :                                 aReader.getTypeName().replace( '/', '.' ) );
     497         [ #  # ]:          0 :                             aName.appendAscii( "." );
     498 [ #  # ][ #  # ]:          0 :                             aName.append( aReader.getFieldName( nFields ) );
     499                 :            : 
     500                 :            :                             uno::Any aValue(
     501                 :            :                                 getRTValue(
     502 [ #  # ][ #  # ]:          0 :                                     aReader.getFieldValue( nFields ) ) );
     503                 :            : 
     504                 :            :                             m_aTypeDescs.push_back(
     505                 :            :                                 new IndividualConstantTypeDescriptionImpl(
     506                 :            :                                     aName.makeStringAndClear(), aValue,
     507                 :          0 :                                     ( ( aReader.getFieldFlags( nFields )
     508                 :            :                                         & RT_ACCESS_PUBLISHED )
     509 [ #  # ][ #  # ]:          0 :                                       != 0 ) ) );
                 [ #  # ]
           [ #  #  #  # ]
     510                 :          0 :                         }
     511 [ #  # ][ #  # ]:          0 :                     }
     512                 :            :                 }
     513         [ #  # ]:          0 :                 catch ( registry::InvalidRegistryException const & )
     514                 :            :                 {
     515                 :            :                     // getBinaryValue
     516                 :            : 
     517                 :            :                     OSL_FAIL( "TypeDescriptionEnumerationImpl::queryMore "
     518                 :            :                                 "- Caught InvalidRegistryException!" );
     519                 :            :                 }
     520                 :            :             }
     521                 :            :         }
     522                 :            : 
     523                 :            :         /////////////////////////////////////////////////////////////////////
     524                 :            : 
     525                 :            : /*
     526                 :            :    @@@ m_aModuleKeys.front() may have open sub keys (may be contained in
     527                 :            :        both m_aModuleKeys and m_aCurrentModuleSubKeys)!
     528                 :            : 
     529                 :            :         try
     530                 :            :         {
     531                 :            :            m_aModuleKeys.front()->closeKey();
     532                 :            :         }
     533                 :            :         catch ( registry::InvalidRegistryException const & )
     534                 :            :         {
     535                 :            :             OSL_FAIL( "TypeDescriptionEnumerationImpl::queryMore "
     536                 :            :                         "- Caught InvalidRegistryException!" );
     537                 :            :         }
     538                 :            : */
     539                 :            :         // We're done with this module key, even if there were errors.
     540         [ +  - ]:         20 :         m_aModuleKeys.pop_front();
     541 [ +  - ][ +  - ]:       6630 :     }
     542                 :            : 
     543                 :            :     // unreachable
     544                 :            : }
     545                 :            : 
     546                 :            : //=========================================================================
     547                 :            : uno::Reference< reflection::XTypeDescription >
     548                 :       1652 : TypeDescriptionEnumerationImpl::queryNext()
     549                 :            : {
     550         [ +  - ]:       1652 :     osl::MutexGuard aGuard( m_aMutex );
     551                 :            : 
     552                 :          0 :     for (;;)
     553                 :            :     {
     554 [ +  - ][ -  + ]:       1652 :         if ( !queryMore() )
     555                 :          0 :             return uno::Reference< reflection::XTypeDescription >();
     556                 :            : 
     557                 :       1652 :         uno::Reference< reflection::XTypeDescription > xTD;
     558                 :            : 
     559         [ -  + ]:       1652 :         if ( !m_aTypeDescs.empty() )
     560                 :            :         {
     561 [ #  # ][ #  # ]:          0 :             xTD = m_aTypeDescs.front();
     562         [ #  # ]:          0 :             m_aTypeDescs.pop_front();
     563                 :          0 :             return xTD;
     564                 :            :         }
     565                 :            : 
     566                 :            :         // Note: xKey is already opened.
     567                 :            :         uno::Reference< registry::XRegistryKey >
     568         [ +  - ]:       1652 :             xKey( m_aCurrentModuleSubKeys.front() );
     569                 :            : /*
     570                 :            :    @@@ xKey may still be contained in m_aModuleKeys, too
     571                 :            : 
     572                 :            :         // closes key in it's dtor (which is
     573                 :            :         // called even in case of exceptions).
     574                 :            :         RegistryKeyCloser aCloser( xKey );
     575                 :            : */
     576                 :            :         try
     577                 :            :         {
     578                 :            :             {
     579 [ +  - ][ +  - ]:       1652 :                 if ( xKey->isValid() )
                 [ +  - ]
     580                 :            :                 {
     581 [ +  - ][ +  - ]:       1652 :                     if ( xKey->getValueType()
                 [ +  - ]
     582                 :            :                             == registry::RegistryValueType_BINARY )
     583                 :            :                     {
     584                 :            :                         uno::Sequence< sal_Int8 > aBytes(
     585 [ +  - ][ +  - ]:       1652 :                             xKey->getBinaryValue() );
     586                 :            : 
     587                 :            :                         xTD = createTypeDescription( aBytes,
     588                 :            :                                                      m_xTDMgr,
     589 [ +  - ][ +  - ]:       1652 :                                                      false );
     590                 :            :                         OSL_ENSURE( xTD.is(),
     591                 :            :                             "TypeDescriptionEnumerationImpl::queryNext "
     592 [ #  # ][ +  - ]:       1652 :                             "- No XTypeDescription created!" );
     593                 :            :                     }
     594                 :            :                 }
     595                 :            :                 else
     596                 :            :                 {
     597                 :            :                     OSL_FAIL( "TypeDescriptionEnumerationImpl::queryNext "
     598                 :            :                         "- Invalid registry key!" );
     599                 :            :                 }
     600                 :            :             }
     601                 :            :         }
     602         [ #  # ]:          0 :         catch ( registry::InvalidRegistryException const & )
     603                 :            :         {
     604                 :            :             // getValueType, getBinaryValue
     605                 :            : 
     606                 :            :             OSL_FAIL( "TypeDescriptionEnumerationImpl::queryNext "
     607                 :            :                         "- Caught InvalidRegistryException!" );
     608                 :            :         }
     609                 :            : 
     610                 :            :         // We're done with this key, even if there were errors.
     611         [ +  - ]:       1652 :         m_aCurrentModuleSubKeys.pop_front();
     612                 :            : 
     613         [ +  - ]:       1652 :         if ( xTD.is() )
     614                 :       1652 :             return xTD;
     615                 :            : 
     616                 :            :         // next try...
     617                 :            : 
     618 [ +  - ][ -  + ]:       1652 :     } // for (;;)
                 [ +  - ]
     619                 :            : }
     620                 :            : 
     621                 :            : } // namespace stoc_rdbtdp
     622                 :            : 
     623                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10