LCOV - code coverage report
Current view: top level - comphelper/source/property - MasterPropertySetInfo.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 56 94.6 %
Date: 2012-08-25 Functions: 8 8 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 45 88 51.1 %

           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 <comphelper/MasterPropertySetInfo.hxx>
      21                 :            : #include <comphelper/TypeGeneration.hxx>
      22                 :            : 
      23                 :            : using ::rtl::OUString;
      24                 :            : using ::comphelper::PropertyInfo;
      25                 :            : using ::comphelper::GenerateCppuType;
      26                 :            : using ::comphelper::MasterPropertySetInfo;
      27                 :            : using ::com::sun::star::uno::Any;
      28                 :            : using ::com::sun::star::uno::Type;
      29                 :            : using ::com::sun::star::uno::Sequence;
      30                 :            : using ::com::sun::star::uno::Reference;
      31                 :            : using ::com::sun::star::uno::XInterface;
      32                 :            : using ::com::sun::star::uno::RuntimeException;
      33                 :            : using ::com::sun::star::beans::Property;
      34                 :            : using ::com::sun::star::beans::XPropertySetInfo;
      35                 :            : using ::com::sun::star::beans::UnknownPropertyException;
      36                 :            : 
      37                 :        748 : MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo* pMap )
      38 [ +  - ][ +  - ]:        748 :     throw()
      39                 :            : {
      40                 :        748 :     add ( pMap );
      41                 :        748 : }
      42                 :            : 
      43                 :       1496 : MasterPropertySetInfo::~MasterPropertySetInfo()
      44 [ +  - ][ +  - ]:        748 :     throw()
      45                 :            : {
      46 [ +  - ][ +  - ]:        748 :     PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
      47         [ +  + ]:      55352 :     while (aIter != aEnd )
      48                 :            :     {
      49         [ +  - ]:      54604 :         delete (*aIter).second;
      50                 :      54604 :         ++aIter;
      51                 :            :     }
      52         [ -  + ]:       1496 : }
      53                 :            : 
      54                 :        748 : void MasterPropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount, sal_uInt8 nMapId )
      55                 :            :     throw()
      56                 :            : {
      57                 :            :     // nCount < 0   => add all
      58                 :            :     // nCount == 0  => add nothing
      59                 :            :     // nCount > 0   => add at most nCount entries
      60         [ -  + ]:        748 :     if( maProperties.getLength() )
      61                 :          0 :         maProperties.realloc( 0 );
      62                 :            : 
      63 [ +  + ][ -  + ]:      41888 :     for ( ; pMap->mpName && ( ( nCount < 0 ) || ( nCount > 0 ) ); --nCount, ++pMap )
         [ #  # ][ +  + ]
      64                 :            :     {
      65         [ +  - ]:      41140 :         OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
      66                 :            : 
      67                 :            : #ifdef DBG_UTIL
      68                 :            :         PropertyDataHash::iterator aIter = maMap.find( aName );
      69                 :            :         if( aIter != maMap.end() )
      70                 :            :             OSL_FAIL( "Warning: PropertyInfo added twice, possible error!");
      71                 :            : #endif
      72 [ +  - ][ +  - ]:      41140 :         maMap[aName] = new PropertyData ( nMapId, pMap );
      73                 :      41140 :     }
      74                 :        748 : }
      75                 :            : 
      76                 :        748 : void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
      77                 :            :     throw()
      78                 :            : {
      79         [ -  + ]:        748 :     if( maProperties.getLength() )
      80         [ #  # ]:          0 :         maProperties.realloc( 0 );
      81 [ +  - ][ +  - ]:        748 :     PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
      82                 :            : 
      83         [ +  + ]:      14212 :     while ( aIter != aEnd )
      84                 :            :     {
      85                 :            : #ifdef DBG_UTIL
      86                 :            :         PropertyDataHash::iterator aDebugIter = maMap.find( (*aIter).first );
      87                 :            :         if( aDebugIter != maMap.end() )
      88                 :            :             OSL_FAIL( "Warning: PropertyInfo added twice, possible error!");
      89                 :            : #endif
      90 [ +  - ][ +  - ]:      13464 :         maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
         [ +  - ][ +  - ]
      91                 :      13464 :         ++aIter;
      92                 :            :     }
      93                 :        748 : }
      94                 :            : 
      95                 :         19 : Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
      96                 :            :     throw(::com::sun::star::uno::RuntimeException)
      97                 :            : {
      98                 :         19 :     sal_Int32 nSize = maMap.size();
      99         [ +  - ]:         19 :     if( maProperties.getLength() != nSize )
     100                 :            :     {
     101         [ +  - ]:         19 :         maProperties.realloc ( nSize );
     102         [ +  - ]:         19 :         Property* pProperties = maProperties.getArray();
     103                 :            : 
     104         [ +  - ]:         19 :         PropertyDataHash::iterator aIter = maMap.begin();
     105         [ +  - ]:         19 :         const PropertyDataHash::iterator aEnd = maMap.end();
     106         [ +  + ]:       1406 :         for ( ; aIter != aEnd; ++aIter, ++pProperties)
     107                 :            :         {
     108         [ +  - ]:       1387 :             PropertyInfo* pInfo = (*aIter).second->mpInfo;
     109                 :            : 
     110         [ +  - ]:       1387 :             pProperties->Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
     111                 :       1387 :             pProperties->Handle = pInfo->mnHandle;
     112                 :            :             const Type* pType;
     113         [ +  - ]:       1387 :             GenerateCppuType ( pInfo->meCppuType, pType);
     114                 :       1387 :             pProperties->Type = *pType;
     115                 :       1387 :             pProperties->Attributes = pInfo->mnAttributes;
     116                 :            :         }
     117                 :            :     }
     118                 :         19 :     return maProperties;
     119                 :            : }
     120                 :            : 
     121                 :         44 : Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const ::rtl::OUString& rName )
     122                 :            :     throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
     123                 :            : {
     124         [ +  - ]:         44 :     PropertyDataHash::iterator aIter = maMap.find( rName );
     125                 :            : 
     126 [ +  - ][ -  + ]:         44 :     if ( maMap.end() == aIter )
     127 [ #  # ][ #  # ]:          0 :         throw UnknownPropertyException( rName, *this );
     128                 :            : 
     129         [ +  - ]:         44 :     PropertyInfo *pInfo = (*aIter).second->mpInfo;
     130                 :         44 :     Property aProperty;
     131         [ +  - ]:         44 :     aProperty.Name   = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
     132                 :         44 :     aProperty.Handle = pInfo->mnHandle;
     133                 :            :     const Type* pType;
     134         [ +  - ]:         44 :     GenerateCppuType ( pInfo->meCppuType, pType );
     135                 :         44 :     aProperty.Type = *pType;
     136                 :            : 
     137                 :         44 :     aProperty.Attributes = pInfo->mnAttributes;
     138                 :         44 :     return aProperty;
     139                 :            : }
     140                 :            : 
     141                 :       4241 : sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const ::rtl::OUString& rName )
     142                 :            :     throw(::com::sun::star::uno::RuntimeException)
     143                 :            : {
     144         [ +  - ]:       4241 :     return static_cast < sal_Bool > ( maMap.find ( rName ) != maMap.end() );
     145                 :            : }
     146                 :            : 
     147                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10