Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / table / propertyset.cxx
blob9043a7ca81cbe2c8c568fe94d0c0bae552414153
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "propertyset.hxx"
32 using ::rtl::OUString;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::lang;
37 namespace comphelper {
39 // -----------------------------------------------------------------------------
40 // FastPropertySetInfo
41 // -----------------------------------------------------------------------------
43 FastPropertySetInfo::FastPropertySetInfo( const PropertyVector& rProps )
45 addProperties( rProps );
48 // -----------------------------------------------------------------------------
50 FastPropertySetInfo::~FastPropertySetInfo()
54 // -----------------------------------------------------------------------------
56 void FastPropertySetInfo::addProperties( const PropertyVector& rProps )
58 sal_uInt32 nIndex = maProperties.size();
59 sal_uInt32 nCount = rProps.size();
60 maProperties.resize( nIndex + nCount );
61 PropertyVector::const_iterator aIter( rProps.begin() );
62 while( nCount-- )
64 const Property& rProperty = (*aIter++);
65 maProperties[nIndex] = rProperty;
66 maMap[ rProperty.Name ] = nIndex++;
70 // -----------------------------------------------------------------------------
72 const Property& FastPropertySetInfo::getProperty( const OUString& aName ) throw (UnknownPropertyException )
74 PropertyMap::iterator aIter( maMap.find( aName ) );
75 if( aIter == maMap.end() )
76 throw UnknownPropertyException();
77 return maProperties[(*aIter).second];
80 // -----------------------------------------------------------------------------
82 const Property* FastPropertySetInfo::hasProperty( const OUString& aName )
84 PropertyMap::iterator aIter( maMap.find( aName ) );
85 if( aIter == maMap.end() )
86 return 0;
87 else
88 return &maProperties[(*aIter).second];
91 // -----------------------------------------------------------------------------
92 // XPropertySetInfo
93 // -----------------------------------------------------------------------------
95 Sequence< Property > SAL_CALL FastPropertySetInfo::getProperties() throw (RuntimeException)
97 return Sequence< Property >( &maProperties[0], maProperties.size() );
100 // -----------------------------------------------------------------------------
102 Property SAL_CALL FastPropertySetInfo::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException)
104 return getProperty( aName );
107 // -----------------------------------------------------------------------------
109 sal_Bool SAL_CALL FastPropertySetInfo::hasPropertyByName( const OUString& aName ) throw (RuntimeException)
111 return hasProperty( aName ) != 0 ? sal_True : sal_False;
114 // -----------------------------------------------------------------------------
115 // FastPropertySet
116 // -----------------------------------------------------------------------------
118 FastPropertySet::FastPropertySet( const rtl::Reference< FastPropertySetInfo >& xInfo )
119 : mxInfo( xInfo )
123 // -----------------------------------------------------------------------------
125 FastPropertySet::~FastPropertySet()
129 // -----------------------------------------------------------------------------
130 // XPropertySet
131 // -----------------------------------------------------------------------------
133 Reference< XPropertySetInfo > SAL_CALL FastPropertySet::getPropertySetInfo( ) throw (RuntimeException)
135 return Reference< XPropertySetInfo >( mxInfo.get() );
138 // -----------------------------------------------------------------------------
140 void SAL_CALL FastPropertySet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
142 setFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle, aValue );
145 // -----------------------------------------------------------------------------
147 Any SAL_CALL FastPropertySet::getPropertyValue( const OUString& aPropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
149 return getFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle );
152 // -----------------------------------------------------------------------------
154 void SAL_CALL FastPropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
158 // -----------------------------------------------------------------------------
160 void SAL_CALL FastPropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
164 // -----------------------------------------------------------------------------
166 void SAL_CALL FastPropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
170 // -----------------------------------------------------------------------------
172 void SAL_CALL FastPropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
176 // -----------------------------------------------------------------------------
177 // XMultiPropertySet
178 // -----------------------------------------------------------------------------
180 void SAL_CALL FastPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
182 const OUString* pPropertyNames = aPropertyNames.getConstArray();
183 const Any* pValues = aValues.getConstArray();
184 sal_Int32 nCount = aPropertyNames.getLength();
185 if( nCount != aValues.getLength() )
186 throw IllegalArgumentException();
188 while( nCount-- )
190 const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
191 if( pProperty ) try
193 setFastPropertyValue( pProperty->Handle, *pValues );
195 catch( UnknownPropertyException& )
198 pValues++;
202 // -----------------------------------------------------------------------------
204 Sequence< Any > SAL_CALL FastPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
206 sal_Int32 nCount = aPropertyNames.getLength();
207 Sequence< Any > aValues( nCount );
209 const OUString* pPropertyNames = aPropertyNames.getConstArray();
210 Any* pValues = aValues.getArray();
211 while( nCount-- )
213 const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
214 if( pProperty ) try
216 *pValues = getFastPropertyValue( pProperty->Handle );
218 catch( UnknownPropertyException& )
221 pValues++;
223 return aValues;
226 // -----------------------------------------------------------------------------
228 void SAL_CALL FastPropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
232 // -----------------------------------------------------------------------------
234 void SAL_CALL FastPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
238 // -----------------------------------------------------------------------------
240 void SAL_CALL FastPropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */