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

@descr 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 > xObject)
 @descr Create a handler of the property set of the given object. More...
 
template<class T >
void Add (const OUString &sName, T &rValue)
 @descr Add a property to handle. More...
 
bool GetProperties ()
 @descr 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)
 @descr Try to use the XMultiPropertySet interface to get the property values. More...
 
bool SingleGet (const css::uno::Sequence< OUString > &rNameList)
 @descr Try to use the XPropertySet interface to get the property values. More...
 

Private Attributes

::std::map< OUString, std::unique_ptr< PropertyWrapperBase >, OUStringComparisonaPropertyList
 @descr 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

@descr 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 119 of file MultiPropertySetHandler.hxx.

Constructor & Destructor Documentation

◆ MultiPropertySetHandler()

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

@descr 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 180 of file MultiPropertySetHandler.hxx.

Member Function Documentation

◆ Add()

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

@descr 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 137 of file MultiPropertySetHandler.hxx.

References aPropertyList, and sName.

Referenced by SchXMLExportHelper_Impl::exportAxes().

◆ GetProperties()

bool MultiPropertySetHandler::GetProperties ( )
inline

@descr 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 186 of file MultiPropertySetHandler.hxx.

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

Referenced by SchXMLExportHelper_Impl::exportAxes().

◆ MultiGet()

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

@descr 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 199 of file MultiPropertySetHandler.hxx.

References aPropertyList, i, and mxObject.

Referenced by GetProperties().

◆ SingleGet()

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

@descr 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 223 of file MultiPropertySetHandler.hxx.

References aPropertyList, i, and mxObject.

Referenced by GetProperties().

Member Data Documentation

◆ aPropertyList

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

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

It uses OUStringComparison for sorting the property names.

Definition at line 174 of file MultiPropertySetHandler.hxx.

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

◆ mxObject

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

The object from which to get the property values.

Definition at line 177 of file MultiPropertySetHandler.hxx.

Referenced by MultiGet(), and SingleGet().


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