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

Generated by: LCOV version 1.11