LCOV - code coverage report
Current view: top level - toolkit/source/helper - unopropertyarrayhelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 51 68 75.0 %
Date: 2012-08-25 Functions: 6 9 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 45 96 46.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <toolkit/helper/unopropertyarrayhelper.hxx>
      31                 :            : #include <toolkit/helper/property.hxx>
      32                 :            : #include <map>
      33                 :            : 
      34                 :            : //  ----------------------------------------------------
      35                 :            : //  class UnoPropertyArrayHelper
      36                 :            : //  ----------------------------------------------------
      37                 :            : 
      38         [ +  - ]:        196 : UnoPropertyArrayHelper::UnoPropertyArrayHelper( const ::com::sun::star::uno::Sequence<sal_Int32>& rIDs )
      39                 :            : {
      40                 :        196 :     sal_Int32 nIDs = rIDs.getLength();
      41                 :        196 :     const sal_Int32* pIDs = rIDs.getConstArray();
      42         [ +  + ]:       4227 :     for ( sal_Int32 n = 0; n < nIDs; n++ )
      43         [ +  - ]:       4031 :         maIDs.insert( pIDs[n] );
      44                 :        196 : }
      45                 :            : 
      46         [ #  # ]:          0 : UnoPropertyArrayHelper::UnoPropertyArrayHelper( const std::list< sal_uInt16 > &rIDs )
      47                 :            : {
      48         [ #  # ]:          0 :     std::list< sal_uInt16 >::const_iterator iter;
      49 [ #  # ][ #  # ]:          0 :     for( iter = rIDs.begin(); iter != rIDs.end(); ++iter)
                 [ #  # ]
      50 [ #  # ][ #  # ]:          0 :       maIDs.insert( *iter );
      51                 :          0 : }
      52                 :            : 
      53                 :     314813 : sal_Bool UnoPropertyArrayHelper::ImplHasProperty( sal_uInt16 nPropId ) const
      54                 :            : {
      55 [ +  + ][ +  - ]:     314813 :     if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
      56                 :      83851 :         nPropId = BASEPROPERTY_FONTDESCRIPTOR;
      57                 :            : 
      58 [ +  - ][ +  - ]:     314813 :     return maIDs.find( nPropId ) != maIDs.end() ? sal_True : sal_False;
                 [ +  - ]
      59                 :            : }
      60                 :            : 
      61                 :            : // ::cppu::IPropertyArrayHelper
      62                 :     182332 : sal_Bool UnoPropertyArrayHelper::fillPropertyMembersByHandle( ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nPropId )
      63                 :            : {
      64                 :     182332 :     sal_uInt16 id = sal::static_int_cast< sal_uInt16 >(nPropId);
      65                 :     182332 :     sal_Bool bValid = ImplHasProperty( id );
      66         [ +  - ]:     182332 :     if ( bValid )
      67                 :            :     {
      68         [ +  + ]:     182332 :         if ( pPropName )
      69                 :      30468 :             *pPropName = GetPropertyName( id );
      70         [ +  + ]:     182332 :         if ( pAttributes )
      71                 :      93292 :             *pAttributes = GetPropertyAttribs( id );
      72                 :            :     }
      73                 :     182332 :     return bValid;
      74                 :            : }
      75                 :            : 
      76                 :        190 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > UnoPropertyArrayHelper::getProperties()
      77                 :            : {
      78                 :            :     // Sortiert nach Namen...
      79                 :            : 
      80         [ +  - ]:        190 :     std::map<sal_Int32, sal_uInt16> aSortedPropsIds;
      81 [ +  - ][ +  - ]:       4065 :     for( std::set<sal_Int32>::const_iterator it =  maIDs.begin(); it != maIDs.end(); ++it)
                 [ +  + ]
      82                 :            :     {
      83         [ +  - ]:       3875 :         sal_uInt16 nId = sal::static_int_cast< sal_uInt16 >(*it);
      84 [ +  - ][ +  - ]:       3875 :         aSortedPropsIds[ 1+GetPropertyOrderNr( nId ) ] = nId;
      85                 :            : 
      86         [ +  + ]:       3875 :         if ( nId == BASEPROPERTY_FONTDESCRIPTOR )
      87                 :            :         {
      88                 :            :             // Einzelproperties...
      89         [ +  + ]:       1802 :             for ( sal_uInt16 i = BASEPROPERTY_FONTDESCRIPTORPART_START; i <= BASEPROPERTY_FONTDESCRIPTORPART_END; i++ )
      90 [ +  - ][ +  - ]:       1696 :                 aSortedPropsIds[ 1+GetPropertyOrderNr( i ) ]  = i;
      91                 :            :         }
      92                 :            :     }
      93                 :            : 
      94                 :        190 :     sal_uInt32 nProps = aSortedPropsIds.size();   // koennen jetzt mehr sein
      95         [ +  - ]:        190 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property> aProps( nProps );
      96         [ +  - ]:        190 :     ::com::sun::star::beans::Property* pProps = aProps.getArray();
      97                 :            : 
      98         [ +  - ]:        190 :     std::map<sal_Int32, sal_uInt16>::const_iterator it = aSortedPropsIds.begin();
      99 [ +  - ][ +  + ]:       5761 :     for ( sal_uInt32 n = 0; n < nProps; n++, ++it )
     100                 :            :     {
     101         [ +  - ]:       5571 :         sal_uInt16 nId = it->second;
     102         [ +  - ]:       5571 :         pProps[n].Name = GetPropertyName( nId );
     103                 :       5571 :         pProps[n].Handle = nId;
     104         [ +  - ]:       5571 :         pProps[n].Type = *GetPropertyType( nId );
     105         [ +  - ]:       5571 :         pProps[n].Attributes = GetPropertyAttribs( nId );
     106                 :            :     }
     107                 :            : 
     108                 :        190 :     return aProps;
     109                 :            : }
     110                 :            : 
     111                 :          0 : ::com::sun::star::beans::Property UnoPropertyArrayHelper::getPropertyByName(const ::rtl::OUString& rPropertyName) throw (::com::sun::star::beans::UnknownPropertyException)
     112                 :            : {
     113                 :          0 :     ::com::sun::star::beans::Property aProp;
     114         [ #  # ]:          0 :     sal_uInt16 nId = GetPropertyId( rPropertyName );
     115 [ #  # ][ #  # ]:          0 :     if ( ImplHasProperty( nId ) )
     116                 :            :     {
     117                 :          0 :         aProp.Name = rPropertyName;
     118                 :          0 :         aProp.Handle = -1;
     119         [ #  # ]:          0 :         aProp.Type = *GetPropertyType( nId );
     120         [ #  # ]:          0 :         aProp.Attributes = GetPropertyAttribs( nId );
     121                 :            :     }
     122                 :            : 
     123                 :          0 :     return aProp;
     124                 :            : }
     125                 :            : 
     126                 :          0 : sal_Bool UnoPropertyArrayHelper::hasPropertyByName(const ::rtl::OUString& rPropertyName)
     127                 :            : {
     128                 :          0 :     return ImplHasProperty( GetPropertyId( rPropertyName ) );
     129                 :            : }
     130                 :            : 
     131                 :      13732 : sal_Int32 UnoPropertyArrayHelper::getHandleByName( const ::rtl::OUString & rPropertyName )
     132                 :            : {
     133                 :      13732 :     sal_Int32 nId = (sal_Int32 ) GetPropertyId( rPropertyName );
     134         [ +  - ]:      13732 :     return nId ? nId : (-1);
     135                 :            : }
     136                 :            : 
     137                 :       5590 : sal_Int32 UnoPropertyArrayHelper::fillHandles( sal_Int32* pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames )
     138                 :            : {
     139                 :       5590 :     const ::rtl::OUString* pNames = rPropNames.getConstArray();
     140                 :       5590 :     sal_Int32 nValues = rPropNames.getLength();
     141                 :       5590 :     sal_Int32 nValidHandles = 0;
     142                 :            : 
     143         [ +  + ]:     138071 :     for ( sal_Int32 n = 0; n < nValues; n++ )
     144                 :            :     {
     145                 :     132481 :         sal_uInt16 nPropId = GetPropertyId( pNames[n] );
     146 [ +  - ][ +  - ]:     132481 :         if ( nPropId && ImplHasProperty( nPropId ) )
                 [ +  - ]
     147                 :            :         {
     148                 :     132481 :             pHandles[n] = nPropId;
     149                 :     132481 :             nValidHandles++;
     150                 :            :         }
     151                 :            :         else
     152                 :            :         {
     153                 :          0 :             pHandles[n] = -1;
     154                 :            :         }
     155                 :            :     }
     156                 :       5590 :     return nValidHandles;
     157                 :            : }
     158                 :            : 
     159                 :            : 
     160                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10