LibreOffice Module comphelper (master)  1
Public Member Functions | Private Attributes | List of all members
comphelper::PropertyBag Class Referencefinal

provides a bag of properties associated with their values More...

#include <propertybag.hxx>

Inheritance diagram for comphelper::PropertyBag:
[legend]
Collaboration diagram for comphelper::PropertyBag:
[legend]

Public Member Functions

 PropertyBag ()
 
virtual ~PropertyBag ()
 
void setAllowEmptyPropertyName (bool i_isAllowed)
 allow adding property with empty string as name (by default, such names are rejected with IllegalActionException). More...
 
void addProperty (const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const css::uno::Any &_rInitialValue)
 adds a property to the bag More...
 
void addVoidProperty (const OUString &_rName, const css::uno::Type &_rType, sal_Int32 _nHandle, sal_Int32 _nAttributes)
 adds a property to the bag More...
 
void removeProperty (const OUString &_rName)
 removes a property from the bag More...
 
void describeProperties (css::uno::Sequence< css::beans::Property > &_out_rProps) const
 describes all properties in the bag More...
 
void getFastPropertyValue (sal_Int32 _nHandle, css::uno::Any &_out_rValue) const
 retrieves the value of a property given by handle More...
 
bool convertFastPropertyValue (sal_Int32 _nHandle, const css::uno::Any &_rNewValue, css::uno::Any &_out_rConvertedValue, css::uno::Any &_out_rCurrentValue) const
 converts a to-be-set value of a property (given by handle) so that it can be used in subsequent calls to setFastPropertyValue More...
 
void setFastPropertyValue (sal_Int32 _nHandle, const css::uno::Any &_rValue)
 sets a new value for a property given by handle More...
 
void getPropertyDefaultByHandle (sal_Int32 _nHandle, css::uno::Any &_out_rValue) const
 returns the default value for a property given by handle More...
 
bool hasPropertyByName (const OUString &_rName) const
 determines whether a property with a given name is part of the bag More...
 
bool hasPropertyByHandle (sal_Int32 _nHandle) const
 determines whether a property with a given handle is part of the bag More...
 

Private Attributes

::std::unique_ptr< PropertyBag_Implm_pImpl
 

Additional Inherited Members

- Protected Member Functions inherited from comphelper::OPropertyContainerHelper
 OPropertyContainerHelper ()
 
 ~OPropertyContainerHelper ()
 
