1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b0724fc6SAndrew Rist  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b0724fc6SAndrew Rist  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19*b0724fc6SAndrew Rist  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir #include "toolkit/controls/geometrycontrolmodel.hxx"
27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
29cdf0e10cSrcweir #include <osl/diagnose.h>
30cdf0e10cSrcweir #include <rtl/instance.hxx>
31cdf0e10cSrcweir #include <comphelper/property.hxx>
32cdf0e10cSrcweir #include <comphelper/sequence.hxx>
33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_XNAMECONTAINER_HPP_
34cdf0e10cSrcweir #include <toolkit/controls/eventcontainer.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <toolkit/helper/property.hxx>
37cdf0e10cSrcweir #include <tools/debug.hxx>
38cdf0e10cSrcweir #include <algorithm>
39cdf0e10cSrcweir #include <functional>
40cdf0e10cSrcweir #include <comphelper/sequence.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define GCM_PROPERTY_ID_POS_X		        1
44cdf0e10cSrcweir #define GCM_PROPERTY_ID_POS_Y		        2
45cdf0e10cSrcweir #define GCM_PROPERTY_ID_WIDTH		        3
46cdf0e10cSrcweir #define GCM_PROPERTY_ID_HEIGHT		        4
47cdf0e10cSrcweir #define GCM_PROPERTY_ID_NAME		        5
48cdf0e10cSrcweir #define GCM_PROPERTY_ID_TABINDEX	        6
49cdf0e10cSrcweir #define GCM_PROPERTY_ID_STEP		        7
50cdf0e10cSrcweir #define GCM_PROPERTY_ID_TAG			        8
51cdf0e10cSrcweir #define GCM_PROPERTY_ID_RESOURCERESOLVER    9
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #define GCM_PROPERTY_POS_X		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX"))
54cdf0e10cSrcweir #define GCM_PROPERTY_POS_Y		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY"))
55cdf0e10cSrcweir #define GCM_PROPERTY_WIDTH		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width"))
56cdf0e10cSrcweir #define GCM_PROPERTY_HEIGHT		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height"))
57cdf0e10cSrcweir #define GCM_PROPERTY_NAME		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))
58cdf0e10cSrcweir #define GCM_PROPERTY_TABINDEX	        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TabIndex"))
59cdf0e10cSrcweir #define GCM_PROPERTY_STEP		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Step"))
60cdf0e10cSrcweir #define GCM_PROPERTY_TAG		        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tag"))
61cdf0e10cSrcweir #define GCM_PROPERTY_RESOURCERESOLVER	::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceResolver"))
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #define DEFAULT_ATTRIBS()		PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT
64cdf0e10cSrcweir 
65cdf0e10cSrcweir //........................................................................
66cdf0e10cSrcweir // namespace toolkit
67cdf0e10cSrcweir // {
68cdf0e10cSrcweir //........................................................................
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	using namespace ::com::sun::star;
71cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
72cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
73cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
74cdf0e10cSrcweir 	using namespace ::com::sun::star::util;
75cdf0e10cSrcweir 	using namespace ::com::sun::star::container;
76cdf0e10cSrcweir 	using namespace ::comphelper;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	//====================================================================
79cdf0e10cSrcweir 	//= OGeometryControlModel_Base
80cdf0e10cSrcweir 	//====================================================================
81cdf0e10cSrcweir 	//--------------------------------------------------------------------
OGeometryControlModel_Base(::com::sun::star::uno::XAggregation * _pAggregateInstance)82cdf0e10cSrcweir 	OGeometryControlModel_Base::OGeometryControlModel_Base(::com::sun::star::uno::XAggregation* _pAggregateInstance)
83cdf0e10cSrcweir 		:OPropertySetAggregationHelper( m_aBHelper )
84cdf0e10cSrcweir 		,OPropertyContainer( m_aBHelper )
85cdf0e10cSrcweir 		,OGCM_Base( m_aMutex )
86cdf0e10cSrcweir 		,m_nPosX(0)
87cdf0e10cSrcweir 		,m_nPosY(0)
88cdf0e10cSrcweir 		,m_nWidth(0)
89cdf0e10cSrcweir 		,m_nHeight(0)
90cdf0e10cSrcweir 		,m_nTabIndex(-1)
91cdf0e10cSrcweir 		,m_nStep(0)
92cdf0e10cSrcweir 		,m_bCloneable(sal_False)
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 		OSL_ENSURE(NULL != _pAggregateInstance, "OGeometryControlModel_Base::OGeometryControlModel_Base: invalid aggregate!");
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 		increment(m_refCount);
97cdf0e10cSrcweir 		{
98cdf0e10cSrcweir 			m_xAggregate = _pAggregateInstance;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 			{	// check if the aggregat is cloneable
101cdf0e10cSrcweir 				Reference< XCloneable > xCloneAccess(m_xAggregate, UNO_QUERY);
102cdf0e10cSrcweir 				m_bCloneable = xCloneAccess.is();
103cdf0e10cSrcweir 			}
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 			setAggregation(m_xAggregate);
106cdf0e10cSrcweir 			m_xAggregate->setDelegator(static_cast< XWeak* >(this));
107cdf0e10cSrcweir 		}
108cdf0e10cSrcweir 		decrement(m_refCount);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		registerProperties();
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	//--------------------------------------------------------------------
OGeometryControlModel_Base(Reference<XCloneable> & _rxAggregateInstance)114cdf0e10cSrcweir 	OGeometryControlModel_Base::OGeometryControlModel_Base(Reference< XCloneable >& _rxAggregateInstance)
115cdf0e10cSrcweir 		:OPropertySetAggregationHelper( m_aBHelper )
116cdf0e10cSrcweir 		,OPropertyContainer( m_aBHelper )
117cdf0e10cSrcweir 		,OGCM_Base( m_aMutex )
118cdf0e10cSrcweir 		,m_nPosX(0)
119cdf0e10cSrcweir 		,m_nPosY(0)
120cdf0e10cSrcweir 		,m_nWidth(0)
121cdf0e10cSrcweir 		,m_nHeight(0)
122cdf0e10cSrcweir 		,m_nTabIndex(-1)
123cdf0e10cSrcweir 		,m_nStep(0)
124cdf0e10cSrcweir 		,m_bCloneable(_rxAggregateInstance.is())
125cdf0e10cSrcweir 	{
126cdf0e10cSrcweir 		increment(m_refCount);
127cdf0e10cSrcweir 		{
128cdf0e10cSrcweir             {
129cdf0e10cSrcweir                 // ensure that the temporary gets destructed NOW
130cdf0e10cSrcweir                 m_xAggregate = Reference< XAggregation >(_rxAggregateInstance, UNO_QUERY);
131cdf0e10cSrcweir             }
132cdf0e10cSrcweir 			OSL_ENSURE(m_xAggregate.is(), "OGeometryControlModel_Base::OGeometryControlModel_Base: invalid object given!");
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 			// now the aggregate has a ref count of 2, but before setting the delegator it must be 1
135cdf0e10cSrcweir 			_rxAggregateInstance.clear();
136cdf0e10cSrcweir 			// now it should be the 1 we need here ...
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 			setAggregation(m_xAggregate);
139cdf0e10cSrcweir 			m_xAggregate->setDelegator(static_cast< XWeak* >(this));
140cdf0e10cSrcweir 		}
141cdf0e10cSrcweir 		decrement(m_refCount);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 		registerProperties();
144cdf0e10cSrcweir 	}
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	//--------------------------------------------------------------------
getTypes()147cdf0e10cSrcweir 	Sequence< Type > SAL_CALL OGeometryControlModel_Base::getTypes(  ) throw (RuntimeException)
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir 		// our own types
150cdf0e10cSrcweir 		Sequence< Type > aTypes = ::comphelper::concatSequences(
151cdf0e10cSrcweir 			OPropertySetAggregationHelper::getTypes(),
152cdf0e10cSrcweir 			OPropertyContainer::getTypes(),
153cdf0e10cSrcweir 			OGCM_Base::getTypes()
154cdf0e10cSrcweir 		);
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 		if ( m_xAggregate.is() )
157cdf0e10cSrcweir 		{
158cdf0e10cSrcweir 			// retrieve the types of the aggregate
159cdf0e10cSrcweir 			Reference< XTypeProvider > xAggregateTypeProv;
160cdf0e10cSrcweir 			m_xAggregate->queryAggregation( ::getCppuType( &xAggregateTypeProv ) ) >>= xAggregateTypeProv;
161cdf0e10cSrcweir 			OSL_ENSURE( xAggregateTypeProv.is(), "OGeometryControlModel_Base::getTypes: aggregate should be a type provider!" );
162cdf0e10cSrcweir 			Sequence< Type > aAggTypes;
163cdf0e10cSrcweir 			if ( xAggregateTypeProv.is() )
164cdf0e10cSrcweir 				aAggTypes = xAggregateTypeProv->getTypes();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 			// concat the sequences
167cdf0e10cSrcweir 			sal_Int32 nOldSize = aTypes.getLength();
168cdf0e10cSrcweir 			aTypes.realloc( nOldSize + aAggTypes.getLength() );
169cdf0e10cSrcweir 			::std::copy(
170cdf0e10cSrcweir 				aAggTypes.getConstArray(),
171cdf0e10cSrcweir 				aAggTypes.getConstArray() + aAggTypes.getLength(),
172cdf0e10cSrcweir 				aTypes.getArray() + nOldSize
173cdf0e10cSrcweir 			);
174cdf0e10cSrcweir 		}
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 		return aTypes;
177cdf0e10cSrcweir 	}
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	//--------------------------------------------------------------------
registerProperties()180cdf0e10cSrcweir 	void OGeometryControlModel_Base::registerProperties()
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir 		// register our members for the property handling of the OPropertyContainer
183cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_POS_X,	GCM_PROPERTY_ID_POS_X,		DEFAULT_ATTRIBS(), &m_nPosX, ::getCppuType(&m_nPosX));
184cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_POS_Y,	GCM_PROPERTY_ID_POS_Y,		DEFAULT_ATTRIBS(), &m_nPosY, ::getCppuType(&m_nPosY));
185cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_WIDTH,	GCM_PROPERTY_ID_WIDTH,		DEFAULT_ATTRIBS(), &m_nWidth, ::getCppuType(&m_nWidth));
186cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_HEIGHT,	GCM_PROPERTY_ID_HEIGHT,		DEFAULT_ATTRIBS(), &m_nHeight, ::getCppuType(&m_nHeight));
187cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_NAME,		GCM_PROPERTY_ID_NAME,		DEFAULT_ATTRIBS(), &m_aName, ::getCppuType(&m_aName));
188cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_TABINDEX,	GCM_PROPERTY_ID_TABINDEX,	DEFAULT_ATTRIBS(), &m_nTabIndex, ::getCppuType(&m_nTabIndex));
189cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_STEP,		GCM_PROPERTY_ID_STEP,		DEFAULT_ATTRIBS(), &m_nStep, ::getCppuType(&m_nStep));
190cdf0e10cSrcweir 		registerProperty(GCM_PROPERTY_TAG,		GCM_PROPERTY_ID_TAG,		DEFAULT_ATTRIBS(), &m_aTag, ::getCppuType(&m_aTag));
191cdf0e10cSrcweir         registerProperty(GCM_PROPERTY_RESOURCERESOLVER, GCM_PROPERTY_ID_RESOURCERESOLVER, DEFAULT_ATTRIBS(), &m_xStrResolver, ::getCppuType(&m_xStrResolver));
192cdf0e10cSrcweir 	}
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	//--------------------------------------------------------------------
ImplGetDefaultValueByHandle(sal_Int32 nHandle) const195cdf0e10cSrcweir 	::com::sun::star::uno::Any OGeometryControlModel_Base::ImplGetDefaultValueByHandle(sal_Int32 nHandle) const
196cdf0e10cSrcweir 	{
197cdf0e10cSrcweir 		::com::sun::star::uno::Any aDefault;
198cdf0e10cSrcweir 
199cdf0e10cSrcweir         switch ( nHandle )
200cdf0e10cSrcweir         {
201cdf0e10cSrcweir             case GCM_PROPERTY_ID_POS_X:			    aDefault <<= (sal_Int32) 0; break;
202cdf0e10cSrcweir             case GCM_PROPERTY_ID_POS_Y:			    aDefault <<= (sal_Int32) 0; break;
203cdf0e10cSrcweir             case GCM_PROPERTY_ID_WIDTH:			    aDefault <<= (sal_Int32) 0; break;
204cdf0e10cSrcweir             case GCM_PROPERTY_ID_HEIGHT:		    aDefault <<= (sal_Int32) 0; break;
205cdf0e10cSrcweir             case GCM_PROPERTY_ID_NAME:			    aDefault <<= ::rtl::OUString(); break;
206cdf0e10cSrcweir             case GCM_PROPERTY_ID_TABINDEX:		    aDefault <<= (sal_Int16) -1; break;
207cdf0e10cSrcweir             case GCM_PROPERTY_ID_STEP:			    aDefault <<= (sal_Int32) 0; break;
208cdf0e10cSrcweir             case GCM_PROPERTY_ID_TAG:			    aDefault <<= ::rtl::OUString(); break;
209cdf0e10cSrcweir             case GCM_PROPERTY_ID_RESOURCERESOLVER:  aDefault <<= Reference< resource::XStringResourceResolver >(); break;
210cdf0e10cSrcweir             default:							DBG_ERROR( "ImplGetDefaultValueByHandle - unknown Property" );
211cdf0e10cSrcweir         }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		return aDefault;
214cdf0e10cSrcweir 	}
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	//--------------------------------------------------------------------
ImplGetPropertyValueByHandle(sal_Int32 nHandle) const217cdf0e10cSrcweir 	::com::sun::star::uno::Any OGeometryControlModel_Base::ImplGetPropertyValueByHandle(sal_Int32 nHandle) const
218cdf0e10cSrcweir 	{
219cdf0e10cSrcweir 		::com::sun::star::uno::Any aValue;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir         switch ( nHandle )
222cdf0e10cSrcweir         {
223cdf0e10cSrcweir             case GCM_PROPERTY_ID_POS_X:			aValue <<= m_nPosX; break;
224cdf0e10cSrcweir             case GCM_PROPERTY_ID_POS_Y:			aValue <<= m_nPosY; break;
225cdf0e10cSrcweir             case GCM_PROPERTY_ID_WIDTH:			aValue <<= m_nWidth; break;
226cdf0e10cSrcweir             case GCM_PROPERTY_ID_HEIGHT:		aValue <<= m_nHeight; break;
227cdf0e10cSrcweir             case GCM_PROPERTY_ID_NAME:			aValue <<= m_aName; break;
228cdf0e10cSrcweir             case GCM_PROPERTY_ID_TABINDEX:		aValue <<= m_nTabIndex; break;
229cdf0e10cSrcweir             case GCM_PROPERTY_ID_STEP:			aValue <<= m_nStep; break;
230cdf0e10cSrcweir             case GCM_PROPERTY_ID_TAG:			aValue <<= m_aTag; break;
231cdf0e10cSrcweir             case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue <<= m_xStrResolver; break;
232cdf0e10cSrcweir             default:							DBG_ERROR( "ImplGetPropertyValueByHandle - unknown Property" );
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 		return aValue;
236cdf0e10cSrcweir 	}
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	//--------------------------------------------------------------------
ImplSetPropertyValueByHandle(sal_Int32 nHandle,const::com::sun::star::uno::Any & aValue)239cdf0e10cSrcweir 	void OGeometryControlModel_Base::ImplSetPropertyValueByHandle(sal_Int32 nHandle, const :: com::sun::star::uno::Any& aValue)
240cdf0e10cSrcweir 	{
241cdf0e10cSrcweir         switch ( nHandle )
242cdf0e10cSrcweir         {
243cdf0e10cSrcweir             case GCM_PROPERTY_ID_POS_X:			aValue >>= m_nPosX; break;
244cdf0e10cSrcweir             case GCM_PROPERTY_ID_POS_Y:			aValue >>= m_nPosY; break;
245cdf0e10cSrcweir             case GCM_PROPERTY_ID_WIDTH:			aValue >>= m_nWidth; break;
246cdf0e10cSrcweir             case GCM_PROPERTY_ID_HEIGHT:		aValue >>= m_nHeight; break;
247cdf0e10cSrcweir             case GCM_PROPERTY_ID_NAME:			aValue >>= m_aName; break;
248cdf0e10cSrcweir             case GCM_PROPERTY_ID_TABINDEX:		aValue >>= m_nTabIndex; break;
249cdf0e10cSrcweir             case GCM_PROPERTY_ID_STEP:			aValue >>= m_nStep; break;
250cdf0e10cSrcweir             case GCM_PROPERTY_ID_TAG:			aValue >>= m_aTag; break;
251cdf0e10cSrcweir             case GCM_PROPERTY_ID_RESOURCERESOLVER: aValue >>= m_xStrResolver; break;
252cdf0e10cSrcweir             default:							DBG_ERROR( "ImplSetPropertyValueByHandle - unknown Property" );
253cdf0e10cSrcweir         }
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	//--------------------------------------------------------------------
queryAggregation(const Type & _rType)257cdf0e10cSrcweir 	Any SAL_CALL OGeometryControlModel_Base::queryAggregation( const Type& _rType ) throw(RuntimeException)
258cdf0e10cSrcweir 	{
259cdf0e10cSrcweir 		Any aReturn;
260cdf0e10cSrcweir 		if (_rType.equals(::getCppuType(static_cast< Reference< XCloneable>* >(NULL))) && !m_bCloneable)
261cdf0e10cSrcweir 			// somebody is asking for the XCloneable interface, but our aggregate does not support it
262cdf0e10cSrcweir 			// -> outta here
263cdf0e10cSrcweir 			// (need this extra check, cause OGCM_Base::queryAggregation would return this interface
264cdf0e10cSrcweir 			// in every case)
265cdf0e10cSrcweir 			return aReturn;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 		aReturn = OGCM_Base::queryAggregation(_rType);
268cdf0e10cSrcweir 			// the basic interfaces (XInterface, XAggregation etc)
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 		if (!aReturn.hasValue())
271cdf0e10cSrcweir 			aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
272cdf0e10cSrcweir 			// the property set related interfaces
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 		if (!aReturn.hasValue() && m_xAggregate.is())
275cdf0e10cSrcweir 			aReturn = m_xAggregate->queryAggregation(_rType);
276cdf0e10cSrcweir 			// the interfaces our aggregate can provide
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 		return aReturn;
279cdf0e10cSrcweir 	}
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	//--------------------------------------------------------------------
queryInterface(const Type & _rType)282cdf0e10cSrcweir 	Any SAL_CALL OGeometryControlModel_Base::queryInterface( const Type& _rType ) throw(RuntimeException)
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		return OGCM_Base::queryInterface(_rType);
285cdf0e10cSrcweir 	}
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 	//--------------------------------------------------------------------
acquire()288cdf0e10cSrcweir 	void SAL_CALL OGeometryControlModel_Base::acquire(  ) throw()
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		OGCM_Base::acquire();
291cdf0e10cSrcweir 	}
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 	//--------------------------------------------------------------------
release()294cdf0e10cSrcweir 	void SAL_CALL OGeometryControlModel_Base::release(  ) throw()
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir 		OGCM_Base::release();
297cdf0e10cSrcweir 	}
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	//--------------------------------------------------------------------
releaseAggregation()300cdf0e10cSrcweir 	void OGeometryControlModel_Base::releaseAggregation()
301cdf0e10cSrcweir 	{
302cdf0e10cSrcweir 		// release the aggregate (_before_ clearing m_xAggregate)
303cdf0e10cSrcweir 		if (m_xAggregate.is())
304cdf0e10cSrcweir 			m_xAggregate->setDelegator(NULL);
305cdf0e10cSrcweir 		setAggregation(NULL);
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	//--------------------------------------------------------------------
~OGeometryControlModel_Base()309cdf0e10cSrcweir 	OGeometryControlModel_Base::~OGeometryControlModel_Base()
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		releaseAggregation();
312cdf0e10cSrcweir 	}
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	//--------------------------------------------------------------------
convertFastPropertyValue(Any & _rConvertedValue,Any & _rOldValue,sal_Int32 _nHandle,const Any & _rValue)315cdf0e10cSrcweir 	sal_Bool SAL_CALL OGeometryControlModel_Base::convertFastPropertyValue(Any& _rConvertedValue, Any& _rOldValue,
316cdf0e10cSrcweir 			sal_Int32 _nHandle, const Any& _rValue) throw (IllegalArgumentException)
317cdf0e10cSrcweir 	{
318cdf0e10cSrcweir 		return OPropertyContainer::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	//--------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _rValue)322cdf0e10cSrcweir 	void SAL_CALL OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
323cdf0e10cSrcweir 	{
324cdf0e10cSrcweir 		OPropertyContainer::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
325cdf0e10cSrcweir 	}
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	//--------------------------------------------------------------------
getFastPropertyValue(Any & _rValue,sal_Int32 _nHandle) const328cdf0e10cSrcweir 	void SAL_CALL OGeometryControlModel_Base::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
329cdf0e10cSrcweir 	{
330cdf0e10cSrcweir 		OPropertyArrayAggregationHelper& rPH = static_cast<OPropertyArrayAggregationHelper&>(const_cast<OGeometryControlModel_Base*>(this)->getInfoHelper());
331cdf0e10cSrcweir 		::rtl::OUString sPropName;
332cdf0e10cSrcweir 		sal_Int32	nOriginalHandle = -1;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 		if (rPH.fillAggregatePropertyInfoByHandle(&sPropName, &nOriginalHandle, _nHandle))
335cdf0e10cSrcweir 			OPropertySetAggregationHelper::getFastPropertyValue(_rValue, _nHandle);
336cdf0e10cSrcweir 		else
337cdf0e10cSrcweir 			OPropertyContainer::getFastPropertyValue(_rValue, _nHandle);
338cdf0e10cSrcweir 	}
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	//--------------------------------------------------------------------
getPropertyStateByHandle(sal_Int32 nHandle)341cdf0e10cSrcweir 	::com::sun::star::beans::PropertyState OGeometryControlModel_Base::getPropertyStateByHandle(sal_Int32 nHandle)
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		::com::sun::star::uno::Any aValue = ImplGetPropertyValueByHandle( nHandle );
344cdf0e10cSrcweir 		::com::sun::star::uno::Any aDefault = ImplGetDefaultValueByHandle( nHandle );
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 		return CompareProperties( aValue, aDefault ) ? ::com::sun::star::beans::PropertyState_DEFAULT_VALUE : ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	//--------------------------------------------------------------------
setPropertyToDefaultByHandle(sal_Int32 nHandle)350cdf0e10cSrcweir 	void OGeometryControlModel_Base::setPropertyToDefaultByHandle(sal_Int32 nHandle)
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir 		ImplSetPropertyValueByHandle( nHandle , ImplGetDefaultValueByHandle( nHandle ) );
353cdf0e10cSrcweir 	}
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 	//--------------------------------------------------------------------
getPropertyDefaultByHandle(sal_Int32 nHandle) const356cdf0e10cSrcweir 	::com::sun::star::uno::Any OGeometryControlModel_Base::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
357cdf0e10cSrcweir 	{
358cdf0e10cSrcweir 		return ImplGetDefaultValueByHandle( nHandle );
359cdf0e10cSrcweir 	}
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	//--------------------------------------------------------------------
getPropertySetInfo()362cdf0e10cSrcweir 	Reference< XPropertySetInfo> SAL_CALL OGeometryControlModel_Base::getPropertySetInfo() throw(RuntimeException)
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 		return OPropertySetAggregationHelper::createPropertySetInfo(getInfoHelper());
365cdf0e10cSrcweir 	}
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	//--------------------------------------------------------------------
createClone()368cdf0e10cSrcweir 	Reference< XCloneable > SAL_CALL OGeometryControlModel_Base::createClone(  ) throw(RuntimeException)
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		OSL_ENSURE(m_bCloneable, "OGeometryControlModel_Base::createClone: invalid call!");
371cdf0e10cSrcweir 		if (!m_bCloneable)
372cdf0e10cSrcweir 			return Reference< XCloneable >();
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 		// let the aggregate create it's own clone
375cdf0e10cSrcweir 		// the interface
376cdf0e10cSrcweir 		Reference< XCloneable > xCloneAccess;
377cdf0e10cSrcweir 		m_xAggregate->queryAggregation(::getCppuType(&xCloneAccess)) >>= xCloneAccess;
378cdf0e10cSrcweir 		OSL_ENSURE(xCloneAccess.is(), "OGeometryControlModel_Base::createClone: suspicious aggregate!");
379cdf0e10cSrcweir 		if (!xCloneAccess.is())
380cdf0e10cSrcweir 			return Reference< XCloneable >();
381cdf0e10cSrcweir 		// the aggregate's clone
382cdf0e10cSrcweir 		Reference< XCloneable > xAggregateClone = xCloneAccess->createClone();
383cdf0e10cSrcweir 		OSL_ENSURE(xAggregateClone.is(), "OGeometryControlModel_Base::createClone: suspicious return of the aggregate!");
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 		// create a new wrapper aggregating this return value
386cdf0e10cSrcweir 		OGeometryControlModel_Base* pOwnClone = createClone_Impl(xAggregateClone);
387cdf0e10cSrcweir 		OSL_ENSURE(pOwnClone, "OGeometryControlModel_Base::createClone: invalid derivee behaviour!");
388cdf0e10cSrcweir 		OSL_ENSURE(!xAggregateClone.is(), "OGeometryControlModel_Base::createClone: invalid ctor behaviour!");
389cdf0e10cSrcweir 			// should have been reset
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 		// set properties
392cdf0e10cSrcweir 		pOwnClone->m_nPosX		= m_nPosX;
393cdf0e10cSrcweir 		pOwnClone->m_nPosY		= m_nPosY;
394cdf0e10cSrcweir 		pOwnClone->m_nWidth		= m_nWidth;
395cdf0e10cSrcweir 		pOwnClone->m_nHeight	= m_nHeight;
396cdf0e10cSrcweir 		pOwnClone->m_aName		= m_aName;
397cdf0e10cSrcweir 		pOwnClone->m_nTabIndex	= m_nTabIndex;
398cdf0e10cSrcweir 		pOwnClone->m_nStep		= m_nStep;
399cdf0e10cSrcweir 		pOwnClone->m_aTag		= m_aTag;
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir         // Clone event container
403cdf0e10cSrcweir 		Reference< ::com::sun::star::script::XScriptEventsSupplier > xEventsSupplier =
404cdf0e10cSrcweir             static_cast< ::com::sun::star::script::XScriptEventsSupplier* >( this );
405cdf0e10cSrcweir 		Reference< ::com::sun::star::script::XScriptEventsSupplier > xCloneEventsSupplier =
406cdf0e10cSrcweir             static_cast< ::com::sun::star::script::XScriptEventsSupplier* >( pOwnClone );
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 		if( xEventsSupplier.is() && xCloneEventsSupplier.is() )
409cdf0e10cSrcweir 		{
410cdf0e10cSrcweir 			Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
411cdf0e10cSrcweir 			Reference< XNameContainer > xCloneEventCont = xCloneEventsSupplier->getEvents();
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::rtl::OUString > aNames =
414cdf0e10cSrcweir                 xEventCont->getElementNames();
415cdf0e10cSrcweir 			const ::rtl::OUString* pNames = aNames.getConstArray();
416cdf0e10cSrcweir 			sal_Int32 i, nNameCount = aNames.getLength();
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 			for( i = 0 ; i < nNameCount ; i++ )
419cdf0e10cSrcweir 			{
420cdf0e10cSrcweir                 ::rtl::OUString aName = pNames[ i ];
421cdf0e10cSrcweir 				::com::sun::star::uno::Any aElement = xEventCont->getByName( aName );
422cdf0e10cSrcweir                 xCloneEventCont->insertByName( aName, aElement );
423cdf0e10cSrcweir 			}
424cdf0e10cSrcweir 		}
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 		return pOwnClone;
427cdf0e10cSrcweir 	}
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	//--------------------------------------------------------------------
getEvents()430cdf0e10cSrcweir 	Reference< XNameContainer > SAL_CALL OGeometryControlModel_Base::getEvents() throw(RuntimeException)
431cdf0e10cSrcweir 	{
432cdf0e10cSrcweir 		if( !mxEventContainer.is() )
433cdf0e10cSrcweir 			mxEventContainer = (XNameContainer*)new toolkit::ScriptEventContainer();
434cdf0e10cSrcweir 		return mxEventContainer;
435cdf0e10cSrcweir 	}
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 	//--------------------------------------------------------------------
disposing()438cdf0e10cSrcweir     void SAL_CALL OGeometryControlModel_Base::disposing()
439cdf0e10cSrcweir 	{
440cdf0e10cSrcweir 		OGCM_Base::disposing();
441cdf0e10cSrcweir 		OPropertySetAggregationHelper::disposing();
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 		Reference<XComponent>  xComp;
444cdf0e10cSrcweir 		if ( query_aggregation( m_xAggregate, xComp ) )
445cdf0e10cSrcweir 			xComp->dispose();
446cdf0e10cSrcweir 	}
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	//====================================================================
449cdf0e10cSrcweir 	//= OCommonGeometryControlModel
450cdf0e10cSrcweir 	//====================================================================
451cdf0e10cSrcweir 	//--------------------------------------------------------------------
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 	typedef	::std::hash_map< ::rtl::OUString, sal_Int32, ::comphelper::UStringHash > HashMapString2Int;
454cdf0e10cSrcweir 	typedef ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > >	PropSeqArray;
455cdf0e10cSrcweir 	typedef ::std::vector< ::std::vector< sal_Int32 > > IntArrayArray;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	// for creating class-unique PropertySetInfo's, we need some info:
458cdf0e10cSrcweir 	namespace { struct ServiceSpecifierMap : public rtl::Static< HashMapString2Int, ServiceSpecifierMap > {}; }
459cdf0e10cSrcweir 	// this one maps from a String, which is the service specifier for our
460cdf0e10cSrcweir 	// aggregate, to a unique id
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 	namespace { struct AggregateProperties : public rtl::Static< PropSeqArray, AggregateProperties > {}; }
463cdf0e10cSrcweir 	// this one contains the properties which belong to all the unique ids
464cdf0e10cSrcweir 	// in ServiceSpecifierMap
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	namespace { struct AmbiguousPropertyIds : public rtl::Static< IntArrayArray, AmbiguousPropertyIds > {}; }
467cdf0e10cSrcweir 	// the ids of the properties which we as well as our aggregate supply
468cdf0e10cSrcweir 	// For such props, we let our base class handle them, and whenever such
469cdf0e10cSrcweir 	// a prop is set, we forward this to our aggregate.
470cdf0e10cSrcweir 
471cdf0e10cSrcweir 	// With this, we can ensure that two instances of this class share the
472cdf0e10cSrcweir 	// same PropertySetInfo if and only if both aggregates have the same
473cdf0e10cSrcweir 	// service specifier.
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	//--------------------------------------------------------------------
OCommonGeometryControlModel(Reference<XCloneable> & _rxAgg,const::rtl::OUString & _rServiceSpecifier)477cdf0e10cSrcweir 	OCommonGeometryControlModel::OCommonGeometryControlModel( Reference< XCloneable >& _rxAgg, const ::rtl::OUString& _rServiceSpecifier )
478cdf0e10cSrcweir 		:OGeometryControlModel_Base( _rxAgg )
479cdf0e10cSrcweir 		,m_sServiceSpecifier( _rServiceSpecifier )
480cdf0e10cSrcweir 		,m_nPropertyMapId( 0 )
481cdf0e10cSrcweir 	{
482cdf0e10cSrcweir 		Reference< XPropertySetInfo > xPI;
483cdf0e10cSrcweir 		if ( m_xAggregateSet.is() )
484cdf0e10cSrcweir 			xPI = m_xAggregateSet->getPropertySetInfo();
485cdf0e10cSrcweir 		if ( !xPI.is() )
486cdf0e10cSrcweir 		{
487cdf0e10cSrcweir 			releaseAggregation();
488cdf0e10cSrcweir 			throw IllegalArgumentException();
489cdf0e10cSrcweir 		}
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	        HashMapString2Int &rMap = ServiceSpecifierMap::get();
492cdf0e10cSrcweir 		HashMapString2Int::iterator aPropMapIdPos = rMap.find( m_sServiceSpecifier );
493cdf0e10cSrcweir 		if ( rMap.end() == aPropMapIdPos )
494cdf0e10cSrcweir 		{
495cdf0e10cSrcweir 			PropSeqArray &rAggProperties = AggregateProperties::get();
496cdf0e10cSrcweir 			m_nPropertyMapId = rAggProperties.size();
497cdf0e10cSrcweir 			rAggProperties.push_back( xPI->getProperties() );
498cdf0e10cSrcweir 			AmbiguousPropertyIds::get().push_back( IntArrayArray::value_type() );
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 			rMap[ m_sServiceSpecifier ] = m_nPropertyMapId;
501cdf0e10cSrcweir 		}
502cdf0e10cSrcweir 		else
503cdf0e10cSrcweir 			m_nPropertyMapId = aPropMapIdPos->second;
504cdf0e10cSrcweir 	}
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	//--------------------------------------------------------------------
507cdf0e10cSrcweir 	struct PropertyNameLess : public ::std::binary_function< Property, Property, bool >
508cdf0e10cSrcweir 	{
operator ()PropertyNameLess509cdf0e10cSrcweir 		bool operator()( const Property& _rLHS, const Property& _rRHS )
510cdf0e10cSrcweir 		{
511cdf0e10cSrcweir 			return _rLHS.Name < _rRHS.Name ? true : false;
512cdf0e10cSrcweir 		}
513cdf0e10cSrcweir 	};
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	//--------------------------------------------------------------------
516cdf0e10cSrcweir 	struct PropertyNameEqual : public ::std::unary_function< Property, bool >
517cdf0e10cSrcweir 	{
518cdf0e10cSrcweir 		const ::rtl::OUString&	m_rCompare;
PropertyNameEqualPropertyNameEqual519cdf0e10cSrcweir 		PropertyNameEqual( const ::rtl::OUString& _rCompare ) : m_rCompare( _rCompare ) { }
520cdf0e10cSrcweir 
operator ()PropertyNameEqual521cdf0e10cSrcweir 		bool operator()( const Property& _rLHS )
522cdf0e10cSrcweir 		{
523cdf0e10cSrcweir 			return _rLHS.Name == m_rCompare ? true : false;
524cdf0e10cSrcweir 		}
525cdf0e10cSrcweir 	};
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	//--------------------------------------------------------------------
createArrayHelper(sal_Int32 _nId) const528cdf0e10cSrcweir 	::cppu::IPropertyArrayHelper* OCommonGeometryControlModel::createArrayHelper( sal_Int32 _nId ) const
529cdf0e10cSrcweir 	{
530cdf0e10cSrcweir 		OSL_ENSURE( _nId == m_nPropertyMapId, "OCommonGeometryControlModel::createArrayHelper: invalid argument!" );
531cdf0e10cSrcweir 		OSL_ENSURE( _nId < (sal_Int32)AggregateProperties::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (1)!" );
532cdf0e10cSrcweir 		OSL_ENSURE( _nId < (sal_Int32)AmbiguousPropertyIds::get().size(), "OCommonGeometryControlModel::createArrayHelper: invalid status info (2)!" );
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 		// our own properties
535cdf0e10cSrcweir 		Sequence< Property > aProps;
536cdf0e10cSrcweir 		OPropertyContainer::describeProperties( aProps );
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 		// the aggregate properties
539cdf0e10cSrcweir 		Sequence< Property > aAggregateProps;
540cdf0e10cSrcweir 		aAggregateProps = AggregateProperties::get()[ _nId ];
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 		// look for duplicates, and remember them
543cdf0e10cSrcweir 		IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ _nId ];
544cdf0e10cSrcweir 		// for this, sort the aggregate properties
545cdf0e10cSrcweir 		::std::sort(
546cdf0e10cSrcweir 			aAggregateProps.getArray(),
547cdf0e10cSrcweir 			aAggregateProps.getArray() + aAggregateProps.getLength(),
548cdf0e10cSrcweir 			PropertyNameLess()
549cdf0e10cSrcweir 		);
550cdf0e10cSrcweir 		const Property* pAggProps = aAggregateProps.getConstArray();
551cdf0e10cSrcweir 		const Property* pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 		// now loop through our own props
554cdf0e10cSrcweir 		const Property* pProp = aProps.getConstArray();
555cdf0e10cSrcweir 		const Property* pPropEnd = aProps.getConstArray() + aProps.getLength();
556cdf0e10cSrcweir 		while ( pProp < pPropEnd )
557cdf0e10cSrcweir 		{
558cdf0e10cSrcweir 			// look for the current property in the properties of our aggregate
559cdf0e10cSrcweir 			const Property* pAggPropPos = ::std::find_if( pAggProps, pAggPropsEnd, PropertyNameEqual( pProp->Name ) );
560cdf0e10cSrcweir 			if ( pAggPropPos != pAggPropsEnd )
561cdf0e10cSrcweir 			{	// found a duplicate
562cdf0e10cSrcweir 				// -> remove from the aggregate property sequence
563cdf0e10cSrcweir 				::comphelper::removeElementAt( aAggregateProps, pAggPropPos - pAggProps );
564cdf0e10cSrcweir 				// which means we have to adjust the pointers
565cdf0e10cSrcweir 				pAggProps = aAggregateProps.getConstArray(),
566cdf0e10cSrcweir 				pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength(),
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 				// and additionally, remember the id of this property
569cdf0e10cSrcweir 				rDuplicateIds.push_back( pProp->Handle );
570cdf0e10cSrcweir 			}
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 			++pProp;
573cdf0e10cSrcweir 		}
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 		// now, finally, sort the duplicates
576cdf0e10cSrcweir 		::std::sort( rDuplicateIds.begin(), rDuplicateIds.end(), ::std::less< sal_Int32 >() );
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 		return new OPropertyArrayAggregationHelper(aProps, aAggregateProps);
579cdf0e10cSrcweir 	}
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	//--------------------------------------------------------------------
getInfoHelper()582cdf0e10cSrcweir 	::cppu::IPropertyArrayHelper& SAL_CALL OCommonGeometryControlModel::getInfoHelper()
583cdf0e10cSrcweir 	{
584cdf0e10cSrcweir 		return *getArrayHelper( m_nPropertyMapId );
585cdf0e10cSrcweir 	}
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	//--------------------------------------------------------------------
createClone_Impl(Reference<XCloneable> & _rxAggregateInstance)588cdf0e10cSrcweir 	OGeometryControlModel_Base* OCommonGeometryControlModel::createClone_Impl( Reference< XCloneable >& _rxAggregateInstance )
589cdf0e10cSrcweir 	{
590cdf0e10cSrcweir 		return new OCommonGeometryControlModel( _rxAggregateInstance, m_sServiceSpecifier );
591cdf0e10cSrcweir 	}
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	//--------------------------------------------------------------------
getImplementationId()594cdf0e10cSrcweir 	Sequence< sal_Int8 > SAL_CALL OCommonGeometryControlModel::getImplementationId(  ) throw (RuntimeException)
595cdf0e10cSrcweir 	{
596cdf0e10cSrcweir 		static ::cppu::OImplementationId * pId = NULL;
597cdf0e10cSrcweir 		if ( !pId )
598cdf0e10cSrcweir 		{
599cdf0e10cSrcweir 			::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
600cdf0e10cSrcweir 			if ( !pId )
601cdf0e10cSrcweir 			{
602cdf0e10cSrcweir 				static ::cppu::OImplementationId s_aId;
603cdf0e10cSrcweir 				pId = &s_aId;
604cdf0e10cSrcweir 			}
605cdf0e10cSrcweir 		}
606cdf0e10cSrcweir 		return pId->getImplementationId();
607cdf0e10cSrcweir 	}
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 	//--------------------------------------------------------------------
610cdf0e10cSrcweir 	struct Int32Equal : public ::std::unary_function< sal_Int32, bool >
611cdf0e10cSrcweir 	{
612cdf0e10cSrcweir 		sal_Int32	m_nCompare;
Int32EqualInt32Equal613cdf0e10cSrcweir 		Int32Equal( sal_Int32 _nCompare ) : m_nCompare( _nCompare ) { }
614cdf0e10cSrcweir 
operator ()Int32Equal615cdf0e10cSrcweir 		bool operator()( sal_Int32 _nLHS )
616cdf0e10cSrcweir 		{
617cdf0e10cSrcweir 			return _nLHS == m_nCompare ? true  : false;
618cdf0e10cSrcweir 		}
619cdf0e10cSrcweir 	};
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 	//--------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _rValue)622cdf0e10cSrcweir 	void SAL_CALL OCommonGeometryControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception )
623cdf0e10cSrcweir 	{
624cdf0e10cSrcweir 		OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 		// look if this id is one we recognized as duplicate
627cdf0e10cSrcweir 		IntArrayArray::value_type& rDuplicateIds = AmbiguousPropertyIds::get()[ m_nPropertyMapId ];
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 		IntArrayArray::value_type::const_iterator aPos = ::std::find_if(
630cdf0e10cSrcweir 			rDuplicateIds.begin(),
631cdf0e10cSrcweir 			rDuplicateIds.end(),
632cdf0e10cSrcweir 			Int32Equal( _nHandle )
633cdf0e10cSrcweir 		);
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 		if ( rDuplicateIds.end() != aPos )
636cdf0e10cSrcweir 		{
637cdf0e10cSrcweir 			// yes, it is such a property
638cdf0e10cSrcweir 			::rtl::OUString sPropName;
639cdf0e10cSrcweir 			sal_Int16 nAttributes(0);
640cdf0e10cSrcweir 			static_cast< OPropertyArrayAggregationHelper* >( getArrayHelper( m_nPropertyMapId ) )->fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 			if ( m_xAggregateSet.is() && sPropName.getLength() )
643cdf0e10cSrcweir 				m_xAggregateSet->setPropertyValue( sPropName, _rValue );
644cdf0e10cSrcweir 		}
645cdf0e10cSrcweir 	}
646cdf0e10cSrcweir 
647cdf0e10cSrcweir //........................................................................
648cdf0e10cSrcweir // }	// namespace toolkit
649cdf0e10cSrcweir //........................................................................
650