LCOV - code coverage report
Current view: top level - toolkit/source/helper - unopropertyarrayhelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 68 0.0 %
Date: 2014-04-14 Functions: 0 9 0.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             : 
      21             : #include <toolkit/helper/unopropertyarrayhelper.hxx>
      22             : #include <toolkit/helper/property.hxx>
      23             : #include <map>
      24             : 
      25             : 
      26             : //  class UnoPropertyArrayHelper
      27             : 
      28             : 
      29           0 : UnoPropertyArrayHelper::UnoPropertyArrayHelper( const ::com::sun::star::uno::Sequence<sal_Int32>& rIDs )
      30             : {
      31           0 :     sal_Int32 nIDs = rIDs.getLength();
      32           0 :     const sal_Int32* pIDs = rIDs.getConstArray();
      33           0 :     for ( sal_Int32 n = 0; n < nIDs; n++ )
      34           0 :         maIDs.insert( pIDs[n] );
      35           0 : }
      36             : 
      37           0 : UnoPropertyArrayHelper::UnoPropertyArrayHelper( const std::list< sal_uInt16 > &rIDs )
      38             : {
      39           0 :     std::list< sal_uInt16 >::const_iterator iter;
      40           0 :     for( iter = rIDs.begin(); iter != rIDs.end(); ++iter)
      41           0 :       maIDs.insert( *iter );
      42           0 : }
      43             : 
      44           0 : bool UnoPropertyArrayHelper::ImplHasProperty( sal_uInt16 nPropId ) const
      45             : {
      46           0 :     if ( ( nPropId >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( nPropId <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
      47           0 :         nPropId = BASEPROPERTY_FONTDESCRIPTOR;
      48             : 
      49           0 :     return maIDs.find( nPropId ) != maIDs.end() ? sal_True : sal_False;
      50             : }
      51             : 
      52             : // ::cppu::IPropertyArrayHelper
      53           0 : sal_Bool UnoPropertyArrayHelper::fillPropertyMembersByHandle( OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nPropId )
      54             : {
      55           0 :     sal_uInt16 id = sal::static_int_cast< sal_uInt16 >(nPropId);
      56           0 :     bool bValid = ImplHasProperty( id );
      57           0 :     if ( bValid )
      58             :     {
      59           0 :         if ( pPropName )
      60           0 :             *pPropName = GetPropertyName( id );
      61           0 :         if ( pAttributes )
      62           0 :             *pAttributes = GetPropertyAttribs( id );
      63             :     }
      64           0 :     return bValid;
      65             : }
      66             : 
      67           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > UnoPropertyArrayHelper::getProperties()
      68             : {
      69             :     // Sortiert nach Namen...
      70             : 
      71           0 :     std::map<sal_Int32, sal_uInt16> aSortedPropsIds;
      72           0 :     for( std::set<sal_Int32>::const_iterator it =  maIDs.begin(); it != maIDs.end(); ++it)
      73             :     {
      74           0 :         sal_uInt16 nId = sal::static_int_cast< sal_uInt16 >(*it);
      75           0 :         aSortedPropsIds[ 1+GetPropertyOrderNr( nId ) ] = nId;
      76             : 
      77           0 :         if ( nId == BASEPROPERTY_FONTDESCRIPTOR )
      78             :         {
      79             :             // Einzelproperties...
      80           0 :             for ( sal_uInt16 i = BASEPROPERTY_FONTDESCRIPTORPART_START; i <= BASEPROPERTY_FONTDESCRIPTORPART_END; i++ )
      81           0 :                 aSortedPropsIds[ 1+GetPropertyOrderNr( i ) ]  = i;
      82             :         }
      83             :     }
      84             : 
      85           0 :     sal_uInt32 nProps = aSortedPropsIds.size();   // koennen jetzt mehr sein
      86           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property> aProps( nProps );
      87           0 :     ::com::sun::star::beans::Property* pProps = aProps.getArray();
      88             : 
      89           0 :     std::map<sal_Int32, sal_uInt16>::const_iterator it = aSortedPropsIds.begin();
      90           0 :     for ( sal_uInt32 n = 0; n < nProps; n++, ++it )
      91             :     {
      92           0 :         sal_uInt16 nId = it->second;
      93           0 :         pProps[n].Name = GetPropertyName( nId );
      94           0 :         pProps[n].Handle = nId;
      95           0 :         pProps[n].Type = *GetPropertyType( nId );
      96           0 :         pProps[n].Attributes = GetPropertyAttribs( nId );
      97             :     }
      98             : 
      99           0 :     return aProps;
     100             : }
     101             : 
     102           0 : ::com::sun::star::beans::Property UnoPropertyArrayHelper::getPropertyByName(const OUString& rPropertyName) throw (::com::sun::star::beans::UnknownPropertyException)
     103             : {
     104           0 :     ::com::sun::star::beans::Property aProp;
     105           0 :     sal_uInt16 nId = GetPropertyId( rPropertyName );
     106           0 :     if ( ImplHasProperty( nId ) )
     107             :     {
     108           0 :         aProp.Name = rPropertyName;
     109           0 :         aProp.Handle = -1;
     110           0 :         aProp.Type = *GetPropertyType( nId );
     111           0 :         aProp.Attributes = GetPropertyAttribs( nId );
     112             :     }
     113             : 
     114           0 :     return aProp;
     115             : }
     116             : 
     117           0 : sal_Bool UnoPropertyArrayHelper::hasPropertyByName(const OUString& rPropertyName)
     118             : {
     119           0 :     return ImplHasProperty( GetPropertyId( rPropertyName ) );
     120             : }
     121             : 
     122           0 : sal_Int32 UnoPropertyArrayHelper::getHandleByName( const OUString & rPropertyName )
     123             : {
     124           0 :     sal_Int32 nId = (sal_Int32 ) GetPropertyId( rPropertyName );
     125           0 :     return nId ? nId : (-1);
     126             : }
     127             : 
     128           0 : sal_Int32 UnoPropertyArrayHelper::fillHandles( sal_Int32* pHandles, const ::com::sun::star::uno::Sequence< OUString > & rPropNames )
     129             : {
     130           0 :     const OUString* pNames = rPropNames.getConstArray();
     131           0 :     sal_Int32 nValues = rPropNames.getLength();
     132           0 :     sal_Int32 nValidHandles = 0;
     133             : 
     134           0 :     for ( sal_Int32 n = 0; n < nValues; n++ )
     135             :     {
     136           0 :         sal_uInt16 nPropId = GetPropertyId( pNames[n] );
     137           0 :         if ( nPropId && ImplHasProperty( nPropId ) )
     138             :         {
     139           0 :             pHandles[n] = nPropId;
     140           0 :             nValidHandles++;
     141             :         }
     142             :         else
     143             :         {
     144           0 :             pHandles[n] = -1;
     145             :         }
     146             :     }
     147           0 :     return nValidHandles;
     148             : }
     149             : 
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10