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 1862211 : bool operator() (const PropertyDescription& x, const PropertyDescription& y) const
55 : {
56 1862211 : return x.aProperty.Handle < y.aProperty.Handle;
57 : }
58 : };
59 : // comparing two property descriptions (by name)
60 18450 : struct PropertyDescriptionNameMatch : public ::std::unary_function< PropertyDescription, bool >
61 : {
62 : OUString m_rCompare;
63 6150 : PropertyDescriptionNameMatch( const OUString& _rCompare ) : m_rCompare( _rCompare ) { }
64 :
65 136128 : bool operator() (const PropertyDescription& x ) const
66 : {
67 136128 : return x.aProperty.Name.equals(m_rCompare);
68 : }
69 : };
70 : }
71 :
72 : //==========================================================================
73 : //= OPropertyContainerHelper
74 : //==========================================================================
75 : //--------------------------------------------------------------------------
76 53539 : OPropertyContainerHelper::OPropertyContainerHelper()
77 53539 : :m_bUnused(sal_False)
78 : {
79 53539 : }
80 :
81 : // -------------------------------------------------------------------------
82 53366 : OPropertyContainerHelper::~OPropertyContainerHelper()
83 : {
84 53366 : }
85 :
86 : //--------------------------------------------------------------------------
87 132489 : void OPropertyContainerHelper::registerProperty(const 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 132489 : PropertyDescription aNewProp;
98 132489 : aNewProp.aProperty = Property( _rName, _nHandle, _rMemberType, (sal_Int16)_nAttributes );
99 132489 : aNewProp.eLocated = PropertyDescription::ltDerivedClassRealType;
100 132489 : aNewProp.aLocation.pDerivedClassMember = _pPointerToMember;
101 :
102 132489 : implPushBackProperty(aNewProp);
103 132489 : }
104 :
105 : //--------------------------------------------------------------------------
106 22 : void OPropertyContainerHelper::revokeProperty( sal_Int32 _nHandle )
107 : {
108 22 : PropertiesIterator aPos = searchHandle( _nHandle );
109 22 : if ( aPos == m_aProperties.end() )
110 0 : throw UnknownPropertyException();
111 22 : m_aProperties.erase( aPos );
112 22 : }
113 :
114 : //--------------------------------------------------------------------------
115 11142 : void OPropertyContainerHelper::registerMayBeVoidProperty(const 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 11142 : _nAttributes |= PropertyAttribute::MAYBEVOID;
126 :
127 11142 : PropertyDescription aNewProp;
128 11142 : aNewProp.aProperty = Property( _rName, _nHandle, _rExpectedType, (sal_Int16)_nAttributes );
129 11142 : aNewProp.eLocated = PropertyDescription::ltDerivedClassAnyType;
130 11142 : aNewProp.aLocation.pDerivedClassMember = _pPointerToMember;
131 :
132 11142 : implPushBackProperty(aNewProp);
133 11142 : }
134 :
135 :
136 : //--------------------------------------------------------------------------
137 7614 : void OPropertyContainerHelper::registerPropertyNoMember(const 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 7614 : PropertyDescription aNewProp;
146 7614 : aNewProp.aProperty = Property( _rName, _nHandle, _rType, (sal_Int16)_nAttributes );
147 7614 : aNewProp.eLocated = PropertyDescription::ltHoldMyself;
148 7614 : aNewProp.aLocation.nOwnClassVectorIndex = m_aHoldProperties.size();
149 7614 : if (_pInitialValue)
150 7323 : m_aHoldProperties.push_back(Any(_pInitialValue, _rType));
151 : else
152 291 : m_aHoldProperties.push_back(Any());
153 :
154 7614 : implPushBackProperty(aNewProp);
155 7614 : }
156 :
157 : //--------------------------------------------------------------------------
158 261508 : sal_Bool OPropertyContainerHelper::isRegisteredProperty( sal_Int32 _nHandle ) const
159 : {
160 261508 : return const_cast< OPropertyContainerHelper* >( this )->searchHandle( _nHandle ) != m_aProperties.end();
161 : }
162 :
163 : //--------------------------------------------------------------------------
164 6126 : sal_Bool OPropertyContainerHelper::isRegisteredProperty( const 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 6126 : );
176 6126 : return pos != m_aProperties.end();
177 : }
178 :
179 : //--------------------------------------------------------------------------
180 : namespace
181 : {
182 : struct ComparePropertyHandles
183 : {
184 273173 : bool operator()( const PropertyDescription& _rLHS, const PropertyDescription& _nRHS ) const
185 : {
186 273173 : return _rLHS.aProperty.Handle < _nRHS.aProperty.Handle;
187 : }
188 : };
189 : }
190 :
191 : //--------------------------------------------------------------------------
192 151245 : 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 151245 : _rProp, ComparePropertyHandles() );
208 :
209 151245 : m_aProperties.insert( pos, _rProp );
210 151245 : }
211 :
212 : //--------------------------------------------------------------------------
213 : namespace
214 : {
215 3 : void lcl_throwIllegalPropertyValueTypeException( const PropertyDescription& _rProperty, const Any& _rValue )
216 : {
217 3 : OUStringBuffer aErrorMessage;
218 3 : aErrorMessage.appendAscii( "The given value cannot be converted to the required property type." );
219 3 : aErrorMessage.appendAscii( "\n(property name \"" );
220 3 : aErrorMessage.append( _rProperty.aProperty.Name );
221 3 : aErrorMessage.appendAscii( "\", found value type \"" );
222 3 : aErrorMessage.append( _rValue.getValueType().getTypeName() );
223 3 : aErrorMessage.appendAscii( "\", required property type \"" );
224 3 : aErrorMessage.append( _rProperty.aProperty.Type.getTypeName() );
225 3 : aErrorMessage.appendAscii( "\")" );
226 3 : throw IllegalArgumentException( aErrorMessage.makeStringAndClear(), NULL, 4 );
227 : }
228 : }
229 :
230 : //--------------------------------------------------------------------------
231 22186 : sal_Bool OPropertyContainerHelper::convertFastPropertyValue(
232 : Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) SAL_THROW( (IllegalArgumentException) )
233 : {
234 22186 : sal_Bool bModified = sal_False;
235 :
236 : // get the property somebody is asking for
237 22186 : PropertiesIterator aPos = searchHandle(_nHandle);
238 22186 : 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 22186 : 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 7090 : sal_Bool bMayBeVoid = ((aPos->aProperty.Attributes & PropertyAttribute::MAYBEVOID) != 0);
253 :
254 :
255 : // non modifiable version of the value-to-be-set
256 7090 : Any aNewRequestedValue( _rValue );
257 :
258 : // normalization
259 : // #i29490#
260 7090 : if ( !aNewRequestedValue.getValueType().equals( aPos->aProperty.Type ) )
261 : { // the actually given value is not of the same type as the one required
262 5490 : Any aProperlyTyped( NULL, aPos->aProperty.Type.getTypeLibType() );
263 :
264 5490 : if ( uno_type_assignData(
265 10980 : const_cast< void* >( aProperlyTyped.getValue() ), aProperlyTyped.getValueType().getTypeLibType(),
266 10980 : 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 16470 : )
271 : )
272 : {
273 : // we were able to query the given XInterface-derivee for the interface
274 : // which is required for this property
275 240 : aNewRequestedValue = aProperlyTyped;
276 5490 : }
277 : }
278 :
279 : // argument check
280 13727 : if ( ! ( (bMayBeVoid && !aNewRequestedValue.hasValue()) // void is allowed if the attribute says so
281 1841 : || (aNewRequestedValue.getValueType().equals(aPos->aProperty.Type)) // else the types have to be equal
282 8931 : )
283 : )
284 : {
285 1 : lcl_throwIllegalPropertyValueTypeException( *aPos, _rValue );
286 : }
287 :
288 7089 : 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 7089 : if (PropertyDescription::ltHoldMyself == aPos->eLocated)
293 : {
294 : OSL_ENSURE(aPos->aLocation.nOwnClassVectorIndex < (sal_Int32)m_aHoldProperties.size(),
295 : "OPropertyContainerHelper::convertFastPropertyValue: invalid position !");
296 485 : PropertyContainerIterator aIter = m_aHoldProperties.begin() + aPos->aLocation.nOwnClassVectorIndex;
297 485 : pPropContainer = &(*aIter);
298 : }
299 : else
300 6604 : pPropContainer = reinterpret_cast<Any*>(aPos->aLocation.pDerivedClassMember);
301 :
302 : // check if the new value differs from the current one
303 7089 : if (!pPropContainer->hasValue() || !aNewRequestedValue.hasValue())
304 6129 : bModified = pPropContainer->hasValue() != aNewRequestedValue.hasValue();
305 : else
306 : bModified = !uno_type_equalData(
307 1920 : const_cast< void* >( pPropContainer->getValue() ), aPos->aProperty.Type.getTypeLibType(),
308 1920 : const_cast< void* >( aNewRequestedValue.getValue() ), aPos->aProperty.Type.getTypeLibType(),
309 : reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
310 : reinterpret_cast< uno_ReleaseFunc >( cpp_release )
311 2880 : );
312 :
313 7089 : if (bModified)
314 : {
315 1061 : _rOldValue = *pPropContainer;
316 1061 : _rConvertedValue = aNewRequestedValue;
317 7090 : }
318 : }
319 7089 : 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 15096 : Any aProperlyTyped;
327 15096 : const Any* pNewValue = &_rValue;
328 :
329 15096 : if (!_rValue.getValueType().equals(aPos->aProperty.Type))
330 : {
331 4 : sal_Bool bConverted = sal_False;
332 :
333 : // a temporary any of the correct (required) type
334 4 : aProperlyTyped = Any( NULL, aPos->aProperty.Type.getTypeLibType() );
335 : // (need this as we do not want to overwrite the derived class member here)
336 :
337 4 : if ( uno_type_assignData(
338 8 : const_cast<void*>(aProperlyTyped.getValue()), aProperlyTyped.getValueType().getTypeLibType(),
339 8 : 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 12 : )
344 : )
345 : {
346 : // could query for the requested interface
347 2 : bConverted = sal_True;
348 2 : pNewValue = &aProperlyTyped;
349 : }
350 :
351 4 : if ( !bConverted )
352 2 : 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 30188 : aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type.getTypeLibType(),
360 30188 : const_cast<void*>(pNewValue->getValue()), aPos->aProperty.Type.getTypeLibType(),
361 : reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
362 : reinterpret_cast< uno_ReleaseFunc >( cpp_release )
363 45282 : );
364 :
365 15094 : if (bModified)
366 : {
367 4632 : _rOldValue.setValue(aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type);
368 4632 : _rConvertedValue = *pNewValue;
369 : }
370 15096 : break;
371 : }
372 :
373 22183 : return bModified;
374 : }
375 :
376 : //--------------------------------------------------------------------------
377 13815 : void OPropertyContainerHelper::setFastPropertyValue(sal_Int32 _nHandle, const Any& _rValue) SAL_THROW( (Exception) )
378 : {
379 : // get the property somebody is asking for
380 13815 : PropertiesIterator aPos = searchHandle(_nHandle);
381 13815 : 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 13815 : return;
387 : }
388 :
389 13815 : switch (aPos->eLocated)
390 : {
391 : case PropertyDescription::ltHoldMyself:
392 23 : m_aHoldProperties[aPos->aLocation.nOwnClassVectorIndex] = _rValue;
393 23 : break;
394 :
395 : case PropertyDescription::ltDerivedClassAnyType:
396 1290 : *reinterpret_cast< Any* >(aPos->aLocation.pDerivedClassMember) = _rValue;
397 1290 : 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 25004 : aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type.getTypeLibType(),
406 25004 : const_cast< void* >( _rValue.getValue() ), _rValue.getValueType().getTypeLibType(),
407 : reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
408 : reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
409 37506 : reinterpret_cast< uno_ReleaseFunc >( cpp_release ) );
410 :
411 : OSL_ENSURE( bSuccess,
412 : "OPropertyContainerHelper::setFastPropertyValue: ooops .... the value could not be assigned!");
413 :
414 12502 : break;
415 : }
416 : }
417 :
418 : //--------------------------------------------------------------------------
419 172710 : void OPropertyContainerHelper::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
420 : {
421 : // get the property somebody is asking for
422 172710 : PropertiesIterator aPos = const_cast<OPropertyContainerHelper*>(this)->searchHandle(_nHandle);
423 172710 : 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 172710 : return;
429 : }
430 :
431 172710 : 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 24663 : _rValue = m_aHoldProperties[aPos->aLocation.nOwnClassVectorIndex];
437 24663 : break;
438 : case PropertyDescription::ltDerivedClassAnyType:
439 12952 : _rValue = *reinterpret_cast<Any*>(aPos->aLocation.pDerivedClassMember);
440 12952 : break;
441 : case PropertyDescription::ltDerivedClassRealType:
442 135095 : _rValue.setValue(aPos->aLocation.pDerivedClassMember, aPos->aProperty.Type);
443 135095 : break;
444 : }
445 : }
446 :
447 : //--------------------------------------------------------------------------
448 470241 : OPropertyContainerHelper::PropertiesIterator OPropertyContainerHelper::searchHandle(sal_Int32 _nHandle)
449 : {
450 470241 : PropertyDescription aHandlePropDesc;
451 470241 : 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 470241 : PropertyDescriptionHandleCompare());
458 :
459 : // check for identity
460 470241 : if ((aLowerBound != m_aProperties.end()) && aLowerBound->aProperty.Handle != _nHandle)
461 28611 : aLowerBound = m_aProperties.end();
462 :
463 470241 : return aLowerBound;
464 : }
465 :
466 : //--------------------------------------------------------------------------
467 24 : const Property& OPropertyContainerHelper::getProperty( const OUString& _rName ) const
468 : {
469 : ConstPropertiesIterator pos = ::std::find_if(
470 : m_aProperties.begin(),
471 : m_aProperties.end(),
472 : PropertyDescriptionNameMatch( _rName )
473 24 : );
474 24 : if ( pos == m_aProperties.end() )
475 1 : throw UnknownPropertyException( _rName, NULL );
476 :
477 23 : return pos->aProperty;
478 : }
479 :
480 : //--------------------------------------------------------------------------
481 2456 : void OPropertyContainerHelper::describeProperties(Sequence< Property >& _rProps) const
482 : {
483 2456 : Sequence< Property > aOwnProps(m_aProperties.size());
484 2456 : Property* pOwnProps = aOwnProps.getArray();
485 :
486 79266 : for ( ConstPropertiesIterator aLoop = m_aProperties.begin();
487 52844 : aLoop != m_aProperties.end();
488 : ++aLoop, ++pOwnProps
489 : )
490 : {
491 23966 : pOwnProps->Name = aLoop->aProperty.Name;
492 23966 : pOwnProps->Handle = aLoop->aProperty.Handle;
493 23966 : pOwnProps->Attributes = (sal_Int16)aLoop->aProperty.Attributes;
494 23966 : 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 2456 : ::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 4912 : Sequence< Property > aOutput;
503 2456 : aOutput.realloc(_rProps.getLength() + aOwnProps.getLength());
504 : // do the merge
505 2456 : ::std::merge( _rProps.getConstArray(), _rProps.getConstArray() + _rProps.getLength(), // input 1
506 2456 : aOwnProps.getConstArray(), aOwnProps.getConstArray() + aOwnProps.getLength(), // input 2
507 : aOutput.getArray(), // output
508 : PropertyCompareByName() // compare operator
509 7368 : );
510 :
511 : // copy the output
512 4912 : _rProps = aOutput;
513 2456 : }
514 :
515 : //.........................................................................
516 : } // namespace comphelper
517 : //.........................................................................
518 :
519 :
520 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|