LCOV - code coverage report
Current view: top level - comphelper/source/property - ChainablePropertySetInfo.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 35 37 94.6 %
Date: 2014-11-03 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 <comphelper/ChainablePropertySetInfo.hxx>
      21             : 
      22             : using ::comphelper::PropertyInfo;
      23             : using ::comphelper::ChainablePropertySetInfo;
      24             : using ::com::sun::star::uno::Any;
      25             : using ::com::sun::star::uno::Type;
      26             : using ::com::sun::star::uno::Sequence;
      27             : using ::com::sun::star::uno::Reference;
      28             : using ::com::sun::star::uno::XInterface;
      29             : using ::com::sun::star::uno::RuntimeException;
      30             : using ::com::sun::star::beans::Property;
      31             : using ::com::sun::star::beans::XPropertySetInfo;
      32             : using ::com::sun::star::beans::UnknownPropertyException;
      33             : 
      34       10202 : ChainablePropertySetInfo::ChainablePropertySetInfo( PropertyInfo const * pMap )
      35             : {
      36      194482 :     for( ; !pMap->maName.isEmpty(); ++pMap )
      37             :     {
      38             :         SAL_WARN_IF(
      39             :             maMap.find(pMap->maName) != maMap.end(),
      40             :             "comphelper", "Duplicate property name \"" << pMap->maName << "\"");
      41      184280 :         maMap[pMap->maName] = pMap;
      42             :     }
      43       10202 : }
      44             : 
      45       20404 : ChainablePropertySetInfo::~ChainablePropertySetInfo()
      46       10202 :     throw()
      47             : {
      48       20404 : }
      49             : 
      50           2 : void ChainablePropertySetInfo::remove( const OUString& aName )
      51             : {
      52           2 :     maMap.erase ( aName );
      53           2 :     if ( maProperties.getLength() )
      54           0 :          maProperties.realloc( 0 );
      55           2 : }
      56             : 
      57           2 : Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties()
      58             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
      59             : {
      60           2 :     sal_Int32 nSize = maMap.size();
      61           2 :     if( maProperties.getLength() != nSize )
      62             :     {
      63           2 :         maProperties.realloc ( nSize );
      64           2 :         Property* pProperties = maProperties.getArray();
      65             : 
      66          84 :         for (PropertyInfoHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()); aIter != aEnd; ++aIter, ++pProperties)
      67             :         {
      68          82 :             PropertyInfo const * pInfo = (*aIter).second;
      69             : 
      70          82 :             pProperties->Name = pInfo->maName;
      71          82 :             pProperties->Handle = pInfo->mnHandle;
      72          82 :             pProperties->Type = pInfo->maType;
      73          82 :             pProperties->Attributes = pInfo->mnAttributes;
      74             :         }
      75             :     }
      76           2 :     return maProperties;
      77             : }
      78             : 
      79          82 : Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const OUString& rName )
      80             :     throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
      81             : {
      82          82 :     PropertyInfoHash::iterator aIter = maMap.find( rName );
      83             : 
      84          82 :     if ( maMap.end() == aIter )
      85           0 :         throw UnknownPropertyException( rName, *this );
      86             : 
      87          82 :     PropertyInfo const *pInfo = (*aIter).second;
      88          82 :     Property aProperty;
      89          82 :     aProperty.Name   = pInfo->maName;
      90          82 :     aProperty.Handle = pInfo->mnHandle;
      91          82 :     aProperty.Type = pInfo->maType;
      92          82 :     aProperty.Attributes = pInfo->mnAttributes;
      93          82 :     return aProperty;
      94             : }
      95             : 
      96          84 : sal_Bool SAL_CALL ChainablePropertySetInfo::hasPropertyByName( const OUString& rName )
      97             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
      98             : {
      99          84 :     return maMap.find ( rName ) != maMap.end();
     100             : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10