LCOV - code coverage report
Current view: top level - libreoffice/comphelper/source/property - MasterPropertySetInfo.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 56 75.0 %
Date: 2012-12-27 Functions: 7 8 87.5 %
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 <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         417 : MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo* pMap )
      38         417 :     throw()
      39             : {
      40         417 :     add ( pMap );
      41         417 : }
      42             : 
      43         834 : MasterPropertySetInfo::~MasterPropertySetInfo()
      44         834 :     throw()
      45             : {
      46         417 :     PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
      47       32943 :     while (aIter != aEnd )
      48             :     {
      49       32109 :         delete (*aIter).second;
      50       32109 :         ++aIter;
      51             :     }
      52         834 : }
      53             : 
      54         417 : 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         417 :     if( maProperties.getLength() )
      61           0 :         maProperties.realloc( 0 );
      62             : 
      63       25020 :     for ( ; pMap->mpName && ( ( nCount < 0 ) || ( nCount > 0 ) ); --nCount, ++pMap )
      64             :     {
      65       24603 :         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       24603 :         maMap[aName] = new PropertyData ( nMapId, pMap );
      73       24603 :     }
      74         417 : }
      75             : 
      76         417 : void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
      77             :     throw()
      78             : {
      79         417 :     if( maProperties.getLength() )
      80           0 :         maProperties.realloc( 0 );
      81         417 :     PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
      82             : 
      83        8340 :     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        7506 :         maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
      91        7506 :         ++aIter;
      92             :     }
      93         417 : }
      94             : 
      95           2 : Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
      96             :     throw(::com::sun::star::uno::RuntimeException)
      97             : {
      98           2 :     sal_Int32 nSize = maMap.size();
      99           2 :     if( maProperties.getLength() != nSize )
     100             :     {
     101           2 :         maProperties.realloc ( nSize );
     102           2 :         Property* pProperties = maProperties.getArray();
     103             : 
     104           2 :         PropertyDataHash::iterator aIter = maMap.begin();
     105           2 :         const PropertyDataHash::iterator aEnd = maMap.end();
     106         156 :         for ( ; aIter != aEnd; ++aIter, ++pProperties)
     107             :         {
     108         154 :             PropertyInfo* pInfo = (*aIter).second->mpInfo;
     109             : 
     110         154 :             pProperties->Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
     111         154 :             pProperties->Handle = pInfo->mnHandle;
     112             :             const Type* pType;
     113         154 :             GenerateCppuType ( pInfo->meCppuType, pType);
     114         154 :             pProperties->Type = *pType;
     115         154 :             pProperties->Attributes = pInfo->mnAttributes;
     116             :         }
     117             :     }
     118           2 :     return maProperties;
     119             : }
     120             : 
     121           0 : Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const ::rtl::OUString& rName )
     122             :     throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
     123             : {
     124           0 :     PropertyDataHash::iterator aIter = maMap.find( rName );
     125             : 
     126           0 :     if ( maMap.end() == aIter )
     127           0 :         throw UnknownPropertyException( rName, *this );
     128             : 
     129           0 :     PropertyInfo *pInfo = (*aIter).second->mpInfo;
     130           0 :     Property aProperty;
     131           0 :     aProperty.Name   = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
     132           0 :     aProperty.Handle = pInfo->mnHandle;
     133             :     const Type* pType;
     134           0 :     GenerateCppuType ( pInfo->meCppuType, pType );
     135           0 :     aProperty.Type = *pType;
     136             : 
     137           0 :     aProperty.Attributes = pInfo->mnAttributes;
     138           0 :     return aProperty;
     139             : }
     140             : 
     141         872 : sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const ::rtl::OUString& rName )
     142             :     throw(::com::sun::star::uno::RuntimeException)
     143             : {
     144         872 :     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