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
{
29 FastPropertySetInfo::FastPropertySetInfo( const PropertyVector
& rProps
)
31 addProperties( rProps
);
35 FastPropertySetInfo::~FastPropertySetInfo()
40 void FastPropertySetInfo::addProperties( const PropertyVector
& rProps
)
42 sal_uInt32 nIndex
= maProperties
.size();
43 sal_uInt32 nCount
= rProps
.size();
44 maProperties
.resize( nIndex
+ nCount
);
45 for( const Property
& rProperty
: rProps
)
47 maProperties
[nIndex
] = rProperty
;
48 maMap
[ rProperty
.Name
] = nIndex
++;
53 const Property
& FastPropertySetInfo::getProperty( const OUString
& aName
)
55 PropertyMap::iterator
aIter( maMap
.find( aName
) );
56 if( aIter
== maMap
.end() )
57 throw UnknownPropertyException( aName
, static_cast<cppu::OWeakObject
*>(this));
58 return maProperties
[(*aIter
).second
];
62 const Property
* FastPropertySetInfo::hasProperty( const OUString
& aName
)
64 PropertyMap::iterator
aIter( maMap
.find( aName
) );
65 if( aIter
== maMap
.end() )
68 return &maProperties
[(*aIter
).second
];
75 Sequence
< Property
> SAL_CALL
FastPropertySetInfo::getProperties()
77 return Sequence
< Property
>( maProperties
.data(), maProperties
.size() );
81 Property SAL_CALL
FastPropertySetInfo::getPropertyByName( const OUString
& aName
)
83 return getProperty( aName
);
87 sal_Bool SAL_CALL
FastPropertySetInfo::hasPropertyByName( const OUString
& aName
)
89 return hasProperty( aName
) != nullptr;
92 FastPropertySet::FastPropertySet( const rtl::Reference
< FastPropertySetInfo
>& xInfo
)
98 FastPropertySet::~FastPropertySet()
106 Reference
< XPropertySetInfo
> SAL_CALL
FastPropertySet::getPropertySetInfo( )
108 return Reference
< XPropertySetInfo
>( mxInfo
.get() );
112 void SAL_CALL
FastPropertySet::setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
)
114 setFastPropertyValue( mxInfo
->getProperty( aPropertyName
).Handle
, aValue
);
118 Any SAL_CALL
FastPropertySet::getPropertyValue( const OUString
& aPropertyName
)
120 return getFastPropertyValue( mxInfo
->getProperty( aPropertyName
).Handle
);
124 void SAL_CALL
FastPropertySet::addPropertyChangeListener( const OUString
&, const Reference
< XPropertyChangeListener
>& )
129 void SAL_CALL
FastPropertySet::removePropertyChangeListener( const OUString
&, const Reference
< XPropertyChangeListener
>& )
134 void SAL_CALL
FastPropertySet::addVetoableChangeListener( const OUString
&, const Reference
< XVetoableChangeListener
>& )
139 void SAL_CALL
FastPropertySet::removeVetoableChangeListener( const OUString
&, const Reference
< XVetoableChangeListener
>& )
147 void SAL_CALL
FastPropertySet::setPropertyValues( const Sequence
< OUString
>& aPropertyNames
, const Sequence
< Any
>& aValues
)
149 if( aPropertyNames
.getLength() != aValues
.getLength() )
150 throw IllegalArgumentException();
152 const Any
* pValues
= aValues
.getConstArray();
153 for( const OUString
& rPropertyName
: aPropertyNames
)
155 const Property
* pProperty
= mxInfo
->hasProperty( rPropertyName
);
158 setFastPropertyValue( pProperty
->Handle
, *pValues
);
160 catch( UnknownPropertyException
& )
168 Sequence
< Any
> SAL_CALL
FastPropertySet::getPropertyValues( const Sequence
< OUString
>& aPropertyNames
)
170 sal_Int32 nCount
= aPropertyNames
.getLength();
171 Sequence
< Any
> aValues( nCount
);
173 Any
* pValues
= aValues
.getArray();
174 for( const OUString
& rPropertyName
: aPropertyNames
)
176 const Property
* pProperty
= mxInfo
->hasProperty( rPropertyName
);
179 *pValues
= getFastPropertyValue( pProperty
->Handle
);
181 catch( UnknownPropertyException
& )
190 void SAL_CALL
FastPropertySet::addPropertiesChangeListener( const Sequence
< OUString
>&, const Reference
< XPropertiesChangeListener
>& )
195 void SAL_CALL
FastPropertySet::removePropertiesChangeListener( const Reference
< XPropertiesChangeListener
>& )
200 void SAL_CALL
FastPropertySet::firePropertiesChangeEvent( const Sequence
< OUString
>&, const Reference
< XPropertiesChangeListener
>& )
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */