bump product version to 5.0.4.1
[LibreOffice.git] / toolkit / source / controls / geometrycontrolmodel.cxx
blobac09345fab3b8959612207bf3a37593bf3344591
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "toolkit/controls/geometrycontrolmodel.hxx"
21 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <osl/diagnose.h>
24 #include <rtl/instance.hxx>
25 #include <comphelper/property.hxx>
26 #include <comphelper/sequence.hxx>
27 #include <toolkit/controls/eventcontainer.hxx>
28 #include <toolkit/helper/property.hxx>
29 #include <algorithm>
30 #include <functional>
33 #define GCM_PROPERTY_ID_POS_X 1
34 #define GCM_PROPERTY_ID_POS_Y 2
35 #define GCM_PROPERTY_ID_WIDTH 3
36 #define GCM_PROPERTY_ID_HEIGHT 4
37 #define GCM_PROPERTY_ID_NAME 5
38 #define GCM_PROPERTY_ID_TABINDEX 6
39 #define GCM_PROPERTY_ID_STEP 7
40 #define GCM_PROPERTY_ID_TAG 8
41 #define GCM_PROPERTY_ID_RESOURCERESOLVER 9
43 #define GCM_PROPERTY_POS_X OUString("PositionX")
44 #define GCM_PROPERTY_POS_Y OUString("PositionY")
45 #define GCM_PROPERTY_WIDTH OUString("Width")
46 #define GCM_PROPERTY_HEIGHT OUString("Height")
47 #define GCM_PROPERTY_NAME OUString("Name")
48 #define GCM_PROPERTY_TABINDEX OUString("TabIndex")
49 #define GCM_PROPERTY_STEP OUString("Step")
50 #define GCM_PROPERTY_TAG OUString("Tag")
51 #define GCM_PROPERTY_RESOURCERESOLVER OUString("ResourceResolver")
53 #define DEFAULT_ATTRIBS() PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT
56 // namespace toolkit
57 // {
60 using namespace ::com::sun::star;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::lang;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::util;
65 using namespace ::com::sun::star::container;
66 using namespace ::comphelper;
69 //= OGeometryControlModel_Base
72 OGeometryControlModel_Base::OGeometryControlModel_Base(::com::sun::star::uno::XAggregation* _pAggregateInstance)
73 :OPropertySetAggregationHelper( m_aBHelper )
74 ,OPropertyContainer( m_aBHelper )
75 ,OGCM_Base( m_aMutex )
76 ,m_nPosX(0)
77 ,m_nPosY(0)
78 ,m_nWidth(0)
79 ,m_nHeight(0)
80 ,m_nTabIndex(-1)
81 ,m_nStep(0)
82 ,m_bCloneable(false)
84 OSL_ENSURE(NULL != _pAggregateInstance, "OGeometryControlModel_Base::OGeometryControlModel_Base: invalid aggregate!");
86 osl_atomic_increment(&m_refCount);
88 m_xAggregate = _pAggregateInstance;
90 { // check if the aggregate is cloneable
91 Reference< XCloneable > xCloneAccess(m_xAggregate, UNO_QUERY);
92 m_bCloneable = xCloneAccess.is();
95 setAggregation(m_xAggregate);
96 m_xAggregate->setDelegator(static_cast< XWeak* >(this));
98 osl_atomic_decrement(&m_refCount);
100 registerProperties();
104 OGeometryControlModel_Base::OGeometryControlModel_Base(Reference< XCloneable >& _rxAggregateInstance)
105 :OPropertySetAggregationHelper( m_aBHelper )
106 ,OPropertyContainer( m_aBHelper )
107 ,OGCM_Base( m_aMutex )
108 ,m_nPosX(0)
109 ,m_nPosY(0)
110 ,m_nWidth(0)
111 ,m_nHeight(0)
112 ,m_nTabIndex(-1)
113 ,m_nStep(0)
114 ,m_bCloneable(_rxAggregateInstance.is())
116 osl_atomic_increment(&m_refCount);
119 // ensure that the temporary gets destructed NOW
120 m_xAggregate = Reference< XAggregation >(_rxAggregateInstance, UNO_QUERY);
122 OSL_ENSURE(m_xAggregate.is(), "OGeometryControlModel_Base::OGeometryControlModel_Base: invalid object given!");
124 // now the aggregate has a ref count of 2, but before setting the delegator it must be 1
125 _rxAggregateInstance.clear();
126 // now it should be the 1 we need here ...
128 setAggregation(m_xAggregate);
129 m_xAggregate->setDelegator(static_cast< XWeak* >(this));
131 osl_atomic_decrement(&m_refCount);
133 registerProperties();
137 Sequence< Type > SAL_CALL OGeometryControlModel_Base::getTypes( ) throw (RuntimeException, std::exception)
139 // our own types
140 Sequence< Type > aTypes = ::comphelper::concatSequences(
141 OPropertySetAggregationHelper::getTypes(),
142 getBaseTypes(),
143 OGCM_Base::getTypes()
146 if ( m_xAggregate.is() )
148 // retrieve the types of the aggregate
149 Reference< XTypeProvider > xAggregateTypeProv;
150 m_xAggregate->queryAggregation( cppu::UnoType<decltype(xAggregateTypeProv)>::get() ) >>= xAggregateTypeProv;
151 OSL_ENSURE( xAggregateTypeProv.is(), "OGeometryControlModel_Base::getTypes: aggregate should be a type provider!" );
152 Sequence< Type > aAggTypes;
153 if ( xAggregateTypeProv.is() )
154 aAggTypes = xAggregateTypeProv->getTypes();
156 // concat the sequences
157 sal_Int32 nOldSize = aTypes.getLength();
158 aTypes.realloc( nOldSize + aAggTypes.getLength() );
159 ::std::copy(
160 aAggTypes.getConstArray(),
161 aAggTypes.getConstArray() + aAggTypes.getLength(),
162 aTypes.getArray() + nOldSize
166 return aTypes;
170 void OGeometryControlModel_Base::registerProperties()
172 // register our members for the property handling of the OPropertyContainer
173 registerProperty(GCM_PROPERTY_POS_X, GCM_PROPERTY_ID_POS_X, DEFAULT_ATTRIBS(), &m_nPosX, cppu::UnoType<decltype(m_nPosX)>::get());
174 registerProperty(GCM_PROPERTY_POS_Y, GCM_PROPERTY_ID_POS_Y, DEFAULT_ATTRIBS(), &m_nPosY, cppu::UnoType<decltype(m_nPosY)>::get());
175 registerProperty(GCM_PROPERTY_WIDTH, GCM_PROPERTY_ID_WIDTH, DEFAULT_ATTRIBS(), &m_nWidth, cppu::UnoType<decltype(m_nWidth)>::get());
176 registerProperty(GCM_PROPERTY_HEIGHT, GCM_PROPERTY_ID_HEIGHT, DEFAULT_ATTRIBS(), &m_nHeight, cppu::UnoType<decltype(m_nHeight)>::get());
177 registerProperty(GCM_PROPERTY_NAME, GCM_PROPERTY_ID_NAME, DEFAULT_ATTRIBS(), &m_aName, cppu::UnoType<decltype(m_aName)>::get());
178 registerProperty(GCM_PROPERTY_TABINDEX, GCM_PROPERTY_ID_TABINDEX, DEFAULT_ATTRIBS(), &m_nTabIndex, cppu::UnoType<decltype(m_nTabIndex)>::get());
179 registerProperty(GCM_PROPERTY_STEP, GCM_PROPERTY_ID_STEP, DEFAULT_ATTRIBS(), &m_nStep, cppu::UnoType<decltype(m_nStep)>::get());
180 registerProperty(GCM_PROPERTY_TAG, GCM_PROPERTY_ID_TAG, DEFAULT_ATTRIBS(), &m_aTag, cppu::UnoType<decltype(m_aTag)>::get());
181 registerProperty(GCM_PROPERTY_RESOURCERESOLVER, GCM_PROPERTY_ID_RESOURCERESOLVER, DEFAULT_ATTRIBS(), &m_xStrResolver, cppu::UnoType<decltype(m_xStrResolver)>::get());
185 ::com::sun::star::uno::Any OGeometryControlModel_Base::ImplGetDefaultValueByHandle(sal_Int32 nHandle)
187 ::com::sun::star::uno::Any aDefault;
189 switch ( nHandle )
191 case GCM_PROPERTY_ID_POS_X: aDefault <<= (sal_Int32) 0; break;
192 case GCM_PROPERTY_ID_POS_Y: aDefault <<= (sal_Int32) 0; break;
193 case GCM_PROPERTY_ID_WIDTH: aDefault <<= (sal_Int32) 0; break;
194 case GCM_PROPERTY_ID_HEIGHT: aDefault <<= (sal_Int32) 0; break;
195 case GCM_PROPERTY_ID_NAME: aDefault <<= OUString(); break;
196 case GCM_PROPERTY_ID_TABINDEX: aDefault <<= (sal_Int16) -1; break;
197 case GCM_PROPERTY_ID_STEP: aDefault <<= (sal_Int32) 0; break;
198 case GCM_PROPERTY_ID_TAG: aDefault <<= OUString(); break;
199 case GCM_PROPERTY_ID_RESOURCERESOLVER: aDefault <<= Reference< resource::XStringResourceResolver >(); break;
200 default: OSL_FAIL( "ImplGetDefaultValueByHandle - unknown Property" );
203 return aDefault;
207 ::com::sun::star::uno::Any OGeometryControlModel_Base::ImplGetPropertyValueByHandle(sal_Int32 nHandle) const
209 ::com::sun::star::uno::Any aValue;
211 switch ( nHandle )
213 case GCM_PROPERTY_ID_POS_X: aValue <<= m_nPosX; break;
214 case GCM_PROPERTY_ID_POS_Y: aValue <<= m_nPosY; break;
215 case GCM_PROPERTY_ID_WIDTH: aValue <<= m_nWidth; break;
216 case GCM_PROPERTY_ID_HEIGHT: aValue <<= m_nHeight; break;
217 case GCM_PROPERTY_ID_NAME: aValue <<= m_aName; break;
218 case GCM_PROPERTY_ID_TABINDEX: aValue <<= m_nTabIndex; break;
219 case GCM_PROPERTY_ID_STEP: aValue <<= m_nStep; break;
220 case GCM_PROPERTY_ID_TAG: aValue <<= m_aTag; break;
221 case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue <<= m_xStrResolver; break;
222 default: OSL_FAIL( "ImplGetPropertyValueByHandle - unknown Property" );
225 return aValue;
229 void OGeometryControlModel_Base::ImplSetPropertyValueByHandle(sal_Int32 nHandle, const :: com::sun::star::uno::Any& aValue)
231 switch ( nHandle )
233 case GCM_PROPERTY_ID_POS_X: aValue >>= m_nPosX; break;
234 case GCM_PROPERTY_ID_POS_Y: aValue >>= m_nPosY; break;
235 case GCM_PROPERTY_ID_WIDTH: aValue >>= m_nWidth; break;
236 case GCM_PROPERTY_ID_HEIGHT: aValue >>= m_nHeight; break;
237 case GCM_PROPERTY_ID_NAME: aValue >>= m_aName; break;
238 case GCM_PROPERTY_ID_TABINDEX: aValue >>= m_nTabIndex; break;
239 case GCM_PROPERTY_ID_STEP: aValue >>= m_nStep; break;
240 case GCM_PROPERTY_ID_TAG: aValue >>= m_aTag; break;
241 case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue >>= m_xStrResolver; break;
242 default: OSL_FAIL( "ImplSetPropertyValueByHandle - unknown Property" );
247 Any SAL_CALL OGeometryControlModel_Base::queryAggregation( const Type& _rType ) throw(RuntimeException, std::exception)
249 Any aReturn;
250 if (_rType.equals(cppu::UnoType<XCloneable>::get()) && !m_bCloneable)
251 // somebody is asking for the XCloneable interface, but our aggregate does not support it
252 // -> outta here
253 // (need this extra check, cause OGCM_Base::queryAggregation would return this interface
254 // in every case)
255 return aReturn;
257 aReturn = OGCM_Base::queryAggregation(_rType);
258 // the basic interfaces (XInterface, XAggregation etc)
260 if (!aReturn.hasValue())
261 aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
262 // the property set related interfaces
264 if (!aReturn.hasValue() && m_xAggregate.is())
265 aReturn = m_xAggregate->queryAggregation(_rType);
266 // the interfaces our aggregate can provide
268 return aReturn;
272 Any SAL_CALL OGeometryControlModel_Base::queryInterface( const Type& _rType ) throw(RuntimeException, std::exception)
274 return OGCM_Base::queryInterface(_rType);
278 void SAL_CALL OGeometryControlModel_Base::acquire( ) throw()
280 OGCM_Base::acquire();
284 void SAL_CALL OGeometryControlModel_Base::release( ) throw()
286 OGCM_Base::release();
290 void OGeometryControlModel_Base::releaseAggregation()
292 // release the aggregate (_before_ clearing m_xAggregate)
293 if (m_xAggregate.is())
294 m_xAggregate->setDelegator(NULL);
295 setAggregation(NULL);
299 OGeometryControlModel_Base::~OGeometryControlModel_Base()
301 releaseAggregation();
305 sal_Bool SAL_CALL OGeometryControlModel_Base::convertFastPropertyValue(Any& _rConvertedValue, Any& _rOldValue,
306 sal_Int32 _nHandle, const Any& _rValue) throw (IllegalArgumentException)
308 return OPropertyContainer::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
312 void SAL_CALL OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception, std::exception)
314 OPropertyContainer::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
318 void SAL_CALL OGeometryControlModel_Base::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
320 OPropertyArrayAggregationHelper& rPH = static_cast<OPropertyArrayAggregationHelper&>(const_cast<OGeometryControlModel_Base*>(this)->getInfoHelper());
321 OUString sPropName;
322 sal_Int32 nOriginalHandle = -1;
324 if (rPH.fillAggregatePropertyInfoByHandle(&sPropName, &nOriginalHandle, _nHandle))
325 OPropertySetAggregationHelper::getFastPropertyValue(_rValue, _nHandle);
326 else
327 OPropertyContainer::getFastPropertyValue(_rValue, _nHandle);
331 ::com::sun::star::beans::PropertyState OGeometryControlModel_Base::getPropertyStateByHandle(sal_Int32 nHandle)
333 ::com::sun::star::uno::Any aValue = ImplGetPropertyValueByHandle( nHandle );
334 ::com::sun::star::uno::Any aDefault = ImplGetDefaultValueByHandle( nHandle );
336 return CompareProperties( aValue, aDefault ) ? ::com::sun::star::beans::PropertyState_DEFAULT_VALUE : ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
340 void OGeometryControlModel_Base::setPropertyToDefaultByHandle(sal_Int32 nHandle)
342 ImplSetPropertyValueByHandle( nHandle , ImplGetDefaultValueByHandle( nHandle ) );
346 ::com::sun::star::uno::Any OGeometryControlModel_Base::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
348 return ImplGetDefaultValueByHandle( nHandle );
352 Reference< XPropertySetInfo> SAL_CALL OGeometryControlModel_Base::getPropertySetInfo() throw(RuntimeException, std::exception)
354 return OPropertySetAggregationHelper::createPropertySetInfo(getInfoHelper());
358 Reference< XCloneable > SAL_CALL OGeometryControlModel_Base::createClone( ) throw(RuntimeException, std::exception)
360 OSL_ENSURE(m_bCloneable, "OGeometryControlModel_Base::createClone: invalid call!");
361 if (!m_bCloneable)
362 return Reference< XCloneable >();
364 // let the aggregate create it's own clone
365 // the interface
366 Reference< XCloneable > xCloneAccess;
367 m_xAggregate->queryAggregation(cppu::UnoType<decltype(xCloneAccess)>::get()) >>= xCloneAccess;
368 OSL_ENSURE(xCloneAccess.is(), "OGeometryControlModel_Base::createClone: suspicious aggregate!");
369 if (!xCloneAccess.is())
370 return Reference< XCloneable >();
371 // the aggregate's clone
372 Reference< XCloneable > xAggregateClone = xCloneAccess->createClone();
373 OSL_ENSURE(xAggregateClone.is(), "OGeometryControlModel_Base::createClone: suspicious return of the aggregate!");
375 // create a new wrapper aggregating this return value
376 OGeometryControlModel_Base* pOwnClone = createClone_Impl(xAggregateClone);
377 OSL_ENSURE(pOwnClone, "OGeometryControlModel_Base::createClone: invalid derivee behaviour!");
378 OSL_ENSURE(!xAggregateClone.is(), "OGeometryControlModel_Base::createClone: invalid ctor behaviour!");
379 // should have been reset
381 // set properties
382 pOwnClone->m_nPosX = m_nPosX;
383 pOwnClone->m_nPosY = m_nPosY;
384 pOwnClone->m_nWidth = m_nWidth;
385 pOwnClone->m_nHeight = m_nHeight;
386 pOwnClone->m_aName = m_aName;
387 pOwnClone->m_nTabIndex = m_nTabIndex;
388 pOwnClone->m_nStep = m_nStep;
389 pOwnClone->m_aTag = m_aTag;
392 // Clone event container
393 Reference< ::com::sun::star::script::XScriptEventsSupplier > xEventsSupplier =
394 static_cast< ::com::sun::star::script::XScriptEventsSupplier* >( this );
395 Reference< ::com::sun::star::script::XScriptEventsSupplier > xCloneEventsSupplier =
396 static_cast< ::com::sun::star::script::XScriptEventsSupplier* >( pOwnClone );
398 if( xEventsSupplier.is() && xCloneEventsSupplier.is() )
400 Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
401 Reference< XNameContainer > xCloneEventCont = xCloneEventsSupplier->getEvents();
403 ::com::sun::star::uno::Sequence< OUString > aNames =
404 xEventCont->getElementNames();
405 const OUString* pNames = aNames.getConstArray();
406 sal_Int32 i, nNameCount = aNames.getLength();
408 for( i = 0 ; i < nNameCount ; i++ )
410 OUString aName = pNames[ i ];
411 ::com::sun::star::uno::Any aElement = xEventCont->getByName( aName );
412 xCloneEventCont->insertByName( aName, aElement );
416 return pOwnClone;
420 Reference< XNameContainer > SAL_CALL OGeometryControlModel_Base::getEvents() throw(RuntimeException, std::exception)
422 if( !mxEventContainer.is() )
423 mxEventContainer = (XNameContainer*)new toolkit::ScriptEventContainer();
424 return mxEventContainer;
428 void SAL_CALL OGeometryControlModel_Base::disposing()
430 OGCM_Base::disposing();
431 OPropertySetAggregationHelper::disposing();
433 Reference<XComponent> xComp;
434 if ( query_aggregation( m_xAggregate, xComp ) )
435 xComp->dispose();
439 //= OCommonGeometryControlModel
443 typedef std::unordered_map< OUString, sal_Int32, OUStringHash > HashMapString2Int;
444 typedef std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > > PropSeqArray;
445 typedef std::vector< ::std::vector< sal_Int32 > > IntArrayArray;
447 // for creating class-unique PropertySetInfo's, we need some info:
448 namespace { struct ServiceSpecifierMap : public rtl::Static< HashMapString2Int, ServiceSpecifierMap > {}; }
449 // this one maps from a String, which is the service specifier for our
450 // aggregate, to a unique id
452 namespace { struct AggregateProperties : public rtl::Static< PropSeqArray, AggregateProperties > {}; }
453 // this one contains the properties which belong to all the unique ids
454 // in ServiceSpecifierMap
456 namespace { struct AmbiguousPropertyIds : public rtl::Static< IntArrayArray, AmbiguousPropertyIds > {}; }
457 // the ids of the properties which we as well as our aggregate supply
458 // For such props, we let our base class handle them, and whenever such
459 // a prop is set, we forward this to our aggregate.
461 // With this, we can ensure that two instances of this class share the
462 // same PropertySetInfo if and only if both aggregates have the same
463 // service specifier.
467 OCommonGeometryControlModel::OCommonGeometryControlModel( Reference< XCloneable >& _rxAgg, const OUString& _rServiceSpecifier )
468 :OGeometryControlModel_Base( _rxAgg )
469 ,m_sServiceSpecifier( _rServiceSpecifier )
470 ,m_nPropertyMapId( 0 )
472 Reference< XPropertySetInfo > xPI;
473 if ( m_xAggregateSet.is() )
474 xPI = m_xAggregateSet->getPropertySetInfo();
475 if ( !xPI.is() )
477 releaseAggregation();
478 throw IllegalArgumentException();
481 HashMapString2Int &rMap = ServiceSpecifierMap::get();
482 HashMapString2Int::iterator aPropMapIdPos = rMap.find( m_sServiceSpecifier );
483 if ( rMap.end() == aPropMapIdPos )
485 PropSeqArray &rAggProperties = AggregateProperties::get();
486 m_nPropertyMapId = rAggProperties.size();
487 rAggProperties.push_back( xPI->getProperties() );
488 AmbiguousPropertyIds::get().push_back( IntArrayArray::value_type() );
490 rMap[ m_sServiceSpecifier ] = m_nPropertyMapId;
492 else
493 m_nPropertyMapId = aPropMapIdPos->second;
497 struct PropertyNameLess : public ::std::binary_function< Property, Property, bool >
499 bool operator()( const Property& _rLHS, const Property& _rRHS )
501 return _rLHS.Name < _rRHS.Name;
506 struct PropertyNameEqual : public ::std::unary_function< Property, bool >
508 const OUString& m_rCompare;
509 PropertyNameEqual( const OUString& _rCompare ) : m_rCompare( _rCompare ) { }
511 bool operator()( const Property& _rLHS )
513 return _rLHS.Name == m_rCompare;
518 ::cppu::IPropertyArrayHelper* OCommonGeometryControlModel::createArrayHelper( sal_Int32 _nId ) const
520 OSL_ENSURE( _nId == m_nPropertyMapId, "OCommonGeometryControlModel::createArrayHelper: invalid argument!" );
521 OSL_ENSURE( _nId < (sal_Int32)AggregateProperties::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (1)!" );
522 OSL_ENSURE( _nId < (sal_Int32)AmbiguousPropertyIds::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (2)!" );
524 // our own properties
525 Sequence< Property > aProps;
526 OPropertyContainer::describeProperties( aProps );
528 // the aggregate properties
529 Sequence< Property > aAggregateProps;
530 aAggregateProps = AggregateProperties::get()[ _nId ];
532 // look for duplicates, and remember them
533 IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ _nId ];
534 // for this, sort the aggregate properties
535 ::std::sort(
536 aAggregateProps.getArray(),
537 aAggregateProps.getArray() + aAggregateProps.getLength(),
538 PropertyNameLess()
540 const Property* pAggProps = aAggregateProps.getConstArray();
541 const Property* pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
543 // now loop through our own props
544 const Property* pProp = aProps.getConstArray();
545 const Property* pPropEnd = aProps.getConstArray() + aProps.getLength();
546 while ( pProp < pPropEnd )
548 // look for the current property in the properties of our aggregate
549 const Property* pAggPropPos = ::std::find_if( pAggProps, pAggPropsEnd, PropertyNameEqual( pProp->Name ) );
550 if ( pAggPropPos != pAggPropsEnd )
551 { // found a duplicate
552 // -> remove from the aggregate property sequence
553 ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - pAggProps );
554 // which means we have to adjust the pointers
555 pAggProps = aAggregateProps.getConstArray(),
556 pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength(),
558 // and additionally, remember the id of this property
559 rDuplicateIds.push_back( pProp->Handle );
562 ++pProp;
565 // now, finally, sort the duplicates
566 ::std::sort( rDuplicateIds.begin(), rDuplicateIds.end(), ::std::less< sal_Int32 >() );
568 return new OPropertyArrayAggregationHelper(aProps, aAggregateProps);
572 ::cppu::IPropertyArrayHelper& SAL_CALL OCommonGeometryControlModel::getInfoHelper()
574 return *getArrayHelper( m_nPropertyMapId );
578 OGeometryControlModel_Base* OCommonGeometryControlModel::createClone_Impl( Reference< XCloneable >& _rxAggregateInstance )
580 return new OCommonGeometryControlModel( _rxAggregateInstance, m_sServiceSpecifier );
583 Sequence< sal_Int8 > SAL_CALL OCommonGeometryControlModel::getImplementationId( ) throw (RuntimeException, std::exception)
585 return css::uno::Sequence<sal_Int8>();
589 struct Int32Equal : public ::std::unary_function< sal_Int32, bool >
591 sal_Int32 m_nCompare;
592 Int32Equal( sal_Int32 _nCompare ) : m_nCompare( _nCompare ) { }
594 bool operator()( sal_Int32 _nLHS )
596 return _nLHS == m_nCompare;
601 void SAL_CALL OCommonGeometryControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception, std::exception )
603 OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
605 // look if this id is one we recognized as duplicate
606 IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ m_nPropertyMapId ];
608 IntArrayArray::value_type::const_iterator aPos = ::std::find_if(
609 rDuplicateIds.begin(),
610 rDuplicateIds.end(),
611 Int32Equal( _nHandle )
614 if ( rDuplicateIds.end() != aPos )
616 // yes, it is such a property
617 OUString sPropName;
618 sal_Int16 nAttributes(0);
619 static_cast< OPropertyArrayAggregationHelper* >( getArrayHelper( m_nPropertyMapId ) )->fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
621 if ( m_xAggregateSet.is() && !sPropName.isEmpty() )
622 m_xAggregateSet->setPropertyValue( sPropName, _rValue );
627 // } // namespace toolkit
630 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */