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 62 of file MultiPropertySetHelper.hxx.

Constructor & Destructor Documentation

◆ MultiPropertySetHelper()

MultiPropertySetHelper::MultiPropertySetHelper ( const char **  pNames)

Definition at line 36 of file MultiPropertySetHelper.cxx.

References i, nLength, pPropertyNames, and pValues.

◆ ~MultiPropertySetHelper()

MultiPropertySetHelper::~MultiPropertySetHelper ( )

Definition at line 52 of file MultiPropertySetHelper.cxx.

References pValues.

Member Function Documentation

◆ checkedProperties()

bool MultiPropertySetHelper::checkedProperties ( )

Return whether hasProperties was called (i.e.

if we are ready to call getValues)

Definition at line 95 of file MultiPropertySetHelper.cxx.

References pSequenceIndex.

Referenced by XMLTextParagraphExport::exportParagraph().

◆ getValue() [1/3]

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 168 of file MultiPropertySetHelper.hxx.

References aEmptyAny, nIndex, nLength, pSequenceIndex, and pValues.

Referenced by XMLTextParagraphExport::exportParagraph().

◆ getValue() [2/3]

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.

◆ getValue() [3/3]

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.

◆ getValues() [1/2]

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.

◆ getValues() [2/2]

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.

◆ hasProperties()

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 58 of file MultiPropertySetHelper.cxx.

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

Referenced by XMLTextParagraphExport::exportParagraph().

◆ hasProperty()

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 178 of file MultiPropertySetHelper.hxx.

References nLength, and pSequenceIndex.

Referenced by XMLTextParagraphExport::exportParagraph().

◆ resetValues()

void MultiPropertySetHelper::resetValues ( )
inline

Definition at line 163 of file MultiPropertySetHelper.hxx.

References pValues.

Referenced by XMLTextParagraphExport::exportTextContentEnumeration().

Member Data Documentation

◆ aEmptyAny

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

an empty Any

Definition at line 85 of file MultiPropertySetHelper.hxx.

Referenced by getValue().

◆ aPropertySequence

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

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

Definition at line 72 of file MultiPropertySetHelper.hxx.

Referenced by hasProperties().

◆ aValues

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

the last set of values retrieved by getValues

Definition at line 79 of file MultiPropertySetHelper.hxx.

◆ nLength

sal_Int16 MultiPropertySetHelper::nLength
private

length of pPropertyNames array

Definition at line 68 of file MultiPropertySetHelper.hxx.

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

◆ pPropertyNames

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

names of all properties

Definition at line 65 of file MultiPropertySetHelper.hxx.

Referenced by hasProperties(), and MultiPropertySetHelper().

◆ pSequenceIndex

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

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

Definition at line 76 of file MultiPropertySetHelper.hxx.

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

◆ pValues

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

result of aValues.getConstArray()

Definition at line 82 of file MultiPropertySetHelper.hxx.

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


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