LCOV - code coverage report
Current view: top level - stoc/source/registry_tdprovider - tdcomp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 64 89.1 %
Date: 2012-08-25 Functions: 12 12 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 59 116 50.9 %

           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 "base.hxx"
      21                 :            : 
      22                 :            : #include "registry/reader.hxx"
      23                 :            : #include "registry/version.h"
      24                 :            : 
      25                 :            : namespace stoc_rdbtdp
      26                 :            : {
      27                 :            : 
      28                 :            : //__________________________________________________________________________________________________
      29         [ +  - ]:      11367 : CompoundTypeDescriptionImpl::~CompoundTypeDescriptionImpl()
      30                 :            : {
      31 [ +  + ][ +  - ]:      11367 :     delete _pMembers;
      32 [ +  + ][ +  - ]:      11367 :     delete _pMemberNames;
      33         [ +  - ]:      11367 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
      34         [ -  + ]:      22734 : }
      35                 :            : 
      36                 :            : // XTypeDescription
      37                 :            : //__________________________________________________________________________________________________
      38                 :      32008 : TypeClass CompoundTypeDescriptionImpl::getTypeClass()
      39                 :            :     throw(::com::sun::star::uno::RuntimeException)
      40                 :            : {
      41                 :      32008 :     return _eTypeClass;
      42                 :            : }
      43                 :            : //__________________________________________________________________________________________________
      44                 :      37940 : OUString CompoundTypeDescriptionImpl::getName()
      45                 :            :     throw(::com::sun::star::uno::RuntimeException)
      46                 :            : {
      47                 :      37940 :     return _aName;
      48                 :            : }
      49                 :            : 
      50                 :            : // XCompoundTypeDescription
      51                 :            : //__________________________________________________________________________________________________
      52                 :       9304 : Reference< XTypeDescription > CompoundTypeDescriptionImpl::getBaseType()
      53                 :            :     throw(::com::sun::star::uno::RuntimeException)
      54                 :            : {
      55 [ +  + ][ +  + ]:       9304 :     if (!_xBaseTD.is() && !_aBaseType.isEmpty())
                 [ +  + ]
      56                 :            :     {
      57                 :            :         try
      58                 :            :         {
      59                 :       1924 :             Reference< XTypeDescription > xBaseTD;
      60 [ +  - ][ +  - ]:       1924 :             if (_xTDMgr->getByHierarchicalName( _aBaseType ) >>= xBaseTD)
         [ +  - ][ +  - ]
      61                 :            :             {
      62 [ +  - ][ +  - ]:       1924 :                 MutexGuard aGuard( getMutex() );
      63         [ +  - ]:       1924 :                 if (! _xBaseTD.is())
      64         [ +  - ]:       1924 :                     _xBaseTD = xBaseTD;
      65         [ +  - ]:       1924 :                 return _xBaseTD;
      66 [ -  + ][ #  # ]:       1924 :             }
      67                 :            :         }
      68                 :          0 :         catch (NoSuchElementException &)
      69                 :            :         {
      70                 :            :         }
      71                 :            :         // never try again, if no base td was found
      72                 :          0 :         _aBaseType = OUString();
      73                 :            :     }
      74                 :       9304 :     return _xBaseTD;
      75                 :            : }
      76                 :            : //__________________________________________________________________________________________________
      77                 :            : 
      78                 :            : namespace {
      79                 :            : 
      80         [ -  + ]:        508 : class TypeParameter: public WeakImplHelper1< XTypeDescription > {
      81                 :            : public:
      82                 :        261 :     explicit TypeParameter(OUString const & name): m_name(name) {}
      83                 :            : 
      84                 :       1000 :     virtual TypeClass SAL_CALL getTypeClass() throw (RuntimeException)
      85                 :       1000 :     { return TypeClass_UNKNOWN; }
      86                 :            : 
      87                 :        579 :     virtual OUString SAL_CALL getName() throw (RuntimeException)
      88                 :        579 :     { return m_name; }
      89                 :            : 
      90                 :            : private:
      91                 :            :     OUString m_name;
      92                 :            : };
      93                 :            : 
      94                 :            : }
      95                 :            : 
      96                 :       9725 : Sequence< Reference< XTypeDescription > > CompoundTypeDescriptionImpl::getMemberTypes()
      97                 :            :     throw(::com::sun::star::uno::RuntimeException)
      98                 :            : {
      99         [ +  + ]:       9725 :     if (! _pMembers)
     100                 :            :     {
     101                 :            :         typereg::Reader aReader(
     102                 :       8268 :             _aBytes.getConstArray(), _aBytes.getLength(), false,
     103         [ +  - ]:       8268 :             TYPEREG_VERSION_1);
     104                 :            : 
     105                 :       8268 :         sal_uInt16 nFields = aReader.getFieldCount();
     106                 :            :         Sequence< Reference< XTypeDescription > > * pTempMembers =
     107         [ +  - ]:       8268 :             new Sequence< Reference< XTypeDescription > >( nFields );
     108         [ +  - ]:       8268 :         Reference< XTypeDescription > * pMembers = pTempMembers->getArray();
     109                 :            : 
     110         [ +  + ]:      35411 :         while (nFields--)
     111                 :            :         {
     112         [ +  + ]:      27143 :             if ((aReader.getFieldFlags(nFields) & RT_ACCESS_PARAMETERIZED_TYPE)
     113                 :            :                 != 0)
     114                 :            :             {
     115                 :            :                 pMembers[nFields] = new TypeParameter(
     116 [ +  - ][ +  - ]:        261 :                     aReader.getFieldTypeName(nFields));
         [ +  - ][ +  - ]
     117                 :            :             } else {
     118                 :            :                 try {
     119         [ +  - ]:      26882 :                     _xTDMgr->getByHierarchicalName(
     120                 :      26882 :                         aReader.getFieldTypeName(nFields).replace('/', '.'))
     121 [ +  - ][ +  - ]:      26882 :                             >>= pMembers[nFields];
         [ +  - ][ #  # ]
     122         [ #  # ]:          0 :                 } catch (NoSuchElementException &) {}
     123                 :            :                 OSL_ENSURE(
     124                 :            :                     pMembers[nFields].is(), "### compound member unknown!");
     125                 :            :             }
     126                 :            :         }
     127                 :            : 
     128 [ +  - ][ +  - ]:       8268 :         ClearableMutexGuard aGuard( getMutex() );
     129         [ -  + ]:       8268 :         if (_pMembers)
     130                 :            :         {
     131         [ #  # ]:          0 :             aGuard.clear();
     132 [ #  # ][ #  # ]:          0 :             delete pTempMembers;
     133                 :            :         }
     134                 :            :         else
     135                 :            :         {
     136                 :       8268 :             _pMembers = pTempMembers;
     137         [ +  - ]:       8268 :         }
     138                 :            :     }
     139                 :            : 
     140                 :       9725 :     return *_pMembers;
     141                 :            : }
     142                 :            : //__________________________________________________________________________________________________
     143                 :       9304 : Sequence< OUString > CompoundTypeDescriptionImpl::getMemberNames()
     144                 :            :     throw(::com::sun::star::uno::RuntimeException)
     145                 :            : {
     146         [ +  + ]:       9304 :     if (! _pMemberNames)
     147                 :            :     {
     148                 :            :         typereg::Reader aReader(
     149                 :       8268 :             _aBytes.getConstArray(), _aBytes.getLength(), false,
     150         [ +  - ]:       8268 :             TYPEREG_VERSION_1);
     151                 :            : 
     152                 :       8268 :         sal_uInt16 nFields = aReader.getFieldCount();
     153         [ +  - ]:       8268 :         Sequence< OUString > * pTempMemberNames = new Sequence< OUString >( nFields );
     154         [ +  - ]:       8268 :         OUString * pMemberNames = pTempMemberNames->getArray();
     155                 :            : 
     156         [ +  + ]:      35411 :         while (nFields--)
     157                 :            :         {
     158         [ +  - ]:      27143 :             pMemberNames[nFields] = aReader.getFieldName( nFields );
     159                 :            :         }
     160                 :            : 
     161 [ +  - ][ +  - ]:       8268 :         ClearableMutexGuard aGuard( getMutex() );
     162         [ -  + ]:       8268 :         if (_pMemberNames)
     163                 :            :         {
     164         [ #  # ]:          0 :             aGuard.clear();
     165 [ #  # ][ #  # ]:          0 :             delete pTempMemberNames;
     166                 :            :         }
     167                 :            :         else
     168                 :            :         {
     169                 :       8268 :             _pMemberNames = pTempMemberNames;
     170         [ +  - ]:       8268 :         }
     171                 :            :     }
     172                 :       9304 :     return *_pMemberNames;
     173                 :            : }
     174                 :            : 
     175                 :            : }
     176                 :            : 
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10