LibreOffice Module xmloff (master)  1
Public Member Functions | Private Attributes | List of all members
MultiPropertySetHelper Class Reference

The MultiPropertySetHelper performs the following functions: More...

#include <MultiPropertySetHelper.hxx>

Public Member Functions

 MultiPropertySetHelper (const char **pNames)
 
 ~MultiPropertySetHelper ()
 
void hasProperties (const css::uno::Reference< css::beans::XPropertySetInfo > &)
 Call hasPropertiesByName for the provided XPropertySetInfo and build list of allowed properties. More...
 
bool checkedProperties ()
 Return whether hasProperties was called (i.e. More...
 
void getValues (const css::uno::Reference< css::beans::XMultiPropertySet > &)
 Get values from the XMultiPropertySet. More...
 
void getValues (const css::uno::Reference< css::beans::XPropertySet > &)
 Get values from the XPropertySet. More...
 
const css::uno::Any & getValue (sal_Int16 nIndex)
 Get a value from the values array. More...
 
bool hasProperty (sal_Int16 nIndex)
 Find out if this property is supported. More...
 
const css::uno::Any & getValue (sal_Int16 nIndex, const css::uno::Reference< css::beans::XPropertySet > &, bool bTryMulti=false)
 Get a value from the XPropertySet on demand. More...
 
const css::uno::Any & getValue (sal_Int16 nIndex, const css::uno::Reference< css::beans::XMultiPropertySet > &)
 Get a value from the XMultiPropertySet on demand. More...
 
void resetValues ()
 

Private Attributes

std::unique_ptr< OUString[]> pPropertyNames
 names of all properties More...
 
sal_Int16 nLength
 length of pPropertyNames array More...
 
css::uno::Sequence< OUString > aPropertySequence
 the sequence of property names that the current (multi) property set implementation supports More...
 
std::unique_ptr< sal_Int16[]> pSequenceIndex
 an array of indices that maps from pPropertyNames indices to aPropertySequence indices More...
 
css::uno::Sequence< css::uno::Any > aValues
 the last set of values retrieved by getValues More...
 
const css::uno::Any * pValues
 result of aValues.getConstArray() More...
 
css::uno::Any aEmptyAny
 an empty Any More...
 

Detailed Description

The MultiPropertySetHelper performs the following functions:

Given a list of property names (as char** or OUString*), it can query an XMultiPropertySet (or XPropertySet) which of these properties it supports (method hasProperties(...)). The properties MUST be sorted alphabetically.

Then, the X(Multi)PropertySet can be queried for values, and only the supported properties are queried. (method getValues(...)) The values are stored in the helper itself.

Finally, each property can be queried for existence (method hasProperty(...)) or its value (method (getValue(...))).

After some initial preparation (hasProperties, getValues) the MultiPropertySetHelper can be used similarly to an XPropertySet in that you can query the values in the places where you need them. However, if an XMultiPropertySet is supplied, the queries are more efficient, often significantly so.

Definition at line 55 of file MultiPropertySetHelper.hxx.

Constructor & Destructor Documentation

MultiPropertySetHelper::MultiPropertySetHelper ( const char **  pNames)

Definition at line 36 of file MultiPropertySetHelper.cxx.

References i, nLength, pPropertyNames, and pValues.

MultiPropertySetHelper::~MultiPropertySetHelper ( )

Definition at line 54 of file MultiPropertySetHelper.cxx.

References pValues.

Member Function Documentation

bool MultiPropertySetHelper::checkedProperties ( )

Return whether hasProperties was called (i.e.

if we are ready to call getValues)

Definition at line 97 of file MultiPropertySetHelper.cxx.

References pSequenceIndex.

Referenced by XMLTextParagraphExport::exportParagraph().

const css::uno::Any & MultiPropertySetHelper::getValue ( sal_Int16  nIndex)
inline

Get a value from the values array.

May only be called after getValues() was called.

Definition at line 166 of file MultiPropertySetHelper.hxx.

References aEmptyAny, assert(), nIndex, nLength, pSequenceIndex, and pValues.

Referenced by XMLTextParagraphExport::exportParagraph().

const css::uno::Any& MultiPropertySetHelper::getValue ( sal_Int16  nIndex,
const css::uno::Reference< css::beans::XPropertySet > &  ,
bool  bTryMulti = false 
)

Get a value from the XPropertySet on demand.

If neither getValues nor getValueOnDemand has been called already after the last call to resetValues, the values are retrieved using getValues. Otherwise the value already retrieved is returned. In case XMultiPropertySet is supported by the XPropertySet and bTryMult is set, the XMultiPropertySet is used to get the values.

const css::uno::Any& MultiPropertySetHelper::getValue ( sal_Int16  nIndex,
const css::uno::Reference< css::beans::XMultiPropertySet > &   
)

Get a value from the XMultiPropertySet on demand.

If neither getValues nor getValueOnDemand has been called already after the last call to resetValues, the values are retrieved using getValues. Otherwise the value already retrieved is returned. In case XMultiPropertySet is supported by the XPropertySet, XMultiPropertySet is used to get the values.

void MultiPropertySetHelper::getValues ( const css::uno::Reference< css::beans::XMultiPropertySet > &  )

Get values from the XMultiPropertySet.

May only be called after hasProperties() was called for the appropriate XPropertySetInfo.

void MultiPropertySetHelper::getValues ( const css::uno::Reference< css::beans::XPropertySet > &  )

Get values from the XPropertySet.

This can be much slower than getValues( const Reference<XMultiPropertySet& ) and hence should be avoided.

May only be called after hasProperties() was called for the appropriate XPropertySetInfo.

void MultiPropertySetHelper::hasProperties ( const css::uno::Reference< css::beans::XPropertySetInfo > &  )

Call hasPropertiesByName for the provided XPropertySetInfo and build list of allowed properties.

Definition at line 60 of file MultiPropertySetHelper.cxx.

References aPropertySequence, i, nIndex, nLength, pPropertyNames, pSequenceIndex, and SAL_WARN_IF.

Referenced by XMLTextParagraphExport::exportParagraph().

bool MultiPropertySetHelper::hasProperty ( sal_Int16  nIndex)
inline

Find out if this property is supported.

May only be called after hasProperties() was called.

Definition at line 177 of file MultiPropertySetHelper.hxx.

References assert(), nLength, and pSequenceIndex.

Referenced by XMLTextParagraphExport::exportParagraph().

void MultiPropertySetHelper::resetValues ( )
inline

Member Data Documentation

css::uno::Any MultiPropertySetHelper::aEmptyAny
private

an empty Any

Definition at line 78 of file MultiPropertySetHelper.hxx.

Referenced by getValue().

css::uno::Sequence< OUString > MultiPropertySetHelper::aPropertySequence
private

the sequence of property names that the current (multi) property set implementation supports

Definition at line 65 of file MultiPropertySetHelper.hxx.

Referenced by hasProperties().

css::uno::Sequence< css::uno::Any > MultiPropertySetHelper::aValues
private

the last set of values retrieved by getValues

Definition at line 72 of file MultiPropertySetHelper.hxx.

sal_Int16 MultiPropertySetHelper::nLength
private

length of pPropertyNames array

Definition at line 61 of file MultiPropertySetHelper.hxx.

Referenced by getValue(), hasProperties(), hasProperty(), and MultiPropertySetHelper().

std::unique_ptr<OUString[]> MultiPropertySetHelper::pPropertyNames
private

names of all properties

Definition at line 58 of file MultiPropertySetHelper.hxx.

Referenced by hasProperties(), and MultiPropertySetHelper().

std::unique_ptr<sal_Int16[]> MultiPropertySetHelper::pSequenceIndex
private

an array of indices that maps from pPropertyNames indices to aPropertySequence indices

Definition at line 69 of file MultiPropertySetHelper.hxx.

Referenced by checkedProperties(), getValue(), hasProperties(), and hasProperty().

const css::uno::Any* MultiPropertySetHelper::pValues
private

result of aValues.getConstArray()

Definition at line 75 of file MultiPropertySetHelper.hxx.

Referenced by getValue(), and ~MultiPropertySetHelper().


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