xref: /aoo41x/main/svx/source/table/propertyset.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "propertyset.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir using ::rtl::OUString;
30cdf0e10cSrcweir using namespace ::com::sun::star::uno;
31cdf0e10cSrcweir using namespace ::com::sun::star::beans;
32cdf0e10cSrcweir using namespace ::com::sun::star::lang;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace comphelper {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir // -----------------------------------------------------------------------------
37cdf0e10cSrcweir // FastPropertySetInfo
38cdf0e10cSrcweir // -----------------------------------------------------------------------------
39cdf0e10cSrcweir 
FastPropertySetInfo()40cdf0e10cSrcweir FastPropertySetInfo::FastPropertySetInfo()
41cdf0e10cSrcweir {
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // -----------------------------------------------------------------------------
45cdf0e10cSrcweir 
FastPropertySetInfo(const PropertyVector & rProps)46cdf0e10cSrcweir FastPropertySetInfo::FastPropertySetInfo( const PropertyVector& rProps )
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	addProperties( rProps );
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // -----------------------------------------------------------------------------
52cdf0e10cSrcweir 
~FastPropertySetInfo()53cdf0e10cSrcweir FastPropertySetInfo::~FastPropertySetInfo()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir // -----------------------------------------------------------------------------
58cdf0e10cSrcweir 
addProperty(const Property & rProperty)59cdf0e10cSrcweir void FastPropertySetInfo::addProperty( const Property& rProperty )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	maProperties.push_back( rProperty );
62cdf0e10cSrcweir 	maMap[ rProperty.Name ] = maProperties.size() - 1;
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // -----------------------------------------------------------------------------
66cdf0e10cSrcweir 
addProperties(const PropertyVector & rProps)67cdf0e10cSrcweir void FastPropertySetInfo::addProperties( const PropertyVector& rProps )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	sal_uInt32 nIndex = maProperties.size();
70cdf0e10cSrcweir 	sal_uInt32 nCount = rProps.size();
71cdf0e10cSrcweir 	maProperties.resize( nIndex + nCount );
72cdf0e10cSrcweir 	PropertyVector::const_iterator aIter( rProps.begin() );
73cdf0e10cSrcweir 	while( nCount-- )
74cdf0e10cSrcweir 	{
75cdf0e10cSrcweir 		const Property& rProperty = (*aIter++);
76cdf0e10cSrcweir 		maProperties[nIndex] = rProperty;
77cdf0e10cSrcweir 		maMap[ rProperty.Name ] = nIndex++;
78cdf0e10cSrcweir 	}
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // -----------------------------------------------------------------------------
82cdf0e10cSrcweir 
getProperty(const OUString & aName)83cdf0e10cSrcweir const Property& FastPropertySetInfo::getProperty( const OUString& aName ) throw (UnknownPropertyException )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	PropertyMap::iterator aIter( maMap.find( aName ) );
86cdf0e10cSrcweir 	if( aIter == maMap.end() )
87cdf0e10cSrcweir 		throw UnknownPropertyException();
88cdf0e10cSrcweir 	return maProperties[(*aIter).second];
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // -----------------------------------------------------------------------------
92cdf0e10cSrcweir 
hasProperty(const OUString & aName)93cdf0e10cSrcweir const Property* FastPropertySetInfo::hasProperty( const OUString& aName )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	PropertyMap::iterator aIter( maMap.find( aName ) );
96cdf0e10cSrcweir 	if( aIter == maMap.end() )
97cdf0e10cSrcweir 		return 0;
98cdf0e10cSrcweir 	else
99cdf0e10cSrcweir 		return &maProperties[(*aIter).second];
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // -----------------------------------------------------------------------------
103cdf0e10cSrcweir // XPropertySetInfo
104cdf0e10cSrcweir // -----------------------------------------------------------------------------
105cdf0e10cSrcweir 
getProperties()106cdf0e10cSrcweir Sequence< Property > SAL_CALL FastPropertySetInfo::getProperties() throw (RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	return Sequence< Property >( &maProperties[0], maProperties.size() );
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // -----------------------------------------------------------------------------
112cdf0e10cSrcweir 
getPropertyByName(const OUString & aName)113cdf0e10cSrcweir Property SAL_CALL FastPropertySetInfo::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	return getProperty( aName );
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir // -----------------------------------------------------------------------------
119cdf0e10cSrcweir 
hasPropertyByName(const OUString & aName)120cdf0e10cSrcweir sal_Bool SAL_CALL FastPropertySetInfo::hasPropertyByName( const OUString& aName ) throw (RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	return hasProperty( aName ) != 0 ? sal_True : sal_False;;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir // -----------------------------------------------------------------------------
126cdf0e10cSrcweir // FastPropertySet
127cdf0e10cSrcweir // -----------------------------------------------------------------------------
128cdf0e10cSrcweir 
FastPropertySet(const rtl::Reference<FastPropertySetInfo> & xInfo)129cdf0e10cSrcweir FastPropertySet::FastPropertySet( const rtl::Reference< FastPropertySetInfo >& xInfo )
130cdf0e10cSrcweir : mxInfo( xInfo )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir // -----------------------------------------------------------------------------
135cdf0e10cSrcweir 
~FastPropertySet()136cdf0e10cSrcweir FastPropertySet::~FastPropertySet()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir // -----------------------------------------------------------------------------
141cdf0e10cSrcweir // XPropertySet
142cdf0e10cSrcweir // -----------------------------------------------------------------------------
143cdf0e10cSrcweir 
getPropertySetInfo()144cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL FastPropertySet::getPropertySetInfo(  ) throw (RuntimeException)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	return Reference< XPropertySetInfo >( mxInfo.get() );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // -----------------------------------------------------------------------------
150cdf0e10cSrcweir 
setPropertyValue(const OUString & aPropertyName,const Any & aValue)151cdf0e10cSrcweir void SAL_CALL FastPropertySet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	setFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle, aValue );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // -----------------------------------------------------------------------------
157cdf0e10cSrcweir 
getPropertyValue(const OUString & aPropertyName)158cdf0e10cSrcweir Any SAL_CALL FastPropertySet::getPropertyValue( const OUString& aPropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	return getFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // -----------------------------------------------------------------------------
164cdf0e10cSrcweir 
addPropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)165cdf0e10cSrcweir void SAL_CALL FastPropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // -----------------------------------------------------------------------------
170cdf0e10cSrcweir 
removePropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)171cdf0e10cSrcweir void SAL_CALL FastPropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir // -----------------------------------------------------------------------------
176cdf0e10cSrcweir 
addVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)177cdf0e10cSrcweir void SAL_CALL FastPropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir // -----------------------------------------------------------------------------
182cdf0e10cSrcweir 
removeVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)183cdf0e10cSrcweir void SAL_CALL FastPropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir // -----------------------------------------------------------------------------
188cdf0e10cSrcweir // XMultiPropertySet
189cdf0e10cSrcweir // -----------------------------------------------------------------------------
190cdf0e10cSrcweir 
setPropertyValues(const Sequence<OUString> & aPropertyNames,const Sequence<Any> & aValues)191cdf0e10cSrcweir void SAL_CALL FastPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir 	const OUString* pPropertyNames = aPropertyNames.getConstArray();
194cdf0e10cSrcweir 	const Any* pValues = aValues.getConstArray();
195cdf0e10cSrcweir 	sal_Int32 nCount = aPropertyNames.getLength();
196cdf0e10cSrcweir 	if( nCount != aValues.getLength() )
197cdf0e10cSrcweir 		throw IllegalArgumentException();
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	while( nCount-- )
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir 		const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
202cdf0e10cSrcweir 		if( pProperty ) try
203cdf0e10cSrcweir 		{
204cdf0e10cSrcweir 			setFastPropertyValue( pProperty->Handle, *pValues );
205cdf0e10cSrcweir 		}
206cdf0e10cSrcweir 		catch( UnknownPropertyException& )
207cdf0e10cSrcweir 		{
208cdf0e10cSrcweir 		}
209cdf0e10cSrcweir 		pValues++;
210cdf0e10cSrcweir 	}
211cdf0e10cSrcweir }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir // -----------------------------------------------------------------------------
214cdf0e10cSrcweir 
getPropertyValues(const Sequence<OUString> & aPropertyNames)215cdf0e10cSrcweir Sequence< Any > SAL_CALL FastPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	sal_Int32 nCount = aPropertyNames.getLength();
218cdf0e10cSrcweir 	Sequence< Any > aValues( nCount );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	const OUString* pPropertyNames = aPropertyNames.getConstArray();
221cdf0e10cSrcweir 	Any* pValues = aValues.getArray();
222cdf0e10cSrcweir 	while( nCount-- )
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
225cdf0e10cSrcweir 		if( pProperty ) try
226cdf0e10cSrcweir 		{
227cdf0e10cSrcweir 			*pValues = getFastPropertyValue( pProperty->Handle );
228cdf0e10cSrcweir 		}
229cdf0e10cSrcweir 		catch( UnknownPropertyException& )
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 		pValues++;
233cdf0e10cSrcweir 	}
234cdf0e10cSrcweir 	return aValues;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir // -----------------------------------------------------------------------------
238cdf0e10cSrcweir 
addPropertiesChangeListener(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)239cdf0e10cSrcweir void SAL_CALL FastPropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir // -----------------------------------------------------------------------------
244cdf0e10cSrcweir 
removePropertiesChangeListener(const Reference<XPropertiesChangeListener> &)245cdf0e10cSrcweir void SAL_CALL FastPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir // -----------------------------------------------------------------------------
250cdf0e10cSrcweir 
firePropertiesChangeEvent(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)251cdf0e10cSrcweir void SAL_CALL FastPropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
252cdf0e10cSrcweir {
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir }
256