Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / toolkit / source / controls / geometrycontrolmodel.cxx
blob5cd187c2fd427523d94fa8c2d10966f7165f3007
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 "PositionX"
44 #define GCM_PROPERTY_POS_Y "PositionY"
45 #define GCM_PROPERTY_WIDTH "Width"
46 #define GCM_PROPERTY_HEIGHT "Height"
47 #define GCM_PROPERTY_NAME "Name"
48 #define GCM_PROPERTY_TABINDEX "TabIndex"
49 #define GCM_PROPERTY_STEP "Step"
50 #define GCM_PROPERTY_TAG "Tag"
51 #define GCM_PROPERTY_RESOURCERESOLVER "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(css::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(nullptr != _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.set(_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( )
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 css::uno::Any OGeometryControlModel_Base::ImplGetDefaultValueByHandle(sal_Int32 nHandle)
187 css::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 css::uno::Any OGeometryControlModel_Base::ImplGetPropertyValueByHandle(sal_Int32 nHandle) const
209 css::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 css::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 )
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 )
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(nullptr);
295 setAggregation(nullptr);
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)
308 return OPropertyContainer::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
312 void SAL_CALL OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue)
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 css::beans::PropertyState OGeometryControlModel_Base::getPropertyStateByHandle(sal_Int32 nHandle)
333 css::uno::Any aValue = ImplGetPropertyValueByHandle( nHandle );
334 css::uno::Any aDefault = ImplGetDefaultValueByHandle( nHandle );
336 return CompareProperties( aValue, aDefault ) ? css::beans::PropertyState_DEFAULT_VALUE : css::beans::PropertyState_DIRECT_VALUE;
340 void OGeometryControlModel_Base::setPropertyToDefaultByHandle(sal_Int32 nHandle)
342 ImplSetPropertyValueByHandle( nHandle , ImplGetDefaultValueByHandle( nHandle ) );
346 css::uno::Any OGeometryControlModel_Base::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
348 return ImplGetDefaultValueByHandle( nHandle );
352 Reference< XPropertySetInfo> SAL_CALL OGeometryControlModel_Base::getPropertySetInfo()
354 return OPropertySetAggregationHelper::createPropertySetInfo(getInfoHelper());
358 Reference< XCloneable > SAL_CALL OGeometryControlModel_Base::createClone( )
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< css::script::XScriptEventsSupplier > xEventsSupplier =
394 static_cast< css::script::XScriptEventsSupplier* >( this );
395 Reference< css::script::XScriptEventsSupplier > xCloneEventsSupplier =
396 static_cast< css::script::XScriptEventsSupplier* >( pOwnClone );
398 if( xEventsSupplier.is() && xCloneEventsSupplier.is() )
400 Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
401 Reference< XNameContainer > xCloneEventCont = xCloneEventsSupplier->getEvents();
403 css::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 css::uno::Any aElement = xEventCont->getByName( aName );
412 xCloneEventCont->insertByName( aName, aElement );
416 return pOwnClone;
420 Reference< XNameContainer > SAL_CALL OGeometryControlModel_Base::getEvents()
422 if( !mxEventContainer.is() )
423 mxEventContainer = static_cast<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
442 typedef std::unordered_map< OUString, sal_Int32, OUStringHash > HashMapString2Int;
443 typedef std::vector< css::uno::Sequence< css::beans::Property > > PropSeqArray;
444 typedef std::vector< ::std::vector< sal_Int32 > > IntArrayArray;
446 // for creating class-unique PropertySetInfo's, we need some info:
447 namespace { struct ServiceSpecifierMap : public rtl::Static< HashMapString2Int, ServiceSpecifierMap > {}; }
448 // this one maps from a String, which is the service specifier for our
449 // aggregate, to a unique id
451 namespace { struct AggregateProperties : public rtl::Static< PropSeqArray, AggregateProperties > {}; }
452 // this one contains the properties which belong to all the unique ids
453 // in ServiceSpecifierMap
455 namespace { struct AmbiguousPropertyIds : public rtl::Static< IntArrayArray, AmbiguousPropertyIds > {}; }
456 // the ids of the properties which we as well as our aggregate supply
457 // For such props, we let our base class handle them, and whenever such
458 // a prop is set, we forward this to our aggregate.
460 // With this, we can ensure that two instances of this class share the
461 // same PropertySetInfo if and only if both aggregates have the same
462 // service specifier.
465 OCommonGeometryControlModel::OCommonGeometryControlModel( Reference< XCloneable >& _rxAgg, const OUString& _rServiceSpecifier )
466 :OGeometryControlModel_Base( _rxAgg )
467 ,m_sServiceSpecifier( _rServiceSpecifier )
468 ,m_nPropertyMapId( 0 )
470 Reference< XPropertySetInfo > xPI;
471 if ( m_xAggregateSet.is() )
472 xPI = m_xAggregateSet->getPropertySetInfo();
473 if ( !xPI.is() )
475 releaseAggregation();
476 throw IllegalArgumentException();
479 HashMapString2Int &rMap = ServiceSpecifierMap::get();
480 HashMapString2Int::iterator aPropMapIdPos = rMap.find( m_sServiceSpecifier );
481 if ( rMap.end() == aPropMapIdPos )
483 PropSeqArray &rAggProperties = AggregateProperties::get();
484 m_nPropertyMapId = rAggProperties.size();
485 rAggProperties.push_back( xPI->getProperties() );
486 AmbiguousPropertyIds::get().push_back( IntArrayArray::value_type() );
488 rMap[ m_sServiceSpecifier ] = m_nPropertyMapId;
490 else
491 m_nPropertyMapId = aPropMapIdPos->second;
495 struct PropertyNameLess : public ::std::binary_function< Property, Property, bool >
497 bool operator()( const Property& _rLHS, const Property& _rRHS )
499 return _rLHS.Name < _rRHS.Name;
504 struct PropertyNameEqual : public ::std::unary_function< Property, bool >
506 const OUString& m_rCompare;
507 explicit PropertyNameEqual( const OUString& _rCompare ) : m_rCompare( _rCompare ) { }
509 bool operator()( const Property& _rLHS )
511 return _rLHS.Name == m_rCompare;
516 ::cppu::IPropertyArrayHelper* OCommonGeometryControlModel::createArrayHelper( sal_Int32 _nId ) const
518 OSL_ENSURE( _nId == m_nPropertyMapId, "OCommonGeometryControlModel::createArrayHelper: invalid argument!" );
519 OSL_ENSURE( _nId < (sal_Int32)AggregateProperties::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (1)!" );
520 OSL_ENSURE( _nId < (sal_Int32)AmbiguousPropertyIds::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (2)!" );
522 // our own properties
523 Sequence< Property > aProps;
524 OPropertyContainer::describeProperties( aProps );
526 // the aggregate properties
527 Sequence< Property > aAggregateProps;
528 aAggregateProps = AggregateProperties::get()[ _nId ];
530 // look for duplicates, and remember them
531 IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ _nId ];
532 // for this, sort the aggregate properties
533 ::std::sort(
534 aAggregateProps.getArray(),
535 aAggregateProps.getArray() + aAggregateProps.getLength(),
536 PropertyNameLess()
538 const Property* pAggProps = aAggregateProps.getConstArray();
539 const Property* pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
541 // now loop through our own props
542 const Property* pProp = aProps.getConstArray();
543 const Property* pPropEnd = aProps.getConstArray() + aProps.getLength();
544 while ( pProp < pPropEnd )
546 // look for the current property in the properties of our aggregate
547 const Property* pAggPropPos = ::std::find_if( pAggProps, pAggPropsEnd, PropertyNameEqual( pProp->Name ) );
548 if ( pAggPropPos != pAggPropsEnd )
549 { // found a duplicate
550 // -> remove from the aggregate property sequence
551 ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - pAggProps );
552 // which means we have to adjust the pointers
553 pAggProps = aAggregateProps.getConstArray();
554 pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
556 // and additionally, remember the id of this property
557 rDuplicateIds.push_back( pProp->Handle );
560 ++pProp;
563 // now, finally, sort the duplicates
564 ::std::sort( rDuplicateIds.begin(), rDuplicateIds.end(), ::std::less< sal_Int32 >() );
566 return new OPropertyArrayAggregationHelper(aProps, aAggregateProps);
570 ::cppu::IPropertyArrayHelper& SAL_CALL OCommonGeometryControlModel::getInfoHelper()
572 return *getArrayHelper( m_nPropertyMapId );
576 OGeometryControlModel_Base* OCommonGeometryControlModel::createClone_Impl( Reference< XCloneable >& _rxAggregateInstance )
578 return new OCommonGeometryControlModel( _rxAggregateInstance, m_sServiceSpecifier );
581 Sequence< sal_Int8 > SAL_CALL OCommonGeometryControlModel::getImplementationId( )
583 return css::uno::Sequence<sal_Int8>();
587 struct Int32Equal : public ::std::unary_function< sal_Int32, bool >
589 sal_Int32 m_nCompare;
590 explicit Int32Equal( sal_Int32 _nCompare ) : m_nCompare( _nCompare ) { }
592 bool operator()( sal_Int32 _nLHS )
594 return _nLHS == m_nCompare;
599 void SAL_CALL OCommonGeometryControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue )
601 OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
603 // look if this id is one we recognized as duplicate
604 IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ m_nPropertyMapId ];
606 IntArrayArray::value_type::const_iterator aPos = ::std::find_if(
607 rDuplicateIds.begin(),
608 rDuplicateIds.end(),
609 Int32Equal( _nHandle )
612 if ( rDuplicateIds.end() != aPos )
614 // yes, it is such a property
615 OUString sPropName;
616 sal_Int16 nAttributes(0);
617 static_cast< OPropertyArrayAggregationHelper* >( getArrayHelper( m_nPropertyMapId ) )->fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
619 if ( m_xAggregateSet.is() && !sPropName.isEmpty() )
620 m_xAggregateSet->setPropertyValue( sPropName, _rValue );
625 // } // namespace toolkit
628 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */