22#include <property.hxx>
24#include <com/sun/star/lang/DisposedException.hpp>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <com/sun/star/beans/PropertyExistException.hpp>
27#include <com/sun/star/beans/XMultiPropertySet.hpp>
28#include <com/sun/star/beans/NotRemoveableException.hpp>
29#include <com/sun/star/beans/UnknownPropertyException.hpp>
36#define NEW_HANDLE_BASE 10000
43 using ::com::sun::star::lang::DisposedException;
44 using ::com::sun::star::uno::Sequence;
45 using ::com::sun::star::beans::Property;
46 using ::com::sun::star::uno::Any;
47 using ::com::sun::star::beans::PropertyExistException;
48 using ::com::sun::star::beans::PropertyValue;
49 using ::com::sun::star::uno::Reference;
50 using ::com::sun::star::beans::XMultiPropertySet;
51 using ::com::sun::star::beans::XPropertySetInfo;
52 using ::com::sun::star::uno::RuntimeException;
53 using ::com::sun::star::uno::Exception;
54 using ::com::sun::star::beans::NotRemoveableException;
55 using ::com::sun::star::beans::UnknownPropertyException;
57 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
67 static ConcreteInfoService s_aPropInfos;
93 throw DisposedException();
108 sal_Int32
nHandle = lcl_getPropertyInfos().getPreferredPropertyId( _rPropertyName );
115 sal_Int32
const nPrime = 1009;
116 sal_Int32 nFactor = 11;
117 sal_Int32 nNum = nFactor;
126 nNum = ( nNum * nFactor ) % nPrime;
152 Sequence< Property > aFixedProps;
153 Sequence< Property > aAggregateProps;
157 Sequence< Property > aDynamicProps;
160 Sequence< Property > aOwnProps(
161 ::comphelper::concatSequences( aFixedProps, aDynamicProps ) );
164 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
170 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
190 _nAttributes |= PropertyAttribute::REMOVABLE;
210 Reference< XPropertySetInfo > xPSI( xMe->getPropertySetInfo(), css::uno::UNO_SET_THROW );
211 Property aProperty( xPSI->getPropertyByName( _rName ) );
212 if ( ( aProperty.Attributes & PropertyAttribute::REMOVABLE ) == 0 )
213 throw NotRemoveableException( _rName, xMe );
223 struct SelectNameOfProperty
225 const OUString& operator()(
const Property& _rProp )
const {
return _rProp.Name; }
229 struct SelectNameOfPropertyValue
231 const OUString& operator()(
const PropertyValue& _rProp )
const {
return _rProp.Name; }
235 struct SelectValueOfPropertyValue
237 const Any& operator()(
const PropertyValue& _rProp )
const {
return _rProp.Value; }
241 struct PropertyValueLessByName
243 bool operator()(
const PropertyValue& _lhs,
const PropertyValue& _rhs )
const
245 return _lhs.Name < _rhs.Name;
257 Reference< XPropertySetInfo > xPSI( xMe->getPropertySetInfo(), css::uno::UNO_SET_THROW );
259 const Sequence< Property >
aProperties( xPSI->getProperties() );
260 Sequence< OUString > aPropertyNames(
aProperties.getLength() );
262 aPropertyNames.getArray(), SelectNameOfProperty() );
264 Sequence< Any > aValues;
267 aValues = xMe->getPropertyValues( aPropertyNames );
269 if ( aValues.getLength() != aPropertyNames.getLength() )
280 const OUString*
pName = aPropertyNames.getConstArray();
281 const OUString* pNameEnd = aPropertyNames.getConstArray() + aPropertyNames.getLength();
282 const Any* pValue = aValues.getConstArray();
283 for ( ;
pName != pNameEnd; ++
pName, ++pValue, ++pPropertyValue )
285 pPropertyValue->Name = *
pName;
286 pPropertyValue->Value = *pValue;
298 sal_Int32 nPropertyValues = _rProps.getLength();
302 Sequence< PropertyValue > aSortedProps( _rProps );
303 ::std::sort( aSortedProps.getArray(), aSortedProps.getArray() + nPropertyValues, PropertyValueLessByName() );
309 for (
const PropertyValue* pProperties = aSortedProps.getConstArray();
310 pProperties != aSortedProps.getConstArray() + nPropertyValues;
320 Sequence< OUString > aNames( nPropertyValues );
321 ::std::transform( aSortedProps.getConstArray(), aSortedProps.getConstArray() + nPropertyValues,
322 aNames.getArray(), SelectNameOfPropertyValue() );
324 Sequence< Any > aValues( nPropertyValues );
325 ::std::transform( aSortedProps.getConstArray(), aSortedProps.getConstArray() + nPropertyValues,
326 aValues.getArray(), SelectValueOfPropertyValue() );
331 xMe->setPropertyValues( aNames, aValues );
PropertyValueVector_t aPropertyValues
PropertiesInfo aProperties
virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(OUString *_pPropName, sal_Int16 *_pAttributes, sal_Int32 _nHandle) override
virtual sal_Bool SAL_CALL hasPropertyByName(const OUString &_rPropertyName) override
virtual ::osl::Mutex & getMutex()=0
virtual void describeFixedAndAggregateProperties(css::uno::Sequence< css::beans::Property > &_out_rFixedProperties, css::uno::Sequence< css::beans::Property > &_out_rAggregateProperties) const =0
virtual css::uno::Reference< css::beans::XMultiPropertySet > getPropertiesInterface()=0
PropertyBagHelper(IPropertyBagHelperContext &_rContext)
::comphelper::PropertyBag m_aDynamicProperties
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues()
void removeProperty(const OUString &_rName)
sal_Int32 impl_findFreeHandle(const OUString &_rPropertyName)
finds a free property handle
void addProperty(const OUString &_rName, ::sal_Int16 _nAttributes, const css::uno::Any &_rInitialValue)
void setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &_rProps)
::comphelper::OPropertyArrayAggregationHelper & impl_ts_getArrayHelper() const
returns the IPropertyArrayHelper instance used by |this|
void impl_nts_checkDisposed_throw() const
IPropertyBagHelperContext & m_rContext
std::unique_ptr<::comphelper::OPropertyArrayAggregationHelper > m_pPropertyArrayHelper
void impl_nts_invalidatePropertySetInfo()
invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus getInfoHelp...
#define DBG_UNHANDLED_EXCEPTION(...)
ListBox is a bit confusing / different from other form components, so here are a few notes:
const Reference< XComponentContext > & m_rContext