LCOV - code coverage report
Current view: top level - comphelper/source/property - MasterPropertySetInfo.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 42 44 95.5 %
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/MasterPropertySetInfo.hxx>
      21             : 
      22             : using ::comphelper::PropertyInfo;
      23             : using ::comphelper::MasterPropertySetInfo;
      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       10172 : MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap )
      35             : {
      36      651008 :     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      640836 :         maMap[pMap->maName] = new PropertyData ( 0, pMap );
      42             :     }
      43       10172 : }
      44             : 
      45       20344 : MasterPropertySetInfo::~MasterPropertySetInfo()
      46       20344 :     throw()
      47             : {
      48       10172 :     PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
      49      844276 :     while (aIter != aEnd )
      50             :     {
      51      823932 :         delete (*aIter).second;
      52      823932 :         ++aIter;
      53             :     }
      54       20344 : }
      55             : 
      56       10172 : void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
      57             : {
      58       10172 :     if( maProperties.getLength() )
      59           0 :         maProperties.realloc( 0 );
      60       10172 :     PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
      61             : 
      62      203440 :     while ( aIter != aEnd )
      63             :     {
      64             :         SAL_WARN_IF(
      65             :             maMap.find(aIter->first) != maMap.end(),
      66             :             "comphelper", "Duplicate property name \"" << aIter->first << "\"");
      67      183096 :         maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
      68      183096 :         ++aIter;
      69             :     }
      70       10172 : }
      71             : 
      72          58 : Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
      73             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
      74             : {
      75          58 :     sal_Int32 nSize = maMap.size();
      76          58 :     if( maProperties.getLength() != nSize )
      77             :     {
      78          58 :         maProperties.realloc ( nSize );
      79          58 :         Property* pProperties = maProperties.getArray();
      80             : 
      81        4756 :         for (PropertyDataHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()) ; aIter != aEnd; ++aIter, ++pProperties)
      82             :         {
      83        4698 :             PropertyInfo const * pInfo = (*aIter).second->mpInfo;
      84             : 
      85        4698 :             pProperties->Name = pInfo->maName;
      86        4698 :             pProperties->Handle = pInfo->mnHandle;
      87        4698 :             pProperties->Type = pInfo->maType;
      88        4698 :             pProperties->Attributes = pInfo->mnAttributes;
      89             :         }
      90             :     }
      91          58 :     return maProperties;
      92             : }
      93             : 
      94          44 : Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const OUString& rName )
      95             :     throw(::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception)
      96             : {
      97          44 :     PropertyDataHash::iterator aIter = maMap.find( rName );
      98             : 
      99          44 :     if ( maMap.end() == aIter )
     100           0 :         throw UnknownPropertyException( rName, *this );
     101             : 
     102          44 :     PropertyInfo const *pInfo = (*aIter).second->mpInfo;
     103          44 :     Property aProperty;
     104          44 :     aProperty.Name   = pInfo->maName;
     105          44 :     aProperty.Handle = pInfo->mnHandle;
     106          44 :     aProperty.Type = pInfo->maType;
     107             : 
     108          44 :     aProperty.Attributes = pInfo->mnAttributes;
     109          44 :     return aProperty;
     110             : }
     111             : 
     112       23104 : sal_Bool SAL_CALL MasterPropertySetInfo::hasPropertyByName( const OUString& rName )
     113             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     114             : {
     115       23104 :     return maMap.find ( rName ) != maMap.end();
     116             : }
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10