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_comphelper.hxx"
30*cdf0e10cSrcweir #include <comphelper/composedprops.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
33*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir //.........................................................................
36*cdf0e10cSrcweir namespace comphelper
37*cdf0e10cSrcweir {
38*cdf0e10cSrcweir //.........................................................................
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
41*cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
42*cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 	//=====================================================================
45*cdf0e10cSrcweir 	//= OComposedPropertySetInfo
46*cdf0e10cSrcweir 	//=====================================================================
47*cdf0e10cSrcweir 	class OComposedPropertySetInfo : public ::cppu::WeakImplHelper1< XPropertySetInfo >
48*cdf0e10cSrcweir 	{
49*cdf0e10cSrcweir 	private:
50*cdf0e10cSrcweir 		Sequence< Property>		m_aProperties;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 	public:
53*cdf0e10cSrcweir 		OComposedPropertySetInfo(const Sequence< Property>& _rProperties);
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 		virtual Sequence< Property > SAL_CALL getProperties(  ) throw(RuntimeException);
56*cdf0e10cSrcweir 		virtual Property SAL_CALL getPropertyByName( const ::rtl::OUString& _rName ) throw(UnknownPropertyException, RuntimeException);
57*cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw(RuntimeException);
58*cdf0e10cSrcweir 	};
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	//=====================================================================
61*cdf0e10cSrcweir 	//= OComposedPropertySet
62*cdf0e10cSrcweir 	//=====================================================================
63*cdf0e10cSrcweir 	//---------------------------------------------------------------------
64*cdf0e10cSrcweir 	OComposedPropertySet::OComposedPropertySet(
65*cdf0e10cSrcweir 			const Sequence< Reference< XPropertySet> > & _rElements,
66*cdf0e10cSrcweir 			const IPropertySetComposerCallback* _pPropertyMetaData)
67*cdf0e10cSrcweir 		:m_pInfo(NULL)
68*cdf0e10cSrcweir 	{
69*cdf0e10cSrcweir 		// copy the sequence
70*cdf0e10cSrcweir 		sal_Int32 nSingleSets = _rElements.getLength();
71*cdf0e10cSrcweir 		if (nSingleSets)
72*cdf0e10cSrcweir 		{
73*cdf0e10cSrcweir 			m_aSingleSets.resize(nSingleSets);
74*cdf0e10cSrcweir 			const Reference< XPropertySet >* pSingleSets = _rElements.getConstArray();
75*cdf0e10cSrcweir 			::std::copy(pSingleSets, pSingleSets + nSingleSets, m_aSingleSets.begin());
76*cdf0e10cSrcweir 		}
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 		// impl ctor
79*cdf0e10cSrcweir 		compose(_pPropertyMetaData);
80*cdf0e10cSrcweir 	}
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	//---------------------------------------------------------------------
83*cdf0e10cSrcweir 	OComposedPropertySet::~OComposedPropertySet()
84*cdf0e10cSrcweir 	{
85*cdf0e10cSrcweir 		if (m_pInfo)
86*cdf0e10cSrcweir 			m_pInfo->release();
87*cdf0e10cSrcweir 	}
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	//---------------------------------------------------------------------
90*cdf0e10cSrcweir 	void OComposedPropertySet::compose(const IPropertySetComposerCallback* _pMetaData)
91*cdf0e10cSrcweir 	{
92*cdf0e10cSrcweir 		sal_Int32 nSingleSets = m_aSingleSets.size();
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 		if (nSingleSets>0)
95*cdf0e10cSrcweir 		{
96*cdf0e10cSrcweir 			// get the properties of the first set
97*cdf0e10cSrcweir 			Reference< XPropertySet > xMasterSet = m_aSingleSets[0];
98*cdf0e10cSrcweir 			Sequence< Property> aMasterProps;
99*cdf0e10cSrcweir 			if (xMasterSet.is())
100*cdf0e10cSrcweir 				aMasterProps = xMasterSet->getPropertySetInfo()->getProperties();
101*cdf0e10cSrcweir 			sal_Int32 nMasterPropsCount = aMasterProps.getLength();
102*cdf0e10cSrcweir 			const Property*	pMasterProps = aMasterProps.getConstArray();
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 			// check which of the master properties should be included
105*cdf0e10cSrcweir 			Sequence<sal_Bool> aInclusionFlags(nMasterPropsCount);
106*cdf0e10cSrcweir 			sal_Bool* pInclusionFlags = aInclusionFlags.getArray();
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 			// the states of all these properties
109*cdf0e10cSrcweir 			Sequence< PropertyState > aPropertyStates(nMasterPropsCount);
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 			for (sal_Int32 i=0; i<nMasterPropsCount; ++i)
112*cdf0e10cSrcweir 				pInclusionFlags[i] = sal_True;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 			Reference< XPropertySet >  xSecondarySet;
115*cdf0e10cSrcweir 			sal_Int32 nSecondaryPropertyCount;
116*cdf0e10cSrcweir 			Sequence< Property > aSecondaryProperties;
117*cdf0e10cSrcweir 			const Property* pPrimaryProperty = aMasterProps.getConstArray();
118*cdf0e10cSrcweir 			for (sal_Int32 nPrimary=0; nPrimary<nMasterPropsCount; ++nPrimary, ++pPrimaryProperty)
119*cdf0e10cSrcweir 			{
120*cdf0e10cSrcweir 				if (_pMetaData && !_pMetaData->isComposeable(pPrimaryProperty->Name))
121*cdf0e10cSrcweir 					// do not include this property
122*cdf0e10cSrcweir 					pInclusionFlags[nPrimary] = sal_False;
123*cdf0e10cSrcweir 				else
124*cdf0e10cSrcweir 				{
125*cdf0e10cSrcweir 					// search the property in all secondary sets
126*cdf0e10cSrcweir 					for (sal_Int32 i=1; i<nSingleSets; ++i)
127*cdf0e10cSrcweir 					{
128*cdf0e10cSrcweir 						xSecondarySet = m_aSingleSets[i];
129*cdf0e10cSrcweir 						aSecondaryProperties = xSecondarySet->getPropertySetInfo()->getProperties();
130*cdf0e10cSrcweir 						nSecondaryPropertyCount = aSecondaryProperties.getLength();
131*cdf0e10cSrcweir 						const Property*	pSecondaryProperties = aSecondaryProperties.getConstArray();
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 						// search the current primary property in the secondary property sequence
134*cdf0e10cSrcweir 						sal_Int32 k=0;
135*cdf0e10cSrcweir 						while (k<nSecondaryPropertyCount && (pSecondaryProperties[k].Name != pPrimaryProperty->Name))
136*cdf0e10cSrcweir 							++k;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 						if (k >= nSecondaryPropertyCount)
139*cdf0e10cSrcweir 							// not found -> do not include
140*cdf0e10cSrcweir 							pInclusionFlags[nPrimary] = sal_False;
141*cdf0e10cSrcweir 					}
142*cdf0e10cSrcweir 				}
143*cdf0e10cSrcweir 			}
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 			// count what's left ....
146*cdf0e10cSrcweir 			sal_Int32 nOverallProperties = 0;
147*cdf0e10cSrcweir 			for (sal_Int32 nCounter=0; nCounter<nMasterPropsCount; ++nCounter)
148*cdf0e10cSrcweir 			{
149*cdf0e10cSrcweir 				if (pInclusionFlags[nCounter])
150*cdf0e10cSrcweir 					++nOverallProperties;
151*cdf0e10cSrcweir 			}
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 			// and finally construct our sequence
154*cdf0e10cSrcweir 			m_aProperties = Sequence< Property >(nOverallProperties);
155*cdf0e10cSrcweir 			Property* pProperties = m_aProperties.getArray();
156*cdf0e10cSrcweir 			const Property* pMasterProperties = pMasterProps;
157*cdf0e10cSrcweir 			sal_Int32 nOwnProperties = 0;
158*cdf0e10cSrcweir 			for (sal_Int32 nCopy = 0; nCopy < nMasterPropsCount; ++nCopy, ++pMasterProperties)
159*cdf0e10cSrcweir 			{
160*cdf0e10cSrcweir 				if (pInclusionFlags[nCopy])
161*cdf0e10cSrcweir 					pProperties[nOwnProperties++] = *pMasterProperties;
162*cdf0e10cSrcweir 			}
163*cdf0e10cSrcweir 		}
164*cdf0e10cSrcweir 	}
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
167*cdf0e10cSrcweir 	Reference< XPropertySetInfo > SAL_CALL OComposedPropertySet::getPropertySetInfo(  ) throw(RuntimeException)
168*cdf0e10cSrcweir 	{
169*cdf0e10cSrcweir 		::osl::MutexGuard aGuard(m_aMutex);
170*cdf0e10cSrcweir 		if (!m_pInfo)
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			m_pInfo = new OComposedPropertySetInfo(m_aProperties);
173*cdf0e10cSrcweir 			m_pInfo->acquire();
174*cdf0e10cSrcweir 		}
175*cdf0e10cSrcweir 		return m_pInfo;
176*cdf0e10cSrcweir 	}
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
179*cdf0e10cSrcweir 	PropertyState SAL_CALL OComposedPropertySet::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw(UnknownPropertyException, RuntimeException)
180*cdf0e10cSrcweir 	{
181*cdf0e10cSrcweir 		// assume DIRECT for the moment
182*cdf0e10cSrcweir 		PropertyState eState = PropertyState_DIRECT_VALUE;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 		sal_Int32 nSingleSets = m_aSingleSets.size();
185*cdf0e10cSrcweir 		if (nSingleSets>0)
186*cdf0e10cSrcweir 		{
187*cdf0e10cSrcweir 			// check the master state
188*cdf0e10cSrcweir 			Reference< XPropertySet >  xMasterSet(m_aSingleSets[0]);
189*cdf0e10cSrcweir 			Any aPrimaryValue;
190*cdf0e10cSrcweir 			if (xMasterSet.is())
191*cdf0e10cSrcweir 			{
192*cdf0e10cSrcweir 				Reference< XPropertyState >  xMasterState(xMasterSet,UNO_QUERY);
193*cdf0e10cSrcweir 				aPrimaryValue = xMasterSet->getPropertyValue(_rPropertyName);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 				if (xMasterState.is())
196*cdf0e10cSrcweir 					eState = xMasterState->getPropertyState(_rPropertyName);
197*cdf0e10cSrcweir 			}
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 			// loop through the secondary sets
200*cdf0e10cSrcweir 			PropertyState eSecondaryState;
201*cdf0e10cSrcweir 			for (sal_Int32 i=1; i<nSingleSets; ++i)
202*cdf0e10cSrcweir 			{
203*cdf0e10cSrcweir 				Reference< XPropertySet >	xSecondary(m_aSingleSets[i]);
204*cdf0e10cSrcweir 				Reference< XPropertyState >	xSecondaryState(xSecondary, UNO_QUERY);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 				// the secondary state
207*cdf0e10cSrcweir 				eSecondaryState = PropertyState_DIRECT_VALUE;
208*cdf0e10cSrcweir 				if(xSecondaryState.is())
209*cdf0e10cSrcweir 					eSecondaryState = xSecondaryState->getPropertyState(_rPropertyName);
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 				// the secondary value
212*cdf0e10cSrcweir 				Any aSecondaryValue(xSecondary->getPropertyValue(_rPropertyName));
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 				if	(	(PropertyState_AMBIGUOUS_VALUE == eSecondaryState)		// secondary is ambiguous
215*cdf0e10cSrcweir 					||	!::comphelper::compare(aPrimaryValue, aSecondaryValue)	// unequal values
216*cdf0e10cSrcweir 					)
217*cdf0e10cSrcweir 				{
218*cdf0e10cSrcweir 					eState = PropertyState_AMBIGUOUS_VALUE;
219*cdf0e10cSrcweir 					break;
220*cdf0e10cSrcweir 				}
221*cdf0e10cSrcweir 			}
222*cdf0e10cSrcweir 		}
223*cdf0e10cSrcweir 		else
224*cdf0e10cSrcweir 		{
225*cdf0e10cSrcweir 			throw UnknownPropertyException(  _rPropertyName, *this  );
226*cdf0e10cSrcweir 		}
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 		return eState;
229*cdf0e10cSrcweir 	}
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	//---------------------------------------------------------------------
232*cdf0e10cSrcweir 	Sequence< PropertyState > SAL_CALL OComposedPropertySet::getPropertyStates( const Sequence< ::rtl::OUString >& _rPropertyName ) throw(UnknownPropertyException, RuntimeException)
233*cdf0e10cSrcweir 	{
234*cdf0e10cSrcweir 		sal_Int32 nCount = _rPropertyName.getLength();
235*cdf0e10cSrcweir 		Sequence< PropertyState > aReturn(nCount);
236*cdf0e10cSrcweir 		const ::rtl::OUString* pNames = _rPropertyName.getConstArray();
237*cdf0e10cSrcweir 		PropertyState* pStates = aReturn.getArray();
238*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nCount; ++i, ++pNames, ++pStates)
239*cdf0e10cSrcweir 			*pStates = getPropertyState(*pNames);
240*cdf0e10cSrcweir 		return aReturn;
241*cdf0e10cSrcweir 	}
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	//---------------------------------------------------------------------
244*cdf0e10cSrcweir 	void SAL_CALL OComposedPropertySet::setPropertyToDefault( const ::rtl::OUString& _rPropertyName ) throw(UnknownPropertyException, RuntimeException)
245*cdf0e10cSrcweir 	{
246*cdf0e10cSrcweir 		sal_Int32 nSingleSets = m_aSingleSets.size();
247*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nSingleSets; ++i)
248*cdf0e10cSrcweir 		{
249*cdf0e10cSrcweir 			Reference< XPropertyState >	xState(m_aSingleSets[i], UNO_QUERY);
250*cdf0e10cSrcweir 			if(xState.is())
251*cdf0e10cSrcweir 				xState->setPropertyToDefault(_rPropertyName);
252*cdf0e10cSrcweir 		}
253*cdf0e10cSrcweir 	}
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	//---------------------------------------------------------------------
256*cdf0e10cSrcweir 	Any SAL_CALL OComposedPropertySet::getPropertyDefault( const ::rtl::OUString& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
257*cdf0e10cSrcweir 	{
258*cdf0e10cSrcweir 		return Any();
259*cdf0e10cSrcweir 	}
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
262*cdf0e10cSrcweir 	void SAL_CALL OComposedPropertySet::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
263*cdf0e10cSrcweir 	{
264*cdf0e10cSrcweir 		sal_Int32 nSingleSets = m_aSingleSets.size();
265*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nSingleSets; ++i)
266*cdf0e10cSrcweir 		{
267*cdf0e10cSrcweir 			if (m_aSingleSets[i].is())
268*cdf0e10cSrcweir 				m_aSingleSets[i]->setPropertyValue(_rPropertyName, _rValue);
269*cdf0e10cSrcweir 		}
270*cdf0e10cSrcweir 	}
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
273*cdf0e10cSrcweir 	Any SAL_CALL OComposedPropertySet::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		sal_Int32 nSingleSets = m_aSingleSets.size();
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 		if ((nSingleSets>0) && (m_aSingleSets[0].is()))
278*cdf0e10cSrcweir 			return m_aSingleSets[0]->getPropertyValue(_rPropertyName);
279*cdf0e10cSrcweir 		return Any();
280*cdf0e10cSrcweir 	}
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
283*cdf0e10cSrcweir 	void SAL_CALL OComposedPropertySet::addPropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
284*cdf0e10cSrcweir 	{
285*cdf0e10cSrcweir 		// TODO:
286*cdf0e10cSrcweir 		// hold the single property sets weak
287*cdf0e10cSrcweir 		// be a property change listener on all single property sets (for all composed properties)
288*cdf0e10cSrcweir 		// upon property change
289*cdf0e10cSrcweir 		//   determine the new state/value of the composed property
290*cdf0e10cSrcweir 		//   broadcast the new composed property value
291*cdf0e10cSrcweir 	}
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
294*cdf0e10cSrcweir 	void SAL_CALL OComposedPropertySet::removePropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
295*cdf0e10cSrcweir 	{
296*cdf0e10cSrcweir 		// TODO
297*cdf0e10cSrcweir 	}
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
300*cdf0e10cSrcweir 	void SAL_CALL OComposedPropertySet::addVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
301*cdf0e10cSrcweir 	{
302*cdf0e10cSrcweir 		OSL_ENSURE(sal_False, "OComposedPropertySet::addVetoableChangeListener: no implemented (yet)!");
303*cdf0e10cSrcweir 	}
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
306*cdf0e10cSrcweir 	void SAL_CALL OComposedPropertySet::removeVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
307*cdf0e10cSrcweir 	{
308*cdf0e10cSrcweir 		OSL_ENSURE(sal_False, "OComposedPropertySet::removeVetoableChangeListener: no implemented (yet)!");
309*cdf0e10cSrcweir 	}
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
312*cdf0e10cSrcweir 	OComposedPropertySetInfo::OComposedPropertySetInfo(const Sequence< Property>& rSeq)
313*cdf0e10cSrcweir 		:m_aProperties(rSeq)
314*cdf0e10cSrcweir 	{
315*cdf0e10cSrcweir 	}
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
318*cdf0e10cSrcweir 	Sequence< Property> SAL_CALL OComposedPropertySetInfo::getProperties() throw(RuntimeException)
319*cdf0e10cSrcweir 	{
320*cdf0e10cSrcweir 		return m_aProperties;
321*cdf0e10cSrcweir 	}
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
324*cdf0e10cSrcweir 	Property SAL_CALL OComposedPropertySetInfo::getPropertyByName( const ::rtl::OUString& _rName ) throw(UnknownPropertyException, RuntimeException)
325*cdf0e10cSrcweir 	{
326*cdf0e10cSrcweir 		sal_Int32 nLength = m_aProperties.getLength();
327*cdf0e10cSrcweir 		const Property*	pProps = m_aProperties.getConstArray();
328*cdf0e10cSrcweir 		// TODO TODO TODO: this O(n) search really sucks ...
329*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nLength; ++i, ++pProps)
330*cdf0e10cSrcweir 		{
331*cdf0e10cSrcweir 			if (pProps->Name == _rName)
332*cdf0e10cSrcweir 				return *pProps;
333*cdf0e10cSrcweir 		}
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 		throw UnknownPropertyException( _rName, *this  );
336*cdf0e10cSrcweir 	}
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
339*cdf0e10cSrcweir 	sal_Bool SAL_CALL OComposedPropertySetInfo::hasPropertyByName( const ::rtl::OUString& _rName ) throw(RuntimeException)
340*cdf0e10cSrcweir 	{
341*cdf0e10cSrcweir 		sal_Int32 nLength = m_aProperties.getLength();
342*cdf0e10cSrcweir 		const Property*	pProps = m_aProperties.getConstArray();
343*cdf0e10cSrcweir 		// TODO TODO TODO: this O(n) search really sucks ...
344*cdf0e10cSrcweir 		for( sal_Int32 i=0; i<nLength; ++i,++pProps )
345*cdf0e10cSrcweir 		{
346*cdf0e10cSrcweir 			if(pProps->Name == _rName)
347*cdf0e10cSrcweir 				return sal_True;
348*cdf0e10cSrcweir 		}
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 		return sal_False;
351*cdf0e10cSrcweir 	}
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir //.........................................................................
354*cdf0e10cSrcweir }	// namespace comphelper
355*cdf0e10cSrcweir //.........................................................................
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 
358