diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-09 09:04:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-13 09:02:22 +0000 |
commit | 7e9857c2935bb2533806db4e71c6cd1e171c3478 (patch) | |
tree | d9f8a6d4f94e19f349b67141359cc7c49130b5fc /xmloff/source/forms | |
parent | 7c0e3d0b37131b12262d0f610505b3384923c4a1 (diff) |
templatize SvXMLEnumMapEntry
in preparation for "scoped UNO enums".
This is a little hacky: In order to limit the scope of this change,
the templated SvXMLEnumMapEntry struct actually has a fixed size field,
and we cast it to SvXMLEnumMapEntry<sal_uInt16>* in various
places, to avoid carrying the type param around.
Change-Id: Idfbc5561303c557598dd5564b7a7259ae5261d83
Reviewed-on: https://gerrit.libreoffice.org/34987
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/forms')
-rw-r--r-- | xmloff/source/forms/controlpropertyhdl.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/forms/elementexport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/forms/formattributes.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/forms/formattributes.hxx | 19 | ||||
-rw-r--r-- | xmloff/source/forms/formenums.cxx | 302 | ||||
-rw-r--r-- | xmloff/source/forms/formenums.hxx | 43 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.cxx | 8 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.hxx | 19 | ||||
-rw-r--r-- | xmloff/source/forms/propertyimport.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/propertyimport.hxx | 13 |
10 files changed, 227 insertions, 193 deletions
diff --git a/xmloff/source/forms/controlpropertyhdl.cxx b/xmloff/source/forms/controlpropertyhdl.cxx index 43e9d8760b6f..2b657689635d 100644 --- a/xmloff/source/forms/controlpropertyhdl.cxx +++ b/xmloff/source/forms/controlpropertyhdl.cxx @@ -124,7 +124,7 @@ namespace xmloff if (_rValue >>= nFontEmphasis) { // the type - sal_Int16 nType = nFontEmphasis & ~(awt::FontEmphasisMark::ABOVE | awt::FontEmphasisMark::BELOW); + sal_uInt16 nType = nFontEmphasis & ~(awt::FontEmphasisMark::ABOVE | awt::FontEmphasisMark::BELOW); // the position of the mark bool bBelow = 0 != (nFontEmphasis & awt::FontEmphasisMark::BELOW); @@ -184,7 +184,7 @@ namespace xmloff if (bSuccess) { nEmphasis |= bBelow ? awt::FontEmphasisMark::BELOW : awt::FontEmphasisMark::ABOVE; - _rValue <<= (sal_Int16)nEmphasis; + _rValue <<= nEmphasis; } return bSuccess; @@ -242,7 +242,7 @@ namespace xmloff { case STYLE: { - sal_Int16 nBorder = 0; + sal_uInt16 nBorder = 0; bSuccess = (_rValue >>= nBorder) && SvXMLUnitConverter::convertEnum( aOut, nBorder, aBorderTypeMap ); } diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 29d837bb347b..a2a1b10fc580 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -663,7 +663,7 @@ namespace xmloff OAttributeMetaData::getCommonControlAttributeName( CCAFlags::Orientation ), PROPERTY_ORIENTATION, aOrientationMap, - ScrollBarOrientation::HORIZONTAL + (sal_uInt16)ScrollBarOrientation::HORIZONTAL ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking @@ -1784,7 +1784,7 @@ namespace xmloff OUStringBuffer sBuffer; SvXMLUnitConverter::convertEnum( sBuffer, - (sal_uInt16)nLinkageType, + nLinkageType, aListLinkageMap ); diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx index fb04f93b9708..e69f984806de 100644 --- a/xmloff/source/forms/formattributes.cxx +++ b/xmloff/source/forms/formattributes.cxx @@ -247,9 +247,9 @@ namespace xmloff implAdd( _pAttributeName, _rPropertyName, ::cppu::UnoType<sal_Int32>::get(), OUString::number( _nAttributeDefault ) ); } - void OAttribute2Property::addEnumProperty( + void OAttribute2Property::addEnumPropertyImpl( const sal_Char* _pAttributeName, const OUString& _rPropertyName, - const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap, + const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap, const css::uno::Type* _pType) { OUStringBuffer aDefault; diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx index fcfab79fbde7..a5dd78959604 100644 --- a/xmloff/source/forms/formattributes.hxx +++ b/xmloff/source/forms/formattributes.hxx @@ -30,6 +30,7 @@ #include <xmloff/xmlnmspe.hxx> #include <o3tl/typed_flags_set.hxx> +template<typename EnumT> struct SvXMLEnumMapEntry; // flags for common control attributes @@ -280,8 +281,9 @@ namespace xmloff css::uno::Type aPropertyType; // the property type // entries which are special to some value types - const SvXMLEnumMapEntry* pEnumMap; // the enum map, if appliable - bool bInverseSemantics; // for booleans: attribute and property value have the same or an inverse semantics? + const SvXMLEnumMapEntry<sal_uInt16>* + pEnumMap; // the enum map, if applicable + bool bInverseSemantics; // for booleans: attribute and property value have the same or an inverse semantics? AttributeAssignment() : pEnumMap(nullptr), bInverseSemantics(false) { } }; @@ -373,12 +375,21 @@ namespace xmloff @param _pType the type of the property. May be NULL, in this case 32bit integer is assumed. */ + template<typename EnumT> void addEnumProperty( const sal_Char* _pAttributeName, const OUString& _rPropertyName, - const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap, - const css::uno::Type* _pType = nullptr); + const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry<EnumT>* _pValueMap, + const css::uno::Type* _pType = nullptr) + { + addEnumPropertyImpl(_pAttributeName, _rPropertyName, _nAttributeDefault, + reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(_pValueMap), _pType); + } private: + void addEnumPropertyImpl( + const sal_Char* _pAttributeName, const OUString& _rPropertyName, + const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap, + const css::uno::Type* _pType = nullptr); /// some common code for the various add*Property methods AttributeAssignment& implAdd( const sal_Char* _pAttributeName, const OUString& _rPropertyName, diff --git a/xmloff/source/forms/formenums.cxx b/xmloff/source/forms/formenums.cxx index fd5dc8384f42..30b13cdb82e9 100644 --- a/xmloff/source/forms/formenums.cxx +++ b/xmloff/source/forms/formenums.cxx @@ -39,162 +39,154 @@ namespace xmloff { - using namespace ::com::sun::star::form; - using namespace ::com::sun::star::sdb; - using namespace ::com::sun::star::awt; - using namespace ::com::sun::star; - using namespace ::xmloff::token; +using namespace ::com::sun::star::form; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star; +using namespace ::xmloff::token; - // FormSubmitEncoding - const SvXMLEnumMapEntry aSubmitEncodingMap[] = - { - { XML_APPLICATION_X_WWW_FORM_URLENCODED, FormSubmitEncoding_URL }, - { XML_MULTIPART_FORMDATA, FormSubmitEncoding_MULTIPART }, - { XML_APPLICATION_TEXT, FormSubmitEncoding_TEXT }, - { XML_TOKEN_INVALID, 0 } - }; - // FormSubmitMethod - const SvXMLEnumMapEntry aSubmitMethodMap[] = - { - { XML_GET, FormSubmitMethod_GET }, - { XML_POST, FormSubmitMethod_POST }, - { XML_TOKEN_INVALID, 0 } - }; - - // CommandType - const SvXMLEnumMapEntry aCommandTypeMap[] = - { - { XML_TABLE, CommandType::TABLE }, - { XML_QUERY, CommandType::QUERY }, - { XML_COMMAND, CommandType::COMMAND }, - { XML_TOKEN_INVALID, 0 } - }; - // NavigationBarMode - const SvXMLEnumMapEntry aNavigationTypeMap[] = - { - { XML_NONE, NavigationBarMode_NONE }, - { XML_CURRENT, NavigationBarMode_CURRENT }, - { XML_PARENT, NavigationBarMode_PARENT }, - { XML_TOKEN_INVALID, 0 } - }; - // TabulatorCycle - const SvXMLEnumMapEntry aTabulatorCycleMap[] = - { - { XML_RECORDS, TabulatorCycle_RECORDS }, - { XML_CURRENT, TabulatorCycle_CURRENT }, - { XML_PAGE, TabulatorCycle_PAGE }, - { XML_TOKEN_INVALID, 0 } - }; - // FormButtonType - const SvXMLEnumMapEntry aFormButtonTypeMap[] = - { - { XML_PUSH, FormButtonType_PUSH }, - { XML_SUBMIT, FormButtonType_SUBMIT }, - { XML_RESET, FormButtonType_RESET }, - { XML_URL, FormButtonType_URL }, - { XML_TOKEN_INVALID, 0 } - }; - // ListSourceType - const SvXMLEnumMapEntry aListSourceTypeMap[] = - { - { XML_VALUE_LIST, ListSourceType_VALUELIST }, - { XML_TABLE, ListSourceType_TABLE }, - { XML_QUERY, ListSourceType_QUERY }, - { XML_SQL, ListSourceType_SQL }, - { XML_SQL_PASS_THROUGH, ListSourceType_SQLPASSTHROUGH }, - { XML_TABLE_FIELDS, ListSourceType_TABLEFIELDS }, - { XML_TOKEN_INVALID, 0 } - }; - // check state of a checkbox - const SvXMLEnumMapEntry aCheckStateMap[] = - { - { XML_UNCHECKED, TRISTATE_FALSE }, - { XML_CHECKED, TRISTATE_TRUE }, - { XML_UNKNOWN, TRISTATE_INDET }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aTextAlignMap[] = - { - { XML_START, awt::TextAlign::LEFT }, - { XML_CENTER, awt::TextAlign::CENTER }, - { XML_END, awt::TextAlign::RIGHT }, - { XML_JUSTIFY, (sal_uInt16)-1 }, - { XML_JUSTIFIED, (sal_uInt16)-1 }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aBorderTypeMap[] = - { - { XML_NONE, 0 }, - { XML_HIDDEN, 0 }, - { XML_SOLID, 2 }, - { XML_DOUBLE, 2 }, - { XML_DOTTED, 2 }, - { XML_DASHED, 2 }, - { XML_GROOVE, 1 }, - { XML_RIDGE, 1 }, - { XML_INSET, 1 }, - { XML_OUTSET, 1 }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aFontEmphasisMap[] = - { - { XML_NONE, awt::FontEmphasisMark::NONE }, - { XML_DOT, awt::FontEmphasisMark::DOT }, - { XML_CIRCLE, awt::FontEmphasisMark::CIRCLE }, - { XML_DISC, awt::FontEmphasisMark::DISC }, - { XML_ACCENT, awt::FontEmphasisMark::ACCENT }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aFontReliefMap[] = - { - { XML_NONE, FontRelief::NONE }, - { XML_ENGRAVED, FontRelief::ENGRAVED }, - { XML_EMBOSSED, FontRelief::EMBOSSED }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aListLinkageMap[] = - { - { XML_SELECTION, 0 }, - { XML_SELECTION_INDEXES, 1 }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aOrientationMap[] = - { - { XML_HORIZONTAL, ScrollBarOrientation::HORIZONTAL }, - { XML_VERTICAL, ScrollBarOrientation::VERTICAL }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aVisualEffectMap[] = - { - { XML_NONE, VisualEffect::NONE }, - { XML_3D, VisualEffect::LOOK3D }, - { XML_FLAT, VisualEffect::FLAT }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aImagePositionMap[] = - { - { XML_START, 0 }, - { XML_END, 1 }, - { XML_TOP, 2 }, - { XML_BOTTOM, 3 }, - { XML_CENTER, (sal_uInt16)-1 }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aImageAlignMap[] = - { - { XML_START, 0 }, - { XML_CENTER, 1 }, - { XML_END, 2 }, - { XML_TOKEN_INVALID, 0 } - }; - const SvXMLEnumMapEntry aScaleModeMap[] = - { - { XML_BACKGROUND_NO_REPEAT, ImageScaleMode::NONE }, - { XML_REPEAT, ImageScaleMode::NONE }, // repeating the image is not supported - { XML_STRETCH, ImageScaleMode::ANISOTROPIC }, - { XML_SCALE, ImageScaleMode::ISOTROPIC }, - { XML_TOKEN_INVALID, ImageScaleMode::NONE } - }; +const SvXMLEnumMapEntry<FormSubmitEncoding> aSubmitEncodingMap[] = +{ + { XML_APPLICATION_X_WWW_FORM_URLENCODED, FormSubmitEncoding_URL }, + { XML_MULTIPART_FORMDATA, FormSubmitEncoding_MULTIPART }, + { XML_APPLICATION_TEXT, FormSubmitEncoding_TEXT }, + { XML_TOKEN_INVALID, (FormSubmitEncoding)0 } +}; +const SvXMLEnumMapEntry<FormSubmitMethod> aSubmitMethodMap[] = +{ + { XML_GET, FormSubmitMethod_GET }, + { XML_POST, FormSubmitMethod_POST }, + { XML_TOKEN_INVALID, (FormSubmitMethod)0 } +}; +const SvXMLEnumMapEntry<sal_Int32> aCommandTypeMap[] = +{ + { XML_TABLE, CommandType::TABLE }, + { XML_QUERY, CommandType::QUERY }, + { XML_COMMAND, CommandType::COMMAND }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<NavigationBarMode> aNavigationTypeMap[] = +{ + { XML_NONE, NavigationBarMode_NONE }, + { XML_CURRENT, NavigationBarMode_CURRENT }, + { XML_PARENT, NavigationBarMode_PARENT }, + { XML_TOKEN_INVALID, (NavigationBarMode)0 } +}; +const SvXMLEnumMapEntry<TabulatorCycle> aTabulatorCycleMap[] = +{ + { XML_RECORDS, TabulatorCycle_RECORDS }, + { XML_CURRENT, TabulatorCycle_CURRENT }, + { XML_PAGE, TabulatorCycle_PAGE }, + { XML_TOKEN_INVALID, (TabulatorCycle)0 } +}; +const SvXMLEnumMapEntry<FormButtonType> aFormButtonTypeMap[] = +{ + { XML_PUSH, FormButtonType_PUSH }, + { XML_SUBMIT, FormButtonType_SUBMIT }, + { XML_RESET, FormButtonType_RESET }, + { XML_URL, FormButtonType_URL }, + { XML_TOKEN_INVALID, (FormButtonType)0 } +}; +const SvXMLEnumMapEntry<ListSourceType> aListSourceTypeMap[] = +{ + { XML_VALUE_LIST, ListSourceType_VALUELIST }, + { XML_TABLE, ListSourceType_TABLE }, + { XML_QUERY, ListSourceType_QUERY }, + { XML_SQL, ListSourceType_SQL }, + { XML_SQL_PASS_THROUGH, ListSourceType_SQLPASSTHROUGH }, + { XML_TABLE_FIELDS, ListSourceType_TABLEFIELDS }, + { XML_TOKEN_INVALID, (ListSourceType)0 } +}; +// check state of a checkbox +const SvXMLEnumMapEntry<TriState> aCheckStateMap[] = +{ + { XML_UNCHECKED, TRISTATE_FALSE }, + { XML_CHECKED, TRISTATE_TRUE }, + { XML_UNKNOWN, TRISTATE_INDET }, + { XML_TOKEN_INVALID, (TriState)0 } +}; +const SvXMLEnumMapEntry<sal_Int16> aTextAlignMap[] = +{ + { XML_START, (sal_uInt16)awt::TextAlign::LEFT }, + { XML_CENTER, (sal_uInt16)awt::TextAlign::CENTER }, + { XML_END, (sal_uInt16)awt::TextAlign::RIGHT }, + { XML_JUSTIFY, -1 }, + { XML_JUSTIFIED, -1 }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_uInt16> aBorderTypeMap[] = +{ + { XML_NONE, 0 }, + { XML_HIDDEN, 0 }, + { XML_SOLID, 2 }, + { XML_DOUBLE, 2 }, + { XML_DOTTED, 2 }, + { XML_DASHED, 2 }, + { XML_GROOVE, 1 }, + { XML_RIDGE, 1 }, + { XML_INSET, 1 }, + { XML_OUTSET, 1 }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_uInt16> aFontEmphasisMap[] = +{ + { XML_NONE, awt::FontEmphasisMark::NONE }, + { XML_DOT, awt::FontEmphasisMark::DOT }, + { XML_CIRCLE, awt::FontEmphasisMark::CIRCLE }, + { XML_DISC, awt::FontEmphasisMark::DISC }, + { XML_ACCENT, awt::FontEmphasisMark::ACCENT }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_uInt16> aFontReliefMap[] = +{ + { XML_NONE, FontRelief::NONE }, + { XML_ENGRAVED, FontRelief::ENGRAVED }, + { XML_EMBOSSED, FontRelief::EMBOSSED }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_Int16> aListLinkageMap[] = +{ + { XML_SELECTION, 0 }, + { XML_SELECTION_INDEXES, 1 }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_uInt16> aOrientationMap[] = +{ + { XML_HORIZONTAL, ScrollBarOrientation::HORIZONTAL }, + { XML_VERTICAL, ScrollBarOrientation::VERTICAL }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_Int16> aVisualEffectMap[] = +{ + { XML_NONE, VisualEffect::NONE }, + { XML_3D, VisualEffect::LOOK3D }, + { XML_FLAT, VisualEffect::FLAT }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_Int16> aImagePositionMap[] = +{ + { XML_START, 0 }, + { XML_END, 1 }, + { XML_TOP, 2 }, + { XML_BOTTOM, 3 }, + { XML_CENTER, -1 }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_uInt16> aImageAlignMap[] = +{ + { XML_START, 0 }, + { XML_CENTER, 1 }, + { XML_END, 2 }, + { XML_TOKEN_INVALID, 0 } +}; +const SvXMLEnumMapEntry<sal_uInt16> aScaleModeMap[] = +{ + { XML_BACKGROUND_NO_REPEAT, ImageScaleMode::NONE }, + { XML_REPEAT, ImageScaleMode::NONE }, // repeating the image is not supported + { XML_STRETCH, ImageScaleMode::ANISOTROPIC }, + { XML_SCALE, ImageScaleMode::ISOTROPIC }, + { XML_TOKEN_INVALID, 0 } +}; } // namespace xmloff diff --git a/xmloff/source/forms/formenums.hxx b/xmloff/source/forms/formenums.hxx index 6550c8ec90c5..7ed7dcf8acac 100644 --- a/xmloff/source/forms/formenums.hxx +++ b/xmloff/source/forms/formenums.hxx @@ -21,28 +21,35 @@ #define INCLUDED_XMLOFF_SOURCE_FORMS_FORMENUMS_HXX #include <xmloff/xmlement.hxx> +#include <com/sun/star/form/FormButtonType.hpp> +#include <com/sun/star/form/FormSubmitEncoding.hpp> +#include <com/sun/star/form/FormSubmitMethod.hpp> +#include <com/sun/star/form/ListSourceType.hpp> +#include <com/sun/star/form/NavigationBarMode.hpp> +#include <com/sun/star/form/TabulatorCycle.hpp> +#include <tools/gen.hxx> namespace xmloff { -extern const SvXMLEnumMapEntry aSubmitEncodingMap[]; -extern const SvXMLEnumMapEntry aSubmitMethodMap[]; -extern const SvXMLEnumMapEntry aCommandTypeMap[]; -extern const SvXMLEnumMapEntry aNavigationTypeMap[]; -extern const SvXMLEnumMapEntry aTabulatorCycleMap[]; -extern const SvXMLEnumMapEntry aFormButtonTypeMap[]; -extern const SvXMLEnumMapEntry aListSourceTypeMap[]; -extern const SvXMLEnumMapEntry aCheckStateMap[]; -extern const SvXMLEnumMapEntry aTextAlignMap[]; -extern const SvXMLEnumMapEntry aBorderTypeMap[]; -extern const SvXMLEnumMapEntry aFontEmphasisMap[]; -extern const SvXMLEnumMapEntry aFontReliefMap[]; -extern const SvXMLEnumMapEntry aListLinkageMap[]; -extern const SvXMLEnumMapEntry aOrientationMap[]; -extern const SvXMLEnumMapEntry aVisualEffectMap[]; -extern const SvXMLEnumMapEntry aImagePositionMap[]; -extern const SvXMLEnumMapEntry aImageAlignMap[]; -extern const SvXMLEnumMapEntry aScaleModeMap[]; +extern const SvXMLEnumMapEntry<css::form::FormSubmitEncoding> aSubmitEncodingMap[]; +extern const SvXMLEnumMapEntry<css::form::FormSubmitMethod> aSubmitMethodMap[]; +extern const SvXMLEnumMapEntry<sal_Int32> aCommandTypeMap[]; +extern const SvXMLEnumMapEntry<css::form::NavigationBarMode> aNavigationTypeMap[]; +extern const SvXMLEnumMapEntry<css::form::TabulatorCycle> aTabulatorCycleMap[]; +extern const SvXMLEnumMapEntry<css::form::FormButtonType> aFormButtonTypeMap[]; +extern const SvXMLEnumMapEntry<css::form::ListSourceType> aListSourceTypeMap[]; +extern const SvXMLEnumMapEntry<TriState> aCheckStateMap[]; +extern const SvXMLEnumMapEntry<sal_Int16> aTextAlignMap[]; +extern const SvXMLEnumMapEntry<sal_uInt16> aBorderTypeMap[]; +extern const SvXMLEnumMapEntry<sal_uInt16> aFontEmphasisMap[]; +extern const SvXMLEnumMapEntry<sal_uInt16> aFontReliefMap[]; +extern const SvXMLEnumMapEntry<sal_Int16> aListLinkageMap[]; +extern const SvXMLEnumMapEntry<sal_uInt16> aOrientationMap[]; +extern const SvXMLEnumMapEntry<sal_Int16> aVisualEffectMap[]; +extern const SvXMLEnumMapEntry<sal_Int16> aImagePositionMap[]; +extern const SvXMLEnumMapEntry<sal_uInt16> aImageAlignMap[]; +extern const SvXMLEnumMapEntry<sal_uInt16> aScaleModeMap[]; } // namespace xmloff diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index b365d66f40e0..11b40dfc7c0c 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -341,17 +341,17 @@ namespace xmloff exportedProperty( _rPropertyName ); } - void OPropertyExport::exportEnumPropertyAttribute( + void OPropertyExport::exportEnumPropertyAttributeImpl( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName, - const OUString &rPropertyName, const SvXMLEnumMapEntry* _pValueMap, - const sal_Int32 _nDefault, const bool _bVoidDefault) + const OUString &rPropertyName, const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap, + const sal_uInt16 _nDefault, const bool _bVoidDefault) { // get the value - sal_Int32 nCurrentValue(_nDefault); Any aValue = m_xProps->getPropertyValue(rPropertyName); if (aValue.hasValue()) { // we have a non-void current value + sal_Int32 nCurrentValue(_nDefault); ::cppu::enum2int(nCurrentValue, aValue); // add the attribute diff --git a/xmloff/source/forms/propertyexport.hxx b/xmloff/source/forms/propertyexport.hxx index ff2efadb3a41..779423272c9d 100644 --- a/xmloff/source/forms/propertyexport.hxx +++ b/xmloff/source/forms/propertyexport.hxx @@ -211,13 +211,26 @@ namespace xmloff the default of the attribute. If the current property value equals this default, no attribute is added. */ + template<typename EnumT> void exportEnumPropertyAttribute( const sal_uInt16 _nNamespaceKey, const sal_Char* _pAttributeName, const OUString& _rPropertyName, - const SvXMLEnumMapEntry* _pValueMap, - const sal_Int32 _nDefault, - const bool _bVoidDefault = false); + const SvXMLEnumMapEntry<EnumT>* _pValueMap, + const EnumT _nDefault, + const bool _bVoidDefault = false) + { + exportEnumPropertyAttributeImpl(_nNamespaceKey, _pAttributeName, _rPropertyName, + reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(_pValueMap), + static_cast<sal_Int16>(_nDefault), _bVoidDefault); + } + void exportEnumPropertyAttributeImpl( + const sal_uInt16 _nNamespaceKey, + const sal_Char* _pAttributeName, + const OUString& _rPropertyName, + const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap, + const sal_uInt16 _nDefault, + const bool _bVoidDefault); // some very special methods for some very special attribute/property pairs diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 6ad41b0e59b9..16b1e36de110 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -84,7 +84,7 @@ namespace } Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType, - const OUString& _rReadCharacters, const SvXMLEnumMapEntry* _pEnumMap, const bool _bInvertBoolean ) + const OUString& _rReadCharacters, const SvXMLEnumMapEntry<sal_uInt16>* _pEnumMap, const bool _bInvertBoolean ) { Any aReturn; bool bEnumAsInt = false; diff --git a/xmloff/source/forms/propertyimport.hxx b/xmloff/source/forms/propertyimport.hxx index 8cb81595f04e..70b1dd71ec84 100644 --- a/xmloff/source/forms/propertyimport.hxx +++ b/xmloff/source/forms/propertyimport.hxx @@ -42,10 +42,21 @@ namespace xmloff class PropertyConversion { public: + template<typename EnumT> static css::uno::Any convertString( const css::uno::Type& _rExpectedType, const OUString& _rReadCharacters, - const SvXMLEnumMapEntry* _pEnumMap = nullptr, + const SvXMLEnumMapEntry<EnumT>* _pEnumMap = nullptr, + const bool _bInvertBoolean = false + ) + { + return convertString(_rExpectedType, _rReadCharacters, + reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(_pEnumMap), _bInvertBoolean); + } + static css::uno::Any convertString( + const css::uno::Type& _rExpectedType, + const OUString& _rReadCharacters, + const SvXMLEnumMapEntry<sal_uInt16>* _pEnumMap = nullptr, const bool _bInvertBoolean = false ); |