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