void registerProperty (const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
 register a property. More...
 
void registerMayBeVoidProperty (const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, css::uno::Any *_pPointerToMember, const css::uno::Type &_rExpectedType)
 register a property. More...
 
void registerPropertyNoMember (const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const css::uno::Type &_rType, css::uno::Any const &_pInitialValue)
 register a property. More...
 
void revokeProperty (sal_Int32 _nHandle)
 revokes a previously registered property More...
 
bool isRegisteredProperty (sal_Int32 _nHandle) const
 checks whether a property with the given handle has been registered More...
 
bool isRegisteredProperty (const OUString &_rName) const
 checks whether a property with the given name has been registered More...
 
bool convertFastPropertyValue (css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue)
 
void setFastPropertyValue (sal_Int32 nHandle, const css::uno::Any &rValue)
 
void getFastPropertyValue (css::uno::Any &rValue, sal_Int32 nHandle) const
 
void describeProperties (css::uno::Sequence< css::beans::Property > &_rProps) const
 appends the descriptions of all properties which were registered 'til that moment to the given sequence, keeping the array sorted (by name) the given sequence is already sorted by name More...
 
const css::beans::Property & getProperty (const OUString &_rName) const
 retrieves the description for a registered property More...
 

Detailed Description

provides a bag of properties associated with their values

This class can, for instance, be used for components which need to implement the com.sun.star.beans.PropertyBag service.

Definition at line 42 of file propertybag.hxx.

Constructor & Destructor Documentation

comphelper::PropertyBag::PropertyBag ( )

Definition at line 59 of file propertybag.cxx.

comphelper::PropertyBag::~PropertyBag ( )
virtual

Definition at line 64 of file propertybag.cxx.

Member Function Documentation

void comphelper::PropertyBag::addProperty ( const OUString &  _rName,
sal_Int32  _nHandle,
sal_Int32  _nAttributes,
const css::uno::Any &  _rInitialValue 
)

adds a property to the bag

The type of the property is determined from its initial value (_rInitialValue).

Parameters
_rNamethe name of the new property. Must not be empty unless explicitly allowed with setAllowEmptyPropertyName.
_nHandlethe handle of the new property
_nAttributesthe attributes of the property
_rInitialValuethe initial value of the property. Must not be <NULL>, to allow determining the property type.
Exceptions
css::beans::IllegalTypeExceptionif the initial value is <NULL>
css::beans::PropertyExistExceptionif the name or the handle are already used
css::beans::IllegalArgumentExceptionif the name is empty

Definition at line 132 of file propertybag.cxx.

References m_pImpl, and comphelper::OPropertyContainerHelper::registerPropertyNoMember().

Referenced by comphelper::OPropertyBag::addProperty().

void comphelper::PropertyBag::addVoidProperty ( const OUString &  _rName,
const css::uno::Type &  _rType,
sal_Int32  _nHandle,
sal_Int32  _nAttributes 
)

adds a property to the bag

The initial value of the property is <NULL>.

Parameters
_rNamethe name of the new property. Must not be empty unless explicitly allowed with setAllowEmptyPropertyName.
_rTypethe type of the new property
_nHandlethe handle of the new property
_nAttributesthe attributes of the property
Exceptions
css::beans::IllegalTypeExceptionif the initial value is <NULL>
css::beans::PropertyExistExceptionif the name or the handle are already used
css::beans::IllegalArgumentExceptionif the name is empty

Definition at line 109 of file propertybag.cxx.

References Any, m_pImpl, and comphelper::OPropertyContainerHelper::registerPropertyNoMember().

Referenced by comphelper::OPropertyBag::insert().

bool comphelper::PropertyBag::convertFastPropertyValue ( sal_Int32  _nHandle,
const css::uno::Any &  _rNewValue,
css::uno::Any &  _out_rConvertedValue,
css::uno::Any &  _out_rCurrentValue 
) const

converts a to-be-set value of a property (given by handle) so that it can be used in subsequent calls to setFastPropertyValue

Parameters
_nHandlethe handle of the property
_rNewValuethe new value, which should be converted
_out_rConvertedValueoutput parameter taking the converted value
_out_rCurrentValueoutput parameter taking the current value of the property
Exceptions
UnknownPropertyExceptionif the given handle does not denote a property in the bag
IllegalArgumentExceptionif the given value cannot be lossless converted into a value for the given property.

Definition at line 178 of file propertybag.cxx.

References comphelper::OPropertyContainerHelper::convertFastPropertyValue(), and hasPropertyByHandle().

Referenced by comphelper::OPropertyBag::convertFastPropertyValue().

void comphelper::PropertyBag::describeProperties ( css::uno::Sequence< css::beans::Property > &  _out_rProps) const
inline

describes all properties in the bag

Parameters
_out_rPropstakes, upon return, the descriptions of all properties in the bag

Definition at line 133 of file propertybag.hxx.

References comphelper::OPropertyContainerHelper::describeProperties().

Referenced by comphelper::OPropertyBag::getInfoHelper(), and comphelper::OPropertyBag::getPropertyValues().

void comphelper::PropertyBag::getFastPropertyValue ( sal_Int32  _nHandle,
css::uno::Any &  _out_rValue 
) const

retrieves the value of a property given by handle

Parameters
_nHandlethe handle of the property whose value is to be retrieved
_out_rValueoutput parameter taking the property value
Exceptions
UnknownPropertyExceptionif the given handle does not denote a property in the bag

Definition at line 169 of file propertybag.cxx.

References comphelper::OPropertyContainerHelper::getFastPropertyValue(), and hasPropertyByHandle().

Referenced by comphelper::OPropertyBag::getFastPropertyValue().

void comphelper::PropertyBag::getPropertyDefaultByHandle ( sal_Int32  _nHandle,
css::uno::Any &  _out_rValue 
) const

returns the default value for a property given by handle

The default value of a property is its initial value, as passed to ->addProperty.

Parameters
_nHandlehandle of the property whose default value is to be obtained
_out_rValuethe default value
Exceptions
UnknownPropertyExceptionif the given handle does not denote a property in the bag

Definition at line 197 of file propertybag.cxx.

References hasPropertyByHandle(), and m_pImpl.

Referenced by comphelper::OPropertyBag::getPropertyDefaultByHandle().

bool comphelper::PropertyBag::hasPropertyByHandle ( sal_Int32  _nHandle) const
inline

determines whether a property with a given handle is part of the bag

Definition at line 212 of file propertybag.hxx.

Referenced by convertFastPropertyValue(), comphelper::OPropertyBag::findFreeHandle(), getFastPropertyValue(), getPropertyDefaultByHandle(), and setFastPropertyValue().

bool comphelper::PropertyBag::hasPropertyByName ( const OUString &  _rName) const
inline

determines whether a property with a given name is part of the bag

Definition at line 205 of file propertybag.hxx.

void comphelper::PropertyBag::removeProperty ( const OUString &  _rName)

removes a property from the bag

Parameters
_rNamethe name of the to-be-removed property.
Exceptions
UnknownPropertyExceptionif the bag does not contain a property with the given name
NotRemoveableExceptionif the property with the given name is not removable, as indicated by the property attributes used in a previous addProperty call.

Definition at line 155 of file propertybag.cxx.

References comphelper::OPropertyContainerHelper::getProperty(), m_pImpl, Property, and comphelper::OPropertyContainerHelper::revokeProperty().

Referenced by comphelper::OPropertyBag::removeProperty().

void comphelper::PropertyBag::setAllowEmptyPropertyName ( bool  i_isAllowed)

allow adding property with empty string as name (by default, such names are rejected with IllegalActionException).

Parameters
i_isAllowediff true, empty property name will be allowed

Definition at line 69 of file propertybag.cxx.

References m_pImpl.

void comphelper::PropertyBag::setFastPropertyValue ( sal_Int32  _nHandle,
const css::uno::Any &  _rValue 
)

sets a new value for a property given by handle

Exceptions
UnknownPropertyExceptionif the given handle does not denote a property in the bag

Definition at line 188 of file propertybag.cxx.

References hasPropertyByHandle(), and comphelper::OPropertyContainerHelper::setFastPropertyValue().

Referenced by comphelper::OPropertyBag::setFastPropertyValue_NoBroadcast().

Member Data Documentation

::std::unique_ptr< PropertyBag_Impl > comphelper::PropertyBag::m_pImpl
private

The documentation for this class was generated from the following files: