LibreOffice Module xmloff (master)  1
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
xmloff::OPropertyExport Class Reference

provides export related tools for attribute handling More...

#include <propertyexport.hxx>

Inheritance diagram for xmloff::OPropertyExport:
[legend]
Collaboration diagram for xmloff::OPropertyExport:
[legend]

Public Member Functions

 OPropertyExport (IFormsExportContext &_rContext, const css::uno::Reference< css::beans::XPropertySet > &_rxProps)
 constructs an object capable of handling attributes for export More...
 
template<typename T >
void exportRemainingPropertiesSequence (Any const &value, token::XMLTokenEnum eValueAttName)
 

Protected Member Functions

void examinePersistence ()
 examines a property set given for all properties which's value are to made persistent More...
 
template<typename T >
void exportRemainingPropertiesSequence (css::uno::Any const &value, token::XMLTokenEnum eValueAttName)
 
void exportRemainingProperties ()
 
void exportedProperty (const OUString &_rPropertyName)
 indicates that a property has been handled by a derived class, without using the helper methods of this class. More...
 
void exportStringPropertyAttribute (const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName)
 add an attribute which is represented by a string property to the export context More...
 
void exportBooleanPropertyAttribute (const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const BoolAttrFlags _nBooleanAttributeFlags)
 add an attribute which is represented by a boolean property to the export context More...
 
void exportInt16PropertyAttribute (const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const sal_Int16 _nDefault, const bool force=false)
 add an attribute which is represented by a sal_Int16 property to the export context More...
 
void exportInt32PropertyAttribute (const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const sal_Int32 _nDefault)
 add an attribute which is represented by a sal_Int32 property to the export context More...
 
template<typename EnumT >
void exportEnumPropertyAttribute (const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const SvXMLEnumMapEntry< EnumT > *_pValueMap, const EnumT _nDefault, const bool _bVoidDefault=false)
 add an attribute which is represented by an enum property to the export context More...
 
void exportEnumPropertyAttributeImpl (const sal_uInt16 _nNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName, const SvXMLEnumMapEntry< sal_uInt16 > *_pValueMap, const sal_uInt16 _nDefault, const bool _bVoidDefault)
 
void exportTargetFrameAttribute ()
 add the hlink:target-frame attribute to the export context. More...
 
void exportTargetLocationAttribute (bool _bAddType)
 add the form:href attribute to the export context. More...
 
void exportImageDataAttribute ()
 add the form:image attribute to the export context. More...
 
void flagStyleProperties ()
 flag the style properties as 'already exported' More...
 
void exportGenericPropertyAttribute (const sal_uInt16 _nAttributeNamespaceKey, const char *_pAttributeName, const char *_pPropertyName)
 add an arbitrary attribute extracted from an arbitrary property to the export context More...
 
void exportStringSequenceAttribute (const sal_uInt16 _nAttributeNamespaceKey, const char *_pAttributeName, const OUString &_rPropertyName)
 exports a property value, which is a string sequence, as attribute More...
 
bool shouldExportProperty (const OUString &i_propertyName) const
 determines whether the given property is to be exported More...
 
OUString implConvertAny (const css::uno::Any &_rValue)
 tries to convert an arbitrary <type scope="com.sun:star.uno">Any</type> into an string More...
 
void AddAttribute (sal_uInt16 _nPrefix, const char *_pName, const OUString &_rValue)
 
void AddAttribute (sal_uInt16 _nPrefix, const OUString &_rName, const OUString &_rValue)
 
void AddAttribute (sal_uInt16 _nPrefix,::xmloff::token::XMLTokenEnum _eName, const OUString &_rValue)
 
void AddAttribute (sal_uInt16 _nPrefix,::xmloff::token::XMLTokenEnum _eName,::xmloff::token::XMLTokenEnum _eValue)
 
void dbg_implCheckProperty (const OUString &_rPropertyName, const css::uno::Type *_pType)
 check a given property set for the existence and type correctness of a given property More...
 

Static Protected Member Functions

::xmloff::token::XMLTokenEnum implGetPropertyXMLType (const css::uno::Type &_rType)
 

Protected Attributes

IFormsExportContextm_rContext
 
const css::uno::Reference< css::beans::XPropertySetm_xProps
 
const css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertyInfo
 
const css::uno::Reference< css::beans::XPropertyState > m_xPropertyState
 
OUString m_sValueTrue
 
OUString m_sValueFalse
 

Private Member Functions

void exportRelativeTargetLocation (const OUString &_sPropertyName, CCAFlags _nProperty, bool _bAddType)
 

Private Attributes

std::set< OUString > m_aRemainingProps
 

Detailed Description

provides export related tools for attribute handling

(The name is somewhat misleading. It's not only a PropertyExport, but in real an ElementExport. Anyway.)

Definition at line 61 of file propertyexport.hxx.

Constructor & Destructor Documentation

xmloff::OPropertyExport::OPropertyExport ( IFormsExportContext _rContext,
const css::uno::Reference< css::beans::XPropertySet > &  _rxProps 
)

constructs an object capable of handling attributes for export

Parameters
_rContextthe export context to which's attribute list the property translation should be added
m_xControlthe property set to be exported

Definition at line 59 of file propertyexport.cxx.

References aBuffer, sax::Converter::convertBool(), examinePersistence(), m_rContext, m_sValueFalse, m_sValueTrue, m_xPropertyInfo, and m_xProps.

Member Function Documentation

void xmloff::OPropertyExport::AddAttribute ( sal_uInt16  _nPrefix,
const char *  _pName,
const OUString &  _rValue 
)
protected
void xmloff::OPropertyExport::AddAttribute ( sal_uInt16  _nPrefix,
const OUString &  _rName,
const OUString &  _rValue 
)
protected
void xmloff::OPropertyExport::AddAttribute ( sal_uInt16  _nPrefix,
::xmloff::token::XMLTokenEnum  _eName,
const OUString &  _rValue 
)
protected
void xmloff::OPropertyExport::AddAttribute ( sal_uInt16  _nPrefix,
::xmloff::token::XMLTokenEnum  _eName,
::xmloff::token::XMLTokenEnum  _eValue 
)
protected
void xmloff::OPropertyExport::dbg_implCheckProperty ( const OUString &  _rPropertyName,
const css::uno::Type *  _pType 
)
protected

check a given property set for the existence and type correctness of a given property

This method is available in the non-product version only.

Parameters
_rPropertyNamethe name of the property to ask the control model for
_pTypethe expected type of the property. May be NULL, in this case no type check is made.
Returns
sal_True, if the property exists and is of the correct type

Definition at line 660 of file propertyexport.cxx.

References Exception, m_xPropertyInfo, Property, SAL_WARN, and TOOLS_WARN_EXCEPTION.

void xmloff::OPropertyExport::examinePersistence ( )
protected

examines a property set given for all properties which's value are to made persistent

upon return the <method>m_aRemainingProps</method> will be filled with the names of all properties which need to be stored

Definition at line 220 of file propertyexport.cxx.

References aProperties, m_aRemainingProps, and m_xPropertyInfo.

Referenced by OPropertyExport().

void xmloff::OPropertyExport::exportBooleanPropertyAttribute ( const sal_uInt16  _nNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName,
const BoolAttrFlags  _nBooleanAttributeFlags 
)
protected

add an attribute which is represented by a boolean property to the export context

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace (it's added automatically)
_pPropertyNamethe name of the property to ask the control for
_nBooleanAttributeFlagsspecifies the default and the "alignment" (inverse semantics) of the boolean property

Definition at line 260 of file propertyexport.cxx.

References AddAttribute(), Any, DBG_CHECK_PROPERTY_NO_TYPE, DefaultTrue, DefaultVoid, exportedProperty(), InverseSemantics, m_sValueFalse, m_sValueTrue, and m_xProps.

Referenced by xmloff::OFormExport::exportAttributes(), xmloff::OControlExport::exportCommonControlAttributes(), xmloff::OControlExport::exportDatabaseAttributes(), and xmloff::OControlExport::exportSpecialAttributes().

void xmloff::OPropertyExport::exportedProperty ( const OUString &  _rPropertyName)
inlineprotected

indicates that a property has been handled by a derived class, without using the helper methods of this class.

Calling this method is necessary in case you use the suggested mechanism for the generic export of properties. This means that you want to use <method>exportRemainingProperties</method>, which exports all properties which need to ('cause they haven't been exported with one of the other type-specific methods).

In this case you should call exportedProperty for every property you export yourself, so the property will be flagged as already handled

Definition at line 118 of file propertyexport.hxx.

Referenced by xmloff::OFormExport::exportAttributes(), exportBooleanPropertyAttribute(), xmloff::OControlExport::exportCommonControlAttributes(), exportEnumPropertyAttributeImpl(), xmloff::OControlExport::exportGenericHandlerAttributes(), exportGenericPropertyAttribute(), xmloff::OControlExport::exportImagePositionAttributes(), exportInt16PropertyAttribute(), exportInt32PropertyAttribute(), xmloff::OControlExport::exportListSourceAsAttribute(), exportRelativeTargetLocation(), xmloff::OColumnExport::exportServiceNameAttribute(), xmloff::OControlExport::exportSpecialAttributes(), exportStringPropertyAttribute(), exportStringSequenceAttribute(), xmloff::OControlExport::exportSubTags(), exportTargetFrameAttribute(), and flagStyleProperties().

template<typename EnumT >
void xmloff::OPropertyExport::exportEnumPropertyAttribute ( const sal_uInt16  _nNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName,
const SvXMLEnumMapEntry< EnumT > *  _pValueMap,
const EnumT  _nDefault,
const bool  _bVoidDefault = false 
)
inlineprotected

add an attribute which is represented by an enum property to the export context

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace (it's added automatically)
_pPropertyNamethe name of the property to ask the control for
_pValueMapthe map to use when converting the property value to an attribute value
_nDefaultthe default of the attribute. If the current property value equals this default, no attribute is added.

Definition at line 214 of file propertyexport.hxx.

References exportEnumPropertyAttributeImpl().

Referenced by xmloff::OFormExport::exportAttributes(), xmloff::OControlExport::exportCommonControlAttributes(), xmloff::OControlExport::exportDatabaseAttributes(), and xmloff::OControlExport::exportSpecialAttributes().

void xmloff::OPropertyExport::exportEnumPropertyAttributeImpl ( const sal_uInt16  _nNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName,
const SvXMLEnumMapEntry< sal_uInt16 > *  _pValueMap,
const sal_uInt16  _nDefault,
const bool  _bVoidDefault 
)
protected
void xmloff::OPropertyExport::exportGenericPropertyAttribute ( const sal_uInt16  _nAttributeNamespaceKey,
const char *  _pAttributeName,
const char *  _pPropertyName 
)
protected

add an arbitrary attribute extracted from an arbitrary property to the export context

The current value of the property specified with <arg>_pPropertyName</arg> is taken and converted into a string, no matter what type it has. (Okay, there are the usual limitations: We know Date, Datetime, double, integer ... to name just a few).

In case the property value is <NULL> (void), no attribute is added

In case the property value is an empty string, and the property is a not allowed to be <NULL> (void), no attribute is added

In case the property value is a sequence of any type, no attribute is added, 'cause sequences can't be transported as attribute. In the debug version, an additional assertion will occur if you nonetheless try to do this.

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace (it's added automatically)
_pPropertyNamethe name of the property to ask the object for

Definition at line 443 of file propertyexport.cxx.

References AddAttribute(), Any, DBG_CHECK_PROPERTY_ASCII_NO_TYPE, exportedProperty(), implConvertAny(), m_xPropertyInfo, m_xProps, and Property.

Referenced by xmloff::OControlExport::exportCommonControlAttributes(), and xmloff::OControlExport::exportSpecialAttributes().

void xmloff::OPropertyExport::exportImageDataAttribute ( )
inlineprotected

add the form:image attribute to the export context.

The value of this attribute is extracted from the ImageURL property of the object given.

The property needs a special handling because the URL's need to be made relative

Definition at line 261 of file propertyexport.hxx.

References exportRelativeTargetLocation(), ImageData, and PROPERTY_GRAPHIC.

Referenced by xmloff::OControlExport::exportCommonControlAttributes().

void xmloff::OPropertyExport::exportInt16PropertyAttribute ( const sal_uInt16  _nNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName,
const sal_Int16  _nDefault,
const bool  force = false 
)
protected

add an attribute which is represented by a sal_Int16 property to the export context

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace (it's added automatically)
_pPropertyNamethe name of the property to ask the control for
_nDefaultthe default of the attribute. See force parameter.
forceif true and the property is not set or does not contain a sal_Int16, then _nDefault is written out. if false and the current property value equals _nDefault, then no attribute is added.

Definition at line 298 of file propertyexport.cxx.

References AddAttribute(), DBG_CHECK_PROPERTY, exportedProperty(), and m_xProps.

Referenced by xmloff::OControlExport::exportCommonControlAttributes(), and xmloff::OControlExport::exportDatabaseAttributes().

void xmloff::OPropertyExport::exportInt32PropertyAttribute ( const sal_uInt16  _nNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName,
const sal_Int32  _nDefault 
)
protected

add an attribute which is represented by a sal_Int32 property to the export context

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace (it's added automatically)
_pPropertyNamethe name of the property to ask the control for
_nDefaultthe default of the attribute. If the current property value equals this default, no attribute is added.

Definition at line 318 of file propertyexport.cxx.

References AddAttribute(), DBG_CHECK_PROPERTY, exportedProperty(), and m_xProps.

Referenced by xmloff::OControlExport::exportSpecialAttributes().

void xmloff::OPropertyExport::exportRelativeTargetLocation ( const OUString &  _sPropertyName,
CCAFlags  _nProperty,
bool  _bAddType 
)
private
void xmloff::OPropertyExport::exportRemainingProperties ( )
protected
template<typename T >
void xmloff::OPropertyExport::exportRemainingPropertiesSequence ( Any const &  value,
token::XMLTokenEnum  eValueAttName 
)
template<typename T >
void xmloff::OPropertyExport::exportRemainingPropertiesSequence ( css::uno::Any const &  value,
token::XMLTokenEnum  eValueAttName 
)
protected
void xmloff::OPropertyExport::exportStringPropertyAttribute ( const sal_uInt16  _nNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName 
)
protected

add an attribute which is represented by a string property to the export context

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace
_pPropertyNamethe name of the property to ask the control for

Definition at line 238 of file propertyexport.cxx.

References AddAttribute(), DBG_CHECK_PROPERTY, exportedProperty(), and m_xProps.

Referenced by xmloff::OColumnExport::exportAttributes(), xmloff::OFormExport::exportAttributes(), xmloff::OControlExport::exportCommonControlAttributes(), xmloff::OControlExport::exportDatabaseAttributes(), xmloff::OControlExport::exportOuterAttributes(), and xmloff::OControlExport::exportSpecialAttributes().

void xmloff::OPropertyExport::exportStringSequenceAttribute ( const sal_uInt16  _nAttributeNamespaceKey,
const char *  _pAttributeName,
const OUString &  _rPropertyName 
)
protected

exports a property value, which is a string sequence, as attribute

The elements of the string sequence given are quoted and concatenated, with the characters used for this to be chosen by the caller

If you use the quote character, no check (except assertions) is made if one of the list items contains the quote character

If you don't use the quote character, no check (except assertions) is made if one of the list items contains the separator character (which would be deadly when reimporting the string)

Parameters
_nNamespaceKeythe key of the namespace to use for the attribute name. Is used with the namespace map provided by the export context.
_pAttributeNamethe name of the attribute to add. Must not contain any namespace (it's added automatically)
_pPropertyNamethe name of the property to ask the object for

Definition at line 471 of file propertyexport.cxx.

References AddAttribute(), DBG_CHECK_PROPERTY, exportedProperty(), m_xProps, and sQuote.

Referenced by xmloff::OFormExport::exportAttributes().

void xmloff::OPropertyExport::exportTargetFrameAttribute ( )
protected

add the hlink:target-frame attribute to the export context.

The value of this attribute is extracted from the TargetFrame property of the object given.

The property needs a special handling because conflicts between the default values for the attribute and the property.

Definition at line 372 of file propertyexport.cxx.

References AddAttribute(), DBG_CHECK_PROPERTY, exportedProperty(), xmloff::OAttributeMetaData::getCommonControlAttributeName(), xmloff::OAttributeMetaData::getCommonControlAttributeNamespace(), comphelper::getString(), m_xProps, PROPERTY_TARGETFRAME, and TargetFrame.

Referenced by xmloff::OFormExport::exportAttributes(), and xmloff::OControlExport::exportCommonControlAttributes().

void xmloff::OPropertyExport::exportTargetLocationAttribute ( bool  _bAddType)
inlineprotected

add the form:href attribute to the export context.

The value of this attribute is extracted from the TargetURL property of the object given.

The property needs a special handling because the URL's need to be made relative

If _bAddType is set, an additional xlink:type="simple" attribute is also added.

Definition at line 253 of file propertyexport.hxx.

References exportRelativeTargetLocation(), PROPERTY_TARGETURL, and TargetLocation.

Referenced by xmloff::OFormExport::exportAttributes(), and xmloff::OControlExport::exportCommonControlAttributes().

void xmloff::OPropertyExport::flagStyleProperties ( )
protected

flag the style properties as 'already exported'

We don't have style support right now, so the only thing the method does is removing the style-relevant properties from the list of yet-to-be-exported properties (<member>m_aRemainingProps</member>)

Definition at line 419 of file propertyexport.cxx.

References exportedProperty(), xmloff::IFormsExportContext::getStylePropertyMapper(), i, m_rContext, PROPERTY_DATEFORMAT, PROPERTY_FONT, and PROPERTY_TIMEFORMAT.

Referenced by xmloff::OControlExport::exportInnerAttributes().

OUString xmloff::OPropertyExport::implConvertAny ( const css::uno::Any &  _rValue)
protected

tries to convert an arbitrary <type scope="com.sun:star.uno">Any</type> into an string

If the type contained in the Any is not supported, the returned string will be empty. In the debug version, an additional assertion occurs.

Parameters
_rValuethe value to convert

Definition at line 516 of file propertyexport.cxx.

References aBuffer, sax::Converter::convertDouble(), DateTime::EMPTY, Date::EMPTY, getBOOL(), Date::GetDate(), getDouble(), getINT32(), getINT64(), tools::Time::hourPerDay, m_sValueFalse, m_sValueTrue, tools::Time::minutePerDay, tools::Time::nanoSecPerDay, nValue, and tools::Time::secondPerDay.

Referenced by exportGenericPropertyAttribute(), exportRemainingProperties(), and exportRemainingPropertiesSequence().

token::XMLTokenEnum xmloff::OPropertyExport::implGetPropertyXMLType ( const css::uno::Type &  _rType)
staticprotected
Returns
token which can be used in the form:property element's type attribute to describe the type of a value.
Possible types returned are
  • boolean: <arg>_rValue</arg> was interpreted as boolean value before converting it into a string
  • float: <arg>_rValue</arg> was interpreted as 64 bit floating point 16bit integer, 32bit integer or 64 bit integer value before converting it into a string
  • string: <arg>_rValue</arg> did not need any conversion as it already was a string
If the type is not convertible, float is returned

Definition at line 605 of file propertyexport.cxx.

References xmloff::token::XML_BOOLEAN, xmloff::token::XML_FLOAT, and xmloff::token::XML_STRING.

Referenced by exportRemainingProperties().

bool xmloff::OPropertyExport::shouldExportProperty ( const OUString &  i_propertyName) const
protected

determines whether the given property is to be exported

Currently, the method simply checks whether the property's state is not PropertyState.DEFAULT, or whether the property is a dynamic property (i.e. added via an XPropertyContainer). So, take care when using the method - the heuristics is not applicable for all properties.

Definition at line 78 of file propertyexport.cxx.

References m_xPropertyInfo, and m_xPropertyState.

Referenced by xmloff::OControlExport::exportGenericHandlerAttributes(), and exportRemainingProperties().

Member Data Documentation

std::set<OUString> xmloff::OPropertyExport::m_aRemainingProps
private

Definition at line 64 of file propertyexport.hxx.

Referenced by examinePersistence(), and exportRemainingProperties().

IFormsExportContext& xmloff::OPropertyExport::m_rContext
protected
OUString xmloff::OPropertyExport::m_sValueFalse
protected
OUString xmloff::OPropertyExport::m_sValueTrue
protected
const css::uno::Reference< css::beans::XPropertySetInfo > xmloff::OPropertyExport::m_xPropertyInfo
protected
const css::uno::Reference< css::beans::XPropertyState > xmloff::OPropertyExport::m_xPropertyState
protected

Definition at line 77 of file propertyexport.hxx.

Referenced by shouldExportProperty().

const css::uno::Reference< css::beans::XPropertySet > xmloff::OPropertyExport::m_xProps
protected

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