LCOV - code coverage report
Current view: top level - libreoffice/comphelper/source/property - propertycontainerhelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 104 172 60.5 %
Date: 2012-12-27 Functions: 19 22 86.4 %
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/propertycontainerhelper.hxx>
      21             : #include <comphelper/property.hxx>
      22             : #include <osl/diagnose.h>
      23             : #include <uno/data.h>
      24             : #include <com/sun/star/uno/genfunc.h>
      25             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      26             : #include <com/sun/star/beans/UnknownPropertyException.hpp>
      27             : #include <rtl/ustrbuf.hxx>
      28             : 
      29             : #include <algorithm>
      30             : 
      31             : //.........................................................................
      32             : namespace comphelper
      33             : {
      34             : //.........................................................................
      35             : 
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::beans;
      39             : 
      40             : //--------------------------------------------------------------------------
      41             : namespace
      42             : {
      43             :     // comparing two property descriptions
      44             :     struct PropertyDescriptionCompareByHandle : public ::std::binary_function< PropertyDescription, PropertyDescription, bool >
      45             :     {
      46             :         bool operator() (const PropertyDescription& x, const PropertyDescription& y) const
      47             :         {
      48             :             return x.aProperty.Handle < y.aProperty.Handle;
      49             :         }
      50             :     };
      51             :     // comparing two property descriptions
      52             :     struct PropertyDescriptionHandleCompare : public ::std::binary_function< PropertyDescription, PropertyDescription, bool >
      53             :     {
      54        8154 :         bool operator() (const PropertyDescription& x, const PropertyDescription& y) const
      55             :         {
      56        8154 :             return x.aProperty.Handle < y.aProperty.Handle;
      57             :         }
      58             :     };
      59             :     // comparing two property descriptions (by name)
      60        1245 :     struct PropertyDescriptionNameMatch : public ::std::unary_function< PropertyDescription, bool >
      61             :     {
      62             :         ::rtl::OUString m_rCompare;
      63         415 :         PropertyDescriptionNameMatch( const ::rtl::OUString& _rCompare ) : m_rCompare( _rCompare ) { }
      64             : 
      65        1071 :         bool operator() (const PropertyDescription& x ) const
      66             :         {
      67        1071 :             return x.aProperty.Name.equals(m_rCompare);
      68             :         }
      69             :     };
      70             : }
      71             : 
      72             : //==========================================================================
      73             : //= OPropertyContainerHelper
      74             : //==========================================================================
      75             : //--------------------------------------------------------------------------
      76        3174 : OPropertyContainerHelper::OPropertyContainerHelper()
      77        3174 :     :m_bUnused(sal_False)
      78             : {
      79        3174 : }
      80             : 
      81             : // -------------------------------------------------------------------------
      82        1434 : OPropertyContainerHelper::~OPropertyContainerHelper()
      83             : {
      84        1434 : }
      85             : 
      86             : //--------------------------------------------------------------------------
      87        6885 : void OPropertyContainerHelper::registerProperty(const ::rtl::OUString& _rName, sal_Int32 _nHandle,
      88             :         sal_Int32 _nAttributes, void* _pPointerToMember, const Type& _rMemberType)
      89             : {
      90             :     OSL_ENSURE((_nAttributes & PropertyAttribute::MAYBEVOID) == 0,
      91             :         "OPropertyContainerHelper::registerProperty: don't use this for properties which may be void ! There is a method called \"registerMayBeVoidProperty\" for this !");
      92             :     OSL_ENSURE(!_rMemberType.equals(::getCppuType(static_cast< Any* >(NULL))),
      93             :         "OPropertyContainerHelper::registerProperty: don't give my the type of an uno::Any ! Really can't handle this !");
      94             :     OSL_ENSURE(_pPointerToMember,
      95             :         "OPropertyContainerHelper::registerProperty: you gave me nonsense : the pointer must be non-NULL");
      96             : 
      97        6885 :     PropertyDescription aNewProp;
      98        6885 :     aNewProp.aProperty = Property( _rName, _nHandle, _rMemberType, (sal_Int16)_nAttributes );
      99        6885 :     aNewProp.eLocated = PropertyDescription::ltDerivedClassRealType;
     100        6885 :     aNewProp.aLocation.pDerivedClassMember = _pPointerToMember;
     101             : 
     102        6885 :     implPushBackProperty(aNewProp);
     103        6885 : }
     104             : 
     105             : //--------------------------------------------------------------------------
     106           0 : void OPropertyContainerHelper::revokeProperty( sal_Int32 _nHandle )
     107             : {
     108           0 :     PropertiesIterator aPos = searchHandle( _nHandle );
     109           0 :     if ( aPos == m_aProperties.end() )
     110           0 :         throw UnknownPropertyException();
     111           0 :     m_aProperties.erase( aPos );
     112           0 : }
     113             : 
     114             : //--------------------------------------------------------------------------
     115           4 : void OPropertyContainerHelper::registerMayBeVoidProperty(const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
     116             :         Any* _pPointerToMember, const Type& _rExpectedType)
     117             : {
     118             :     OSL_ENSURE((_nAttributes & PropertyAttribute::MAYBEVOID) != 0,
     119             :         "OPropertyContainerHelper::registerMayBeVoidProperty: why calling this when the attributes say nothing about may-be-void ?");
     120             :     OSL_ENSURE(!_rExpectedType.equals(::getCppuType(static_cast< Any* >(NULL))),
     121             :         "OPropertyContainerHelper::registerMayBeVoidProperty: don't give my the type of an uno::Any ! Really can't handle this !");
     122             :     OSL_ENSURE(_pPointerToMember,
     123             :         "OPropertyContainerHelper::registerMayBeVoidProperty: you gave me nonsense : the pointer must be non-NULL");
     124             : 
     125           4 :     _nAttributes |= PropertyAttribute::MAYBEVOID;
     126             : 
     127           4 :     PropertyDescription aNewProp;
     128           4 :     aNewProp.aProperty = Property( _rName, _nHandle, _rExpectedType, (sal_Int16)_nAttributes );
     129           4 :     aNewProp.eLocated = PropertyDescription::ltDerivedClassAnyType;
     130           4 :     aNewProp.aLocation.pDerivedClassMember = _pPointerToMember;
     131             : 
     132           4 :     implPushBackProperty(aNewProp);
     133           4 : }
     134             : 
     135             : 
     136             : //--------------------------------------------------------------------------
     137         605 : void OPropertyContainerHelper::registerPropertyNoMember(const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
     138             :         const Type& _rType, const void* _pInitialValue)
     139             : {
     140             :     OSL_ENSURE(!_rType.equals(::getCppuType(static_cast< Any* >(NULL))),
     141             :         "OPropertyContainerHelper::registerPropertyNoMember : don't give my the type of an uno::Any ! Really can't handle this !");
     142             :     OSL_ENSURE(_pInitialValue || ((_nAttributes & PropertyAttribute::MAYBEVOID) != 0),
     143             :         "OPropertyContainerHelper::registerPropertyNoMember : you should not ommit the initial value if the property can't be void ! This will definitivly crash later !");
     144             : 
     145         605 :     PropertyDescription aNewProp;
     146         605 :     aNewProp.aProperty = Property( _rName, _nHandle, _rType, (sal_Int16)_nAttributes );
     147         605 :     aNewProp.eLocated = PropertyDescription::ltHoldMyself;
     148         605 :     aNewProp.aLocation.nOwnClassVectorIndex = m_aHoldProperties.size();
     149         605 :     if (_pInitialValue)
     150         605 :         m_aHoldProperties.push_back(Any(_pInitialValue, _rType));
     151             :     else
     152           0 :         m_aHoldProperties.push_back(Any());
     153             : 
     154         605 :     implPushBackProperty(aNewProp);
     155         605 : }
     156             : 
     157             : //--------------------------------------------------------------------------
     158        1958 : sal_Bool OPropertyContainerHelper::isRegisteredProperty( sal_Int32 _nHandle ) const
     159             : {
     160        1958 :     return const_cast< OPropertyContainerHelper* >( this )->searchHandle( _nHandle ) != m_aProperties.end();
     161             : }
     162             : 
     163             : //--------------------------------------------------------------------------
     164         415 : sal_Bool OPropertyContainerHelper::isRegisteredProperty( const ::rtl::OUString& _rName ) const
     165             : {
     166             :     // TODO: the current structure is from a time where properties were
     167             :     // static, not dynamic. Since we allow that properties are also dynamic,
     168             :     // i.e. registered and revoked even though the XPropertySet has already been
     169             :     // accessed, a vector is not really the best data structure anymore ...
     170             : 
     171             :     ConstPropertiesIterator pos = ::std::find_if(
     172             :         m_aProperties.begin(),
     173             :         m_aProperties.end(),
     174             :         PropertyDescriptionNameMatch( _rName )
     175         415 :     );
     176         415 :     return pos != m_aProperties.end();
     177             : }
     178             : 
     179             : //--------------------------------------------------------------------------
     180             : namespace
     181             : {
     182             :     struct ComparePropertyHandles
     183             :     {
     184        7355 :         bool operator()( const PropertyDescription& _rLHS, const PropertyDescription& _nRHS ) const
     185             :         {
     186        7355 :             return _rLHS.aProperty.Handle < _nRHS.aProperty.Handle;
     187             :         }
     188             :     };
     189             : }
     190             : 
     191             : //--------------------------------------------------------------------------
     192        7494 : void OPropertyContainerHelper::implPushBackProperty(const PropertyDescription& _rProp)
     193             : {
     194             : #ifdef DBG_UTIL
     195             :     for (   PropertiesIterator checkConflicts = m_aProperties.begin();
     196             :             checkConflicts != m_aProperties.end();
     197             :             ++checkConflicts
     198             :         )
     199             :     {
     200             :         OSL_ENSURE(checkConflicts->aProperty.Name != _rProp.aProperty.Name, "OPropertyContainerHelper::implPushBackProperty: name already exists!");
     201             :         OSL_ENSURE(checkConflicts->aProperty.Handle != _rProp.aProperty.Handle, "OPropertyContainerHelper::implPushBackProperty: handle already exists!");
     202             :     }
     203             : #endif
     204             : 
     205             :     PropertiesIterator pos = ::std::lower_bound(
     206             :         m_aProperties.begin(), m_aProperties.end(),
     207        7494 :         _rProp, ComparePropertyHandles() );
     208             : 
     209        7494 :     m_aProperties.insert( pos, _rProp );
     210        7494 : }
     211             : 
     212             : //--------------------------------------------------------------------------
     213             : namespace
     214             : {
     215           0 :     void lcl_throwIllegalPropertyValueTypeException( const PropertyDescription& _rProperty, const Any& _rValue )
     216             :     {
     217           0 :         ::rtl::OUStringBuffer aErrorMessage;
     218           0 :         aErrorMessage.appendAscii( "The given value cannot be converted to the required property type." );
     219           0 :         aErrorMessage.appendAscii( "\n(property name \"" );
     220           0 :         aErrorMessage.append( _rProperty.aProperty.Name );
     221           0 :         aErrorMessage.appendAscii( "\", found value type \"" );
     222           0 :         aErrorMessage.append( _rValue.getValueType().getTypeName() );
     223           0 :         aErrorMessage.appendAscii( "\", required property type \"" );
     224           0 :         aErrorMessage.append( _rProperty.aProperty.Type.getTypeName() );
     225           0 :         aErrorMessage.appendAscii( "\")" );
     226           0 :         throw IllegalArgumentException( aErrorMessage.makeStringAndClear(), NULL, 4 );
     227             :     }
     228             : }
     229             : 
     230             : //--------------------------------------------------------------------------
     231         230 : sal_Bool OPropertyContainerHelper::convertFastPropertyValue(
     232             :     Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) SAL_THROW( (IllegalArgumentException) )
     233             : {
     234         230 :     sal_Bool bModified = sal_False;
     235             : 
     236             :     // get the property somebody is asking for
     237         230 :     PropertiesIterator aPos = searchHandle(_nHandle);
     238         230 :     if (aPos == m_aProperties.end())
     239             :     {
     240             :         OSL_FAIL( "OPropertyContainerHelper::convertFastPropertyValue: unknown handle!" );
     241             :         // should not happen if the derived class has built a correct property set info helper to be used by
     242             :         // our base class OPropertySetHelper
     243           0 :         return bModified;
     244             :     }
     245             : 
     246         230 :     switch (aPos->eLocated)
     247             :     {
     248             :         // similar handling for the two cases where the value is stored in an any
     249             :         case PropertyDescription::ltHoldMyself:
     250             :         case PropertyDescription::ltDerivedClassAnyType:
     251             :         {
     252           0 :             sal_Bool bMayBeVoid = ((aPos->aProperty.Attributes & PropertyAttribute::MAYBEVOID) != 0);
     253             : 
     254             : 
     255             :             // non modifiable version of the value-to-be-set
     256           0 :             Any aNewRequestedValue( _rValue );
     257             : 
     258             :             // normalization
     259             :             // #i29490#
     260           0 :             if ( !aNewRequestedValue.getValueType().equals( aPos->aProperty.Type ) )
     261             :             {   // the actually given value is not of the same type as the one required
     262           0 :                 Any aProperlyTyped( NULL, aPos->aProperty.Type.getTypeLibType() );
     263             : 
     264           0 :                 if (    uno_type_assignData(
     265           0 :                             const_cast< void* >( aProperlyTyped.getValue() ), aProperlyTyped.getValueType().getTypeLibType(),
     266           0 :                             const_cast< void* >( aNewRequestedValue.getValue() ), aNewRequestedValue.getValueType().getTypeLibType(),
     267             :                             reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
     268             :                             reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
     269             :                             reinterpret_cast< uno_ReleaseFunc >( cpp_release )
     270           0 :                         )
     271             :                     )
     272             :                 {
     273             :                     // we were able to query the given XInterface-derivee for the interface
     274             :                     // which is required for this property
     275           0 :                     aNewRequestedValue = aProperlyTyped;
     276           0 :                 }
     277             :             }
     278             : 
     279             :             // argument check
     280           0 :             if  (   !   (   (bMayBeVoid && !aNewRequestedValue.hasValue())                      // void is allowed if the attribute says so
     281           0 :                         ||  (aNewRequestedValue.getValueType().equals(aPos->aProperty.Type))    // else the types have to be equal
     282           0 :                         )
     283             :                 )
     284             :             {
     285           0 :                 lcl_throwIllegalPropertyValueTypeException( *aPos, _rValue );
     286             :             }
     287             : 
     288           0 :             Any* pPropContainer = NULL;
     289             :                 // the pointer to the any which holds the property value, no matter if located in the derived clas
     290             :                 // or in out vector
     291             : 
     292           0 :             if (PropertyDescription::ltHoldMyself == aPos->eLocated)
     293             :             {
     294             :                 OSL_ENSURE(aPos->aLocation.nOwnClassVectorIndex < (sal_Int32)m_aHoldProperties.size(),
     295             :                     "OPropertyContainerHelper::convertFastPropertyValue: invalid position !");
     296           0 :                 PropertyContainerIterator aIter = m_aHoldProperties.begin() + aPos->aLocation.nOwnClassVectorIndex;
     297           0 :                 pPropContainer = &(*aIter);
     298             :             }
     299             :             else
     300           0 :                 pPropContainer = reinterpret_cast<Any*>(aPos->aLocation.pDerivedClassMember);
     301             : 
     302             :             // check if the new value differs from the current one
     303           0 :             if (!pPropContainer->hasValue() || !aNewRequestedValue.hasValue())
     304           0 :                 bModified = pPropContainer->hasValue() != aNewRequestedValue.hasValue();
     305             :             else
     306             :                 bModified = !uno_type_equalData(
     307           0 :                                 const_cast< void* >( pPropContainer->getValue() ), aPos->aProperty.Type.getTypeLibType(),
     308           0 :                                 const_cast< void* >( aNewRequestedValue.getValue() ), aPos->aProperty.Type.getTypeLibType(),
     309             :                                 reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
     310             :                                 reinterpret_cast< uno_ReleaseFunc >( cpp_release )
     311           0 :                             );
     312             : 
     313           0 :             if (bModified)
     314             :             {
     315           0 :                 _rOldValue = *pPropContainer;
     316           0 :                 _rConvertedValue = aNewRequestedValue;
     317           0 :             }
     318             :         }
     319             :         break;
     320             :         case PropertyDescription::ltDerivedClassRealType:
     321             :             // let the UNO runtime library do any possible conversion
     322             :             // this may include a change of the type - for instance, if a LONG is required,
     323             :             // but a short is given, then this is valid, as it can be converted without any potential
     324             :             // data loss
     325             : 
     326         230 :             Any aProperlyTyped;
     327         230 :             const Any* pNewValue = &_rValue;
     328             : 
     329         230 :             if (!_rValue.getValueType().equals(aPos->aProperty.Type))
     330             :             {
     331           0 :                 sal_Bool bConverted = sal_False;
     332             : 
     333             :                 // a temporary any of the correct (required) type
     334           0 :                 aProperlyTyped = Any( NULL, aPos->aProperty.Type.getTypeLibType() );
     335             :                     // (need this as we do not want to overwrite the derived class member here)
     336             : 
     337           0 :                 if (    uno_type_assignData(
     338           0 :                             const_cast<void*>(aProperlyTyped.getValue()), aProperlyTyped.getValueType().getTypeLibType(),
     339           0 :                             const_cast<void*>(_rValue.getValue()), _rValue.getValueType().getTypeLibType(),
     340             :                             reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
     341             :                             reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
     342             :                             reinterpret_cast< uno_ReleaseFunc >( cpp_release )
     343           0 :                         )
     344             :                     )
     345             :                 {
     346             :                     // could query for the requested interface
     347           0 :                     bConverted = sal_True;
     348           0 :                     pNewValue = &aProperlyTyped;
     349             :                 }
     350             : 
     351           0 :                 if ( !bConverted )
     352           0 :                     lcl_throwIllegalPropertyValueTypeException( *aPos, _rValue );
     353             :             }
     354             : 
     355             :             // from here on, we should have the proper type
     356             :             OSL_ENSURE( pNewValue->getValueType() == aPos->aProperty.Type,
     357             :                 "OPropertyContainerHelper::convertFastPropertyValue: conversion failed!" );
     358             :             bModified = !uno_type_equalData(
     359         460 :                             aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type.getTypeLibType(),
     360         460 :                             const_cast<void*>(pNewValue->getValue()), aPos->aProperty.Type.getTypeLibType(),
     361             :                             reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
     362             :                             reinterpret_cast< uno_ReleaseFunc >( cpp_release )
     363         690 :                         );
     364             : 
     365         230 :             if (bModified)
     366             :             {
     367         148 :                 _rOldValue.setValue(aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type);
     368         148 :                 _rConvertedValue = *pNewValue;
     369             :             }
     370         230 :             break;
     371             :     }
     372             : 
     373         230 :     return bModified;
     374             : }
     375             : 
     376             : //--------------------------------------------------------------------------
     377         804 : void OPropertyContainerHelper::setFastPropertyValue(sal_Int32 _nHandle, const Any& _rValue) SAL_THROW( (Exception) )
     378             : {
     379             :     // get the property somebody is asking for
     380         804 :     PropertiesIterator aPos = searchHandle(_nHandle);
     381         804 :     if (aPos == m_aProperties.end())
     382             :     {
     383             :         OSL_FAIL( "OPropertyContainerHelper::setFastPropertyValue: unknown handle!" );
     384             :         // should not happen if the derived class has built a correct property set info helper to be used by
     385             :         // our base class OPropertySetHelper
     386         804 :         return;
     387             :     }
     388             : 
     389         804 :     switch (aPos->eLocated)
     390             :     {
     391             :         case PropertyDescription::ltHoldMyself:
     392           0 :             m_aHoldProperties[aPos->aLocation.nOwnClassVectorIndex] = _rValue;
     393           0 :             break;
     394             : 
     395             :         case PropertyDescription::ltDerivedClassAnyType:
     396           0 :             *reinterpret_cast< Any* >(aPos->aLocation.pDerivedClassMember) = _rValue;
     397           0 :             break;
     398             : 
     399             :         case PropertyDescription::ltDerivedClassRealType:
     400             : #if OSL_DEBUG_LEVEL > 0
     401             :             sal_Bool bSuccess =
     402             : #endif
     403             :             // copy the data from the to-be-set value
     404             :             uno_type_assignData(
     405        1608 :                 aPos->aLocation.pDerivedClassMember,        aPos->aProperty.Type.getTypeLibType(),
     406        1608 :                 const_cast< void* >( _rValue.getValue() ),  _rValue.getValueType().getTypeLibType(),
     407             :                 reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
     408             :                 reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
     409        2412 :                 reinterpret_cast< uno_ReleaseFunc >( cpp_release ) );
     410             : 
     411             :             OSL_ENSURE( bSuccess,
     412             :                 "OPropertyContainerHelper::setFastPropertyValue: ooops .... the value could not be assigned!");
     413             : 
     414         804 :             break;
     415             :     }
     416             : }
     417             : 
     418             : //--------------------------------------------------------------------------
     419         790 : void OPropertyContainerHelper::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
     420             : {
     421             :     // get the property somebody is asking for
     422         790 :     PropertiesIterator aPos = const_cast<OPropertyContainerHelper*>(this)->searchHandle(_nHandle);
     423         790 :     if (aPos == m_aProperties.end())
     424             :     {
     425             :         OSL_FAIL( "OPropertyContainerHelper::getFastPropertyValue: unknown handle!" );
     426             :         // should not happen if the derived class has built a correct property set info helper to be used by
     427             :         // our base class OPropertySetHelper
     428         790 :         return;
     429             :     }
     430             : 
     431         790 :     switch (aPos->eLocated)
     432             :     {
     433             :         case PropertyDescription::ltHoldMyself:
     434             :             OSL_ENSURE(aPos->aLocation.nOwnClassVectorIndex < (sal_Int32)m_aHoldProperties.size(),
     435             :                 "OPropertyContainerHelper::convertFastPropertyValue: invalid position !");
     436          48 :             _rValue = m_aHoldProperties[aPos->aLocation.nOwnClassVectorIndex];
     437          48 :             break;
     438             :         case PropertyDescription::ltDerivedClassAnyType:
     439           0 :             _rValue = *reinterpret_cast<Any*>(aPos->aLocation.pDerivedClassMember);
     440           0 :             break;
     441             :         case PropertyDescription::ltDerivedClassRealType:
     442         742 :             _rValue.setValue(aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type);
     443         742 :             break;
     444             :     }
     445             : }
     446             : 
     447             : //--------------------------------------------------------------------------
     448        3782 : OPropertyContainerHelper::PropertiesIterator OPropertyContainerHelper::searchHandle(sal_Int32 _nHandle)
     449             : {
     450        3782 :     PropertyDescription aHandlePropDesc;
     451        3782 :     aHandlePropDesc.aProperty.Handle = _nHandle;
     452             :     // search a lower bound
     453             :     PropertiesIterator aLowerBound = ::std::lower_bound(
     454             :         m_aProperties.begin(),
     455             :         m_aProperties.end(),
     456             :         aHandlePropDesc,
     457        3782 :         PropertyDescriptionHandleCompare());
     458             : 
     459             :     // check for identity
     460        3782 :     if ((aLowerBound != m_aProperties.end()) && aLowerBound->aProperty.Handle != _nHandle)
     461          26 :         aLowerBound = m_aProperties.end();
     462             : 
     463        3782 :     return aLowerBound;
     464             : }
     465             : 
     466             : //--------------------------------------------------------------------------
     467           0 : const Property& OPropertyContainerHelper::getProperty( const ::rtl::OUString& _rName ) const
     468             : {
     469             :     ConstPropertiesIterator pos = ::std::find_if(
     470             :         m_aProperties.begin(),
     471             :         m_aProperties.end(),
     472             :         PropertyDescriptionNameMatch( _rName )
     473           0 :     );
     474           0 :     if ( pos == m_aProperties.end() )
     475           0 :         throw UnknownPropertyException( _rName, NULL );
     476             : 
     477           0 :     return pos->aProperty;
     478             : }
     479             : 
     480             : //--------------------------------------------------------------------------
     481          57 : void OPropertyContainerHelper::describeProperties(Sequence< Property >& _rProps) const
     482             : {
     483          57 :     Sequence< Property > aOwnProps(m_aProperties.size());
     484          57 :     Property* pOwnProps = aOwnProps.getArray();
     485             : 
     486         807 :     for (   ConstPropertiesIterator aLoop = m_aProperties.begin();
     487         538 :             aLoop != m_aProperties.end();
     488             :             ++aLoop, ++pOwnProps
     489             :         )
     490             :     {
     491         212 :         pOwnProps->Name = aLoop->aProperty.Name;
     492         212 :         pOwnProps->Handle = aLoop->aProperty.Handle;
     493         212 :         pOwnProps->Attributes = (sal_Int16)aLoop->aProperty.Attributes;
     494         212 :         pOwnProps->Type = aLoop->aProperty.Type;
     495             :     }
     496             : 
     497             :     // as our property vector is sorted by handles, not by name, we have to sort aOwnProps
     498          57 :     ::std::sort(aOwnProps.getArray(), aOwnProps.getArray() + aOwnProps.getLength(), PropertyCompareByName());
     499             : 
     500             :     // unfortunally the STL merge function does not allow the output range to overlap one of the input ranges,
     501             :     // so we need an extra sequence
     502          57 :     Sequence< Property > aOutput;
     503          57 :     aOutput.realloc(_rProps.getLength() + aOwnProps.getLength());
     504             :     // do the merge
     505          57 :     ::std::merge(   _rProps.getConstArray(), _rProps.getConstArray() + _rProps.getLength(),         // input 1
     506          57 :                     aOwnProps.getConstArray(), aOwnProps.getConstArray() + aOwnProps.getLength(),   // input 2
     507             :                     aOutput.getArray(),                                                             // output
     508             :                     PropertyCompareByName()                                                         // compare operator
     509         171 :                 );
     510             : 
     511             :     // copy the output
     512          57 :     _rProps = aOutput;
     513          57 : }
     514             : 
     515             : //.........................................................................
     516             : }   // namespace comphelper
     517             : //.........................................................................
     518             : 
     519             : 
     520             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10