LCOV - code coverage report
Current view: top level - svx/source/table - propertyset.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 48 82 58.5 %
Date: 2014-11-03 Functions: 13 24 54.2 %
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             : 
      21             : #include "propertyset.hxx"
      22             : 
      23             : using namespace ::com::sun::star::uno;
      24             : using namespace ::com::sun::star::beans;
      25             : using namespace ::com::sun::star::lang;
      26             : 
      27             : namespace sdr { namespace table {
      28             : 
      29          12 : FastPropertySetInfo::FastPropertySetInfo( const PropertyVector& rProps )
      30             : {
      31          12 :     addProperties( rProps );
      32          12 : }
      33             : 
      34             : 
      35             : 
      36          24 : FastPropertySetInfo::~FastPropertySetInfo()
      37             : {
      38          24 : }
      39             : 
      40             : 
      41             : 
      42          12 : void FastPropertySetInfo::addProperties( const PropertyVector& rProps )
      43             : {
      44          12 :     sal_uInt32 nIndex = maProperties.size();
      45          12 :     sal_uInt32 nCount = rProps.size();
      46          12 :     maProperties.resize( nIndex + nCount );
      47          12 :     PropertyVector::const_iterator aIter( rProps.begin() );
      48          96 :     while( nCount-- )
      49             :     {
      50          72 :         const Property& rProperty = (*aIter++);
      51          72 :         maProperties[nIndex] = rProperty;
      52          72 :         maMap[ rProperty.Name ] = nIndex++;
      53             :     }
      54          12 : }
      55             : 
      56             : 
      57             : 
      58        8568 : const Property& FastPropertySetInfo::getProperty( const OUString& aName ) throw (UnknownPropertyException )
      59             : {
      60        8568 :     PropertyMap::iterator aIter( maMap.find( aName ) );
      61        8568 :     if( aIter == maMap.end() )
      62           0 :         throw UnknownPropertyException();
      63        8568 :     return maProperties[(*aIter).second];
      64             : }
      65             : 
      66             : 
      67             : 
      68         140 : const Property* FastPropertySetInfo::hasProperty( const OUString& aName )
      69             : {
      70         140 :     PropertyMap::iterator aIter( maMap.find( aName ) );
      71         140 :     if( aIter == maMap.end() )
      72           0 :         return 0;
      73             :     else
      74         140 :         return &maProperties[(*aIter).second];
      75             : }
      76             : 
      77             : 
      78             : // XPropertySetInfo
      79             : 
      80             : 
      81           0 : Sequence< Property > SAL_CALL FastPropertySetInfo::getProperties() throw (RuntimeException, std::exception)
      82             : {
      83           0 :     return Sequence< Property >( &maProperties[0], maProperties.size() );
      84             : }
      85             : 
      86             : 
      87             : 
      88           0 : Property SAL_CALL FastPropertySetInfo::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException, std::exception)
      89             : {
      90           0 :     return getProperty( aName );
      91             : }
      92             : 
      93             : 
      94             : 
      95          70 : sal_Bool SAL_CALL FastPropertySetInfo::hasPropertyByName( const OUString& aName ) throw (RuntimeException, std::exception)
      96             : {
      97          70 :     return hasProperty( aName ) != 0 ? sal_True : sal_False;
      98             : }
      99             : 
     100         596 : FastPropertySet::FastPropertySet( const rtl::Reference< FastPropertySetInfo >& xInfo )
     101         596 : : mxInfo( xInfo )
     102             : {
     103         596 : }
     104             : 
     105             : 
     106             : 
     107         596 : FastPropertySet::~FastPropertySet()
     108             : {
     109         596 : }
     110             : 
     111             : 
     112             : // XPropertySet
     113             : 
     114             : 
     115          50 : Reference< XPropertySetInfo > SAL_CALL FastPropertySet::getPropertySetInfo(  ) throw (RuntimeException, std::exception)
     116             : {
     117          50 :     return Reference< XPropertySetInfo >( mxInfo.get() );
     118             : }
     119             : 
     120             : 
     121             : 
     122        1296 : void SAL_CALL FastPropertySet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
     123             : {
     124        1296 :     setFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle, aValue );
     125        1296 : }
     126             : 
     127             : 
     128             : 
     129        7272 : Any SAL_CALL FastPropertySet::getPropertyValue( const OUString& aPropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     130             : {
     131        7272 :     return getFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle );
     132             : }
     133             : 
     134             : 
     135             : 
     136           0 : void SAL_CALL FastPropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     137             : {
     138           0 : }
     139             : 
     140             : 
     141             : 
     142           0 : void SAL_CALL FastPropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     143             : {
     144           0 : }
     145             : 
     146             : 
     147             : 
     148           0 : void SAL_CALL FastPropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     149             : {
     150           0 : }
     151             : 
     152             : 
     153             : 
     154           0 : void SAL_CALL FastPropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     155             : {
     156           0 : }
     157             : 
     158             : 
     159             : // XMultiPropertySet
     160             : 
     161             : 
     162          50 : void SAL_CALL FastPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
     163             : {
     164          50 :     const OUString* pPropertyNames = aPropertyNames.getConstArray();
     165          50 :     const Any* pValues = aValues.getConstArray();
     166          50 :     sal_Int32 nCount = aPropertyNames.getLength();
     167          50 :     if( nCount != aValues.getLength() )
     168           0 :         throw IllegalArgumentException();
     169             : 
     170         170 :     while( nCount-- )
     171             :     {
     172          70 :         const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
     173          70 :         if( pProperty ) try
     174             :         {
     175          70 :             setFastPropertyValue( pProperty->Handle, *pValues );
     176             :         }
     177           0 :         catch( UnknownPropertyException& )
     178             :         {
     179             :         }
     180          70 :         pValues++;
     181             :     }
     182          50 : }
     183             : 
     184             : 
     185             : 
     186           0 : Sequence< Any > SAL_CALL FastPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException, std::exception)
     187             : {
     188           0 :     sal_Int32 nCount = aPropertyNames.getLength();
     189           0 :     Sequence< Any > aValues( nCount );
     190             : 
     191           0 :     const OUString* pPropertyNames = aPropertyNames.getConstArray();
     192           0 :     Any* pValues = aValues.getArray();
     193           0 :     while( nCount-- )
     194             :     {
     195           0 :         const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
     196           0 :         if( pProperty ) try
     197             :         {
     198           0 :             *pValues = getFastPropertyValue( pProperty->Handle );
     199             :         }
     200           0 :         catch( UnknownPropertyException& )
     201             :         {
     202             :         }
     203           0 :         pValues++;
     204             :     }
     205           0 :     return aValues;
     206             : }
     207             : 
     208             : 
     209             : 
     210           0 : void SAL_CALL FastPropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException, std::exception)
     211             : {
     212           0 : }
     213             : 
     214             : 
     215             : 
     216           0 : void SAL_CALL FastPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& ) throw (RuntimeException, std::exception)
     217             : {
     218           0 : }
     219             : 
     220             : 
     221             : 
     222           0 : void SAL_CALL FastPropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException, std::exception)
     223             : {
     224           0 : }
     225             : 
     226             : }}
     227             : 
     228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10