1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "propertyset.hxx"
23 using namespace ::com::sun::star::uno
;
24 using namespace ::com::sun::star::beans
;
25 using namespace ::com::sun::star::lang
;
27 namespace sdr
{ namespace table
{
30 // FastPropertySetInfo
33 FastPropertySetInfo::FastPropertySetInfo( const PropertyVector
& rProps
)
35 addProperties( rProps
);
40 FastPropertySetInfo::~FastPropertySetInfo()
46 void FastPropertySetInfo::addProperties( const PropertyVector
& rProps
)
48 sal_uInt32 nIndex
= maProperties
.size();
49 sal_uInt32 nCount
= rProps
.size();
50 maProperties
.resize( nIndex
+ nCount
);
51 PropertyVector::const_iterator
aIter( rProps
.begin() );
54 const Property
& rProperty
= (*aIter
++);
55 maProperties
[nIndex
] = rProperty
;
56 maMap
[ rProperty
.Name
] = nIndex
++;
62 const Property
& FastPropertySetInfo::getProperty( const OUString
& aName
) throw (UnknownPropertyException
)
64 PropertyMap::iterator
aIter( maMap
.find( aName
) );
65 if( aIter
== maMap
.end() )
66 throw UnknownPropertyException();
67 return maProperties
[(*aIter
).second
];
72 const Property
* FastPropertySetInfo::hasProperty( const OUString
& aName
)
74 PropertyMap::iterator
aIter( maMap
.find( aName
) );
75 if( aIter
== maMap
.end() )
78 return &maProperties
[(*aIter
).second
];
85 Sequence
< Property
> SAL_CALL
FastPropertySetInfo::getProperties() throw (RuntimeException
, std::exception
)
87 return Sequence
< Property
>( &maProperties
[0], maProperties
.size() );
92 Property SAL_CALL
FastPropertySetInfo::getPropertyByName( const OUString
& aName
) throw (UnknownPropertyException
, RuntimeException
, std::exception
)
94 return getProperty( aName
);
99 sal_Bool SAL_CALL
FastPropertySetInfo::hasPropertyByName( const OUString
& aName
) throw (RuntimeException
, std::exception
)
101 return hasProperty( aName
) != 0 ? sal_True
: sal_False
;
108 FastPropertySet::FastPropertySet( const rtl::Reference
< FastPropertySetInfo
>& xInfo
)
115 FastPropertySet::~FastPropertySet()
123 Reference
< XPropertySetInfo
> SAL_CALL
FastPropertySet::getPropertySetInfo( ) throw (RuntimeException
, std::exception
)
125 return Reference
< XPropertySetInfo
>( mxInfo
.get() );
130 void SAL_CALL
FastPropertySet::setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
) throw (UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
, std::exception
)
132 setFastPropertyValue( mxInfo
->getProperty( aPropertyName
).Handle
, aValue
);
137 Any SAL_CALL
FastPropertySet::getPropertyValue( const OUString
& aPropertyName
) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
139 return getFastPropertyValue( mxInfo
->getProperty( aPropertyName
).Handle
);
144 void SAL_CALL
FastPropertySet::addPropertyChangeListener( const OUString
&, const Reference
< XPropertyChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
150 void SAL_CALL
FastPropertySet::removePropertyChangeListener( const OUString
&, const Reference
< XPropertyChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
156 void SAL_CALL
FastPropertySet::addVetoableChangeListener( const OUString
&, const Reference
< XVetoableChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
162 void SAL_CALL
FastPropertySet::removeVetoableChangeListener( const OUString
&, const Reference
< XVetoableChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
170 void SAL_CALL
FastPropertySet::setPropertyValues( const Sequence
< OUString
>& aPropertyNames
, const Sequence
< Any
>& aValues
) throw (PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
, std::exception
)
172 const OUString
* pPropertyNames
= aPropertyNames
.getConstArray();
173 const Any
* pValues
= aValues
.getConstArray();
174 sal_Int32 nCount
= aPropertyNames
.getLength();
175 if( nCount
!= aValues
.getLength() )
176 throw IllegalArgumentException();
180 const Property
* pProperty
= mxInfo
->hasProperty( *pPropertyNames
++ );
183 setFastPropertyValue( pProperty
->Handle
, *pValues
);
185 catch( UnknownPropertyException
& )
194 Sequence
< Any
> SAL_CALL
FastPropertySet::getPropertyValues( const Sequence
< OUString
>& aPropertyNames
) throw (RuntimeException
, std::exception
)
196 sal_Int32 nCount
= aPropertyNames
.getLength();
197 Sequence
< Any
> aValues( nCount
);
199 const OUString
* pPropertyNames
= aPropertyNames
.getConstArray();
200 Any
* pValues
= aValues
.getArray();
203 const Property
* pProperty
= mxInfo
->hasProperty( *pPropertyNames
++ );
206 *pValues
= getFastPropertyValue( pProperty
->Handle
);
208 catch( UnknownPropertyException
& )
218 void SAL_CALL
FastPropertySet::addPropertiesChangeListener( const Sequence
< OUString
>&, const Reference
< XPropertiesChangeListener
>& ) throw (RuntimeException
, std::exception
)
224 void SAL_CALL
FastPropertySet::removePropertiesChangeListener( const Reference
< XPropertiesChangeListener
>& ) throw (RuntimeException
, std::exception
)
230 void SAL_CALL
FastPropertySet::firePropertiesChangeEvent( const Sequence
< OUString
>&, const Reference
< XPropertiesChangeListener
>& ) throw (RuntimeException
, std::exception
)
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */