LCOV - code coverage report
Current view: top level - libreoffice/comphelper/source/property - ChainablePropertySetInfo.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 50 28.0 %
Date: 2012-12-27 Functions: 4 8 50.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 <comphelper/ChainablePropertySetInfo.hxx>
      21             : #include <comphelper/TypeGeneration.hxx>
      22             : 
      23             : using ::rtl::OUString;
      24             : using ::comphelper::PropertyInfo;
      25             : using ::comphelper::GenerateCppuType;
      26             : using ::comphelper::ChainablePropertySetInfo;
      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         419 : ChainablePropertySetInfo::ChainablePropertySetInfo( PropertyInfo* pMap )
      38         419 :     throw()
      39             : {
      40         419 :     add ( pMap );
      41         419 : }
      42             : 
      43         836 : ChainablePropertySetInfo::~ChainablePropertySetInfo()
      44         418 :     throw()
      45             : {
      46         836 : }
      47             : 
      48         419 : void ChainablePropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount )
      49             :     throw()
      50             : {
      51             :     // nCount < 0   => add all
      52             :     // nCount == 0  => add nothing
      53             :     // nCount > 0   => add at most nCount entries
      54         419 :     if( maProperties.getLength() )
      55           0 :         maProperties.realloc( 0 );
      56             : 
      57        8424 :     while( pMap->mpName && ( ( nCount < 0) || ( nCount-- > 0 ) ) )
      58             :     {
      59        7586 :         OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
      60             : 
      61             : #ifdef DBG_UTIL
      62             :         PropertyInfoHash::iterator aIter = maMap.find( aName );
      63             :         if( aIter != maMap.end() )
      64             :             OSL_FAIL( "Warning: PropertyInfo added twice, possible error!");
      65             : #endif
      66        7586 :         maMap[aName] = pMap++;
      67        7586 :     }
      68         419 : }
      69             : 
      70           0 : void ChainablePropertySetInfo::remove( const rtl::OUString& aName )
      71             :     throw()
      72             : {
      73           0 :     maMap.erase ( aName );
      74           0 :     if ( maProperties.getLength() )
      75           0 :          maProperties.realloc( 0 );
      76           0 : }
      77             : 
      78           0 : Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties()
      79             :     throw(::com::sun::star::uno::RuntimeException)
      80             : {
      81           0 :     sal_Int32 nSize = maMap.size();
      82           0 :     if( maProperties.getLength() != nSize )
      83             :     {
      84           0 :         maProperties.realloc ( nSize );
      85           0 :         Property* pProperties = maProperties.getArray();
      86             : 
      87           0 :         PropertyInfoHash::iterator aIter = maMap.begin();
      88           0 :         const PropertyInfoHash::iterator aEnd = maMap.end();
      89           0 :         for ( ; aIter != aEnd; ++aIter, ++pProperties)
      90             :         {
      91           0 :             PropertyInfo* pInfo = (*aIter).second;
      92             : 
      93           0 :             pProperties->Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
      94           0 :             pProperties->Handle = pInfo->mnHandle;
      95             :             const Type* pType;
      96           0 :             GenerateCppuType ( pInfo->meCppuType, pType);
      97           0 :             pProperties->Type = *pType;
      98           0 :             pProperties->Attributes = pInfo->mnAttributes;
      99             :         }
     100             :     }
     101           0 :     return maProperties;
     102             : }
     103             : 
     104           0 : Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const ::rtl::OUString& rName )
     105             :     throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
     106             : {
     107           0 :     PropertyInfoHash::iterator aIter = maMap.find( rName );
     108             : 
     109           0 :     if ( maMap.end() == aIter )
     110           0 :         throw UnknownPropertyException( rName, *this );
     111             : 
     112           0 :     PropertyInfo *pInfo = (*aIter).second;
     113           0 :     Property aProperty;
     114           0 :     aProperty.Name   = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
     115           0 :     aProperty.Handle = pInfo->mnHandle;
     116           0 :     const Type* pType = &aProperty.Type;
     117           0 :     GenerateCppuType ( pInfo->meCppuType, pType );
     118           0 :     aProperty.Type = *pType;
     119           0 :     aProperty.Attributes = pInfo->mnAttributes;
     120           0 :     return aProperty;
     121             : }
     122             : 
     123           0 : sal_Bool SAL_CALL ChainablePropertySetInfo::hasPropertyByName( const ::rtl::OUString& rName )
     124             :     throw(::com::sun::star::uno::RuntimeException)
     125             : {
     126           0 :     return static_cast < sal_Bool > ( maMap.find ( rName ) != maMap.end() );
     127             : }
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10