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

This class lets you get the values from an object that either supports the interface XPropertySet or XMultiPropertySet. More...

#include <MultiPropertySetHandler.hxx>

Public Member Functions

 MultiPropertySetHandler (css::uno::Reference< css::uno::XInterface > const &xObject)
 Create a handler of the property set of the given object. More...
 
template<class T >
void Add (const OUString &sName, T &rValue)
 Add a property to handle. More...
 
bool GetProperties ()
 Try to get the values for all properties added with the Add method. More...
 

Private Member Functions

bool MultiGet (const css::uno::Sequence< OUString > &rNameList)
 Try to use the XMultiPropertySet interface to get the property values. More...
 
bool SingleGet (const css::uno::Sequence< OUString > &rNameList)
 Try to use the XPropertySet interface to get the property values. More...
 

Private Attributes

::std::map< OUString, std::unique_ptr< PropertyWrapperBase >, OUStringComparisonaPropertyList
 STL map that maps from property names to polymorphic instances of PropertyWrapper. More...
 
css::uno::Reference< css::uno::XInterface > mxObject
 The object from which to get the property values. More...
 

Detailed Description

This class lets you get the values from an object that either supports the interface XPropertySet or XMultiPropertySet.

If it supports both interfaces then XMultiPropertySet is preferred.

Using it works in three steps.

  1. Create an instance and pass a reference to the object from which to get the property values.
  2. Make all properties whose values you want to get known to the object by using the Add method. This creates instances of a template class that stores the properties name and a reference to the variable in which to store its value.
  3. Finally call GetProperties to store the properties values into the variables specified in step 2. This uses either the XPropertySet or (preferred) the XMultiPropertySet interface.

Definition at line 118 of file MultiPropertySetHandler.hxx.

Constructor & Destructor Documentation

MultiPropertySetHandler::MultiPropertySetHandler ( css::uno::Reference< css::uno::XInterface > const &  xObject)
explicit

Create a handler of the property set of the given object.

Parameters
xObjectA reference to any of the object's interfaces. not necessarily XPropertySet or XMultiPropertySet. It is casted later to one of the two of them.

Definition at line 179 of file MultiPropertySetHandler.hxx.

Member Function Documentation

template<class T >
void MultiPropertySetHandler::Add ( const OUString &  sName,
T &  rValue 
)
inline

Add a property to handle.

The type given implicitly by the reference to a variable is used to create an instance of the PropertyWrapper template class.

Parameters
sNameName of the property.
rValueReference to a variable whose value is set by the call to GetProperties to the property's value.

Definition at line 136 of file MultiPropertySetHandler.hxx.

References aPropertyList, and XMLImageStyle::rValue.

Referenced by SchXMLExportHelper_Impl::exportAxes().

bool MultiPropertySetHandler::GetProperties ( )
inline

Try to get the values for all properties added with the Add method.

If possible it uses the XMultiPropertySet. If that fails (i.e. for an UnknownPropertyExcption) or if the interface is not supported it uses the XPropertySet interface.

Returns
If none of the two interfaces is supported or using them both fails then sal_False is returned. Else True is returned.

Definition at line 185 of file MultiPropertySetHandler.hxx.

References aPropertyList, i, MultiGet(), and SingleGet().

Referenced by SchXMLExportHelper_Impl::exportAxes().

bool MultiPropertySetHandler::MultiGet ( const css::uno::Sequence< OUString > &  rNameList)
inlineprivate

Try to use the XMultiPropertySet interface to get the property values.

Parameters
rNameListA precomputed and sorted sequence of OUStrings containing the properties names.
Returns
True if values could be derived.

Definition at line 197 of file MultiPropertySetHandler.hxx.

References aPropertyList, i, and mxObject.

Referenced by GetProperties().

bool MultiPropertySetHandler::SingleGet ( const css::uno::Sequence< OUString > &  rNameList)
inlineprivate

Try to use the XPropertySet interface to get the property values.

Parameters
rNameListA precomputed and sorted sequence of OUStrings containing the properties names.
Returns
True if values could be derived.

Definition at line 221 of file MultiPropertySetHandler.hxx.

References aPropertyList, i, and mxObject.

Referenced by GetProperties().

Member Data Documentation

::std::map< OUString, std::unique_ptr<PropertyWrapperBase>, OUStringComparison> MultiPropertySetHandler::aPropertyList
private

STL map that maps from property names to polymorphic instances of PropertyWrapper.

It uses OUStringComparison for sorting the property names.

Definition at line 173 of file MultiPropertySetHandler.hxx.

Referenced by Add(), GetProperties(), MultiGet(), and SingleGet().

css::uno::Reference< css::uno::XInterface> MultiPropertySetHandler::mxObject
private

The object from which to get the property values.

Definition at line 176 of file MultiPropertySetHandler.hxx.

Referenced by MultiGet(), and SingleGet().


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