LCOV - code coverage report
Current view: top level - libreoffice/stoc/source/registry_tdprovider - tdenum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 44 90.9 %
Date: 2012-12-27 Functions: 7 7 100.0 %
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 "base.hxx"
      21             : 
      22             : #include "registry/reader.hxx"
      23             : #include "registry/version.h"
      24             : 
      25             : namespace stoc_rdbtdp
      26             : {
      27             : 
      28             : //__________________________________________________________________________________________________
      29         318 : EnumTypeDescriptionImpl::~EnumTypeDescriptionImpl()
      30             : {
      31         106 :     delete _pEnumNames;
      32         106 :     delete _pEnumValues;
      33         106 :     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
      34         212 : }
      35             : 
      36             : // XTypeDescription
      37             : //__________________________________________________________________________________________________
      38         234 : TypeClass EnumTypeDescriptionImpl::getTypeClass()
      39             :     throw(::com::sun::star::uno::RuntimeException)
      40             : {
      41         234 :     return TypeClass_ENUM;
      42             : }
      43             : //__________________________________________________________________________________________________
      44         255 : OUString EnumTypeDescriptionImpl::getName()
      45             :     throw(::com::sun::star::uno::RuntimeException)
      46             : {
      47         255 :     return _aName;
      48             : }
      49             : 
      50             : // XEnumTypeDescription
      51             : //__________________________________________________________________________________________________
      52         109 : sal_Int32 EnumTypeDescriptionImpl::getDefaultEnumValue()
      53             :     throw(::com::sun::star::uno::RuntimeException)
      54             : {
      55         109 :     return _nDefaultValue;
      56             : }
      57             : //__________________________________________________________________________________________________
      58         109 : Sequence< OUString > EnumTypeDescriptionImpl::getEnumNames()
      59             :     throw(::com::sun::star::uno::RuntimeException)
      60             : {
      61         109 :     if (! _pEnumNames)
      62             :     {
      63             :         typereg::Reader aReader(
      64         214 :             _aBytes.getConstArray(), _aBytes.getLength(), false,
      65         214 :             TYPEREG_VERSION_1);
      66             : 
      67         107 :         sal_uInt16 nFields = aReader.getFieldCount();
      68         107 :         Sequence< OUString > * pTempEnumNames = new Sequence< OUString >( nFields );
      69         107 :         OUString * pEnumNames = pTempEnumNames->getArray();
      70             : 
      71        1235 :         while (nFields--)
      72             :         {
      73        1021 :             pEnumNames[nFields] = aReader.getFieldName( nFields );
      74             :         }
      75             : 
      76         107 :         ClearableMutexGuard aGuard( getMutex() );
      77         107 :         if (_pEnumNames)
      78             :         {
      79           0 :             aGuard.clear();
      80           0 :             delete pTempEnumNames;
      81             :         }
      82             :         else
      83             :         {
      84         107 :             _pEnumNames = pTempEnumNames;
      85         107 :         }
      86             :     }
      87         109 :     return *_pEnumNames;
      88             : }
      89             : //__________________________________________________________________________________________________
      90         109 : Sequence< sal_Int32 > EnumTypeDescriptionImpl::getEnumValues()
      91             :     throw(::com::sun::star::uno::RuntimeException)
      92             : {
      93         109 :     if (! _pEnumValues)
      94             :     {
      95             :         typereg::Reader aReader(
      96         214 :             _aBytes.getConstArray(), _aBytes.getLength(), false,
      97         214 :             TYPEREG_VERSION_1);
      98             : 
      99         107 :         sal_uInt16 nFields = aReader.getFieldCount();
     100         107 :         Sequence< sal_Int32 > * pTempEnumValues = new Sequence< sal_Int32 >( nFields );
     101         107 :         sal_Int32 * pEnumValues = pTempEnumValues->getArray();
     102             : 
     103        1235 :         while (nFields--)
     104             :         {
     105        1021 :             pEnumValues[nFields] = getRTValueAsInt32(
     106        1021 :                 aReader.getFieldValue( nFields ) );
     107             :         }
     108             : 
     109         107 :         ClearableMutexGuard aGuard( getMutex() );
     110         107 :         if (_pEnumValues)
     111             :         {
     112           0 :             aGuard.clear();
     113           0 :             delete pTempEnumValues;
     114             :         }
     115             :         else
     116             :         {
     117         107 :             _pEnumValues = pTempEnumValues;
     118         107 :         }
     119             :     }
     120         109 :     return *_pEnumValues;
     121             : }
     122             : 
     123             : }
     124             : 
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10