22#include <osl/diagnose.h>
36 PropertyMap::const_iterator aIter = mxInfo->getPropertyMap().find(
aName );
38 if( mxInfo->getPropertyMap().end() != aIter )
39 return (*aIter).second;
46 : mxInfo(std::move(xInfo))
50PropertySetHelper::~PropertySetHelper() noexcept
55Reference< XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo( )
60void SAL_CALL PropertySetHelper::setPropertyValue(
const OUString& aPropertyName,
const Any& aValue )
65 if(
nullptr == aEntries[0] )
66 throw UnknownPropertyException( aPropertyName,
static_cast< XPropertySet*
>(
this ) );
70 _setPropertyValues( aEntries, &aValue );
73Any SAL_CALL PropertySetHelper::getPropertyValue(
const OUString& PropertyName )
78 if(
nullptr == aEntries[0] )
79 throw UnknownPropertyException( PropertyName,
static_cast< XPropertySet*
>(
this ) );
84 _getPropertyValues( aEntries, &aAny );
89void SAL_CALL PropertySetHelper::addPropertyChangeListener(
const OUString&,
const Reference< XPropertyChangeListener >& )
94void SAL_CALL PropertySetHelper::removePropertyChangeListener(
const OUString&,
const Reference< XPropertyChangeListener >& )
99void SAL_CALL PropertySetHelper::addVetoableChangeListener(
const OUString&,
const Reference< XVetoableChangeListener >& )
104void SAL_CALL PropertySetHelper::removeVetoableChangeListener(
const OUString&,
const Reference< XVetoableChangeListener >& )
110void SAL_CALL PropertySetHelper::setPropertyValues(
const Sequence< OUString >& rPropertyNames,
const Sequence< Any >& rValues )
112 const sal_Int32
nCount = rPropertyNames.getLength();
114 if(
nCount != rValues.getLength() )
115 throw IllegalArgumentException(
"lengths do not match", uno::Reference<uno::XInterface>(), -1);
121 pEntries[
nCount] =
nullptr;
122 const OUString* pNames = rPropertyNames.getConstArray();
124 bool bUnknown =
false;
126 for(
n = 0; !bUnknown && (
n <
nCount );
n++, pNames++ )
128 pEntries[
n] =
find( mxInfo, *pNames );
129 bUnknown =
nullptr == pEntries[
n];
133 _setPropertyValues( pEntries.get(), rValues.getConstArray() );
139Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues(
const Sequence< OUString >& rPropertyNames)
141 const sal_Int32
nCount = rPropertyNames.getLength();
144 return Sequence< Any >();
147 const OUString* pNames = rPropertyNames.getConstArray();
149 bool bUnknown =
false;
151 for(
n = 0; !bUnknown && (
n <
nCount );
n++, pNames++ )
153 pEntries[
n] =
find( mxInfo, *pNames );
154 bUnknown =
nullptr == pEntries[
n];
160 pEntries[
nCount] =
nullptr;
161 Sequence< Any > aValues(
nCount);
163 _getPropertyValues( pEntries.get(), aValues.getArray() );
168void SAL_CALL PropertySetHelper::addPropertiesChangeListener(
const Sequence< OUString >&,
const Reference< XPropertiesChangeListener >& )
173void SAL_CALL PropertySetHelper::removePropertiesChangeListener(
const Reference< XPropertiesChangeListener >& )
178void SAL_CALL PropertySetHelper::firePropertiesChangeEvent(
const Sequence< OUString >&,
const Reference< XPropertiesChangeListener >& )
184PropertyState SAL_CALL PropertySetHelper::getPropertyState(
const OUString& PropertyName )
190 throw UnknownPropertyException( PropertyName,
static_cast< XPropertySet*
>(
this ) );
194 PropertyState aState(PropertyState_AMBIGUOUS_VALUE);
195 _getPropertyStates(
aEntries, &aState );
200Sequence< PropertyState > SAL_CALL PropertySetHelper::getPropertyStates(
const Sequence< OUString >& aPropertyName )
202 const sal_Int32
nCount = aPropertyName.getLength();
204 Sequence< PropertyState > aStates(
nCount );
208 const OUString* pNames = aPropertyName.getConstArray();
210 bool bUnknown =
false;
215 for(
n = 0; !bUnknown && (
n <
nCount);
n++, pNames++ )
217 pEntries[
n] =
find( mxInfo, *pNames );
218 bUnknown =
nullptr == pEntries[
n];
221 pEntries[
nCount] =
nullptr;
224 _getPropertyStates( pEntries.get(), aStates.getArray() );
227 throw UnknownPropertyException( *pNames,
static_cast< XPropertySet*
>(
this ) );
233void SAL_CALL PropertySetHelper::setPropertyToDefault(
const OUString& PropertyName )
236 if(
nullptr == pEntry )
237 throw UnknownPropertyException( PropertyName,
static_cast< XPropertySet*
>(
this ) );
239 _setPropertyToDefault( pEntry );
242Any SAL_CALL PropertySetHelper::getPropertyDefault(
const OUString& aPropertyName )
245 if(
nullptr == pEntry )
246 throw UnknownPropertyException( aPropertyName,
static_cast< XPropertySet*
>(
this ) );
248 return _getPropertyDefault( pEntry );
251void PropertySetHelper::_getPropertyStates(
254 OSL_FAIL(
"you have to implement this yourself!");
260 OSL_FAIL(
"you have to implement this yourself!");
265 OSL_FAIL(
"you have to implement this yourself!");
ScXMLEditAttributeMap::Entry const aEntries[]
class SAL_NO_VTABLE XPropertySet
std::pair< OUString const, DataAccessDescriptorProperty > PropertyMapEntry
static PropertyMapEntry const * find(const rtl::Reference< PropertySetInfo > &mxInfo, const OUString &aName) noexcept