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