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