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 .
23 #include "propertyset.hxx"
25 using namespace ::com::sun::star::uno
;
26 using namespace ::com::sun::star::beans
;
27 using namespace ::com::sun::star::lang
;
29 namespace sdr::table
{
31 FastPropertySetInfo::FastPropertySetInfo( const PropertyVector
& rProps
)
33 addProperties( rProps
);
37 FastPropertySetInfo::~FastPropertySetInfo()
42 void FastPropertySetInfo::addProperties( const PropertyVector
& rProps
)
44 sal_uInt32 nIndex
= maProperties
.size();
45 sal_uInt32 nCount
= rProps
.size();
46 maProperties
.resize( nIndex
+ nCount
);
47 for( const Property
& rProperty
: rProps
)
49 maProperties
[nIndex
] = rProperty
;
50 maMap
[ rProperty
.Name
] = nIndex
++;
55 const Property
& FastPropertySetInfo::getProperty( const OUString
& aName
)
57 PropertyMap::iterator
aIter( maMap
.find( aName
) );
58 if( aIter
== maMap
.end() )
59 throw UnknownPropertyException( aName
, static_cast<cppu::OWeakObject
*>(this));
60 return maProperties
[(*aIter
).second
];
64 const Property
* FastPropertySetInfo::hasProperty( const OUString
& aName
)
66 PropertyMap::iterator
aIter( maMap
.find( aName
) );
67 if( aIter
== maMap
.end() )
70 return &maProperties
[(*aIter
).second
];
77 Sequence
< Property
> SAL_CALL
FastPropertySetInfo::getProperties()
79 return Sequence
< Property
>( maProperties
.data(), maProperties
.size() );
83 Property SAL_CALL
FastPropertySetInfo::getPropertyByName( const OUString
& aName
)
85 return getProperty( aName
);
89 sal_Bool SAL_CALL
FastPropertySetInfo::hasPropertyByName( const OUString
& aName
)
91 return hasProperty( aName
) != nullptr;
94 FastPropertySet::FastPropertySet( rtl::Reference
< FastPropertySetInfo
> xInfo
)
95 : mxInfo(std::move( xInfo
))
100 FastPropertySet::~FastPropertySet()
108 Reference
< XPropertySetInfo
> SAL_CALL
FastPropertySet::getPropertySetInfo( )
114 void SAL_CALL
FastPropertySet::setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
)
116 setFastPropertyValue( mxInfo
->getProperty( aPropertyName
).Handle
, aValue
);
120 Any SAL_CALL
FastPropertySet::getPropertyValue( const OUString
& aPropertyName
)
122 return getFastPropertyValue( mxInfo
->getProperty( aPropertyName
).Handle
);
126 void SAL_CALL
FastPropertySet::addPropertyChangeListener( const OUString
&, const Reference
< XPropertyChangeListener
>& )
131 void SAL_CALL
FastPropertySet::removePropertyChangeListener( const OUString
&, const Reference
< XPropertyChangeListener
>& )
136 void SAL_CALL
FastPropertySet::addVetoableChangeListener( const OUString
&, const Reference
< XVetoableChangeListener
>& )
141 void SAL_CALL
FastPropertySet::removeVetoableChangeListener( const OUString
&, const Reference
< XVetoableChangeListener
>& )
149 void SAL_CALL
FastPropertySet::setPropertyValues( const Sequence
< OUString
>& aPropertyNames
, const Sequence
< Any
>& aValues
)
151 if( aPropertyNames
.getLength() != aValues
.getLength() )
152 throw IllegalArgumentException();
154 const Any
* pValues
= aValues
.getConstArray();
155 for( const OUString
& rPropertyName
: aPropertyNames
)
157 const Property
* pProperty
= mxInfo
->hasProperty( rPropertyName
);
160 setFastPropertyValue( pProperty
->Handle
, *pValues
);
162 catch( UnknownPropertyException
& )
170 Sequence
< Any
> SAL_CALL
FastPropertySet::getPropertyValues( const Sequence
< OUString
>& aPropertyNames
)
172 sal_Int32 nCount
= aPropertyNames
.getLength();
173 Sequence
< Any
> aValues( nCount
);
175 Any
* pValues
= aValues
.getArray();
176 for( const OUString
& rPropertyName
: aPropertyNames
)
178 const Property
* pProperty
= mxInfo
->hasProperty( rPropertyName
);
181 *pValues
= getFastPropertyValue( pProperty
->Handle
);
183 catch( UnknownPropertyException
& )
192 void SAL_CALL
FastPropertySet::addPropertiesChangeListener( const Sequence
< OUString
>&, const Reference
< XPropertiesChangeListener
>& )
197 void SAL_CALL
FastPropertySet::removePropertiesChangeListener( const Reference
< XPropertiesChangeListener
>& )
202 void SAL_CALL
FastPropertySet::firePropertiesChangeEvent( const Sequence
< OUString
>&, const Reference
< XPropertiesChangeListener
>& )
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */