From 7e9857c2935bb2533806db4e71c6cd1e171c3478 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 9 Mar 2017 09:04:15 +0200 Subject: 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* in various places, to avoid carrying the type param around. Change-Id: Idfbc5561303c557598dd5564b7a7259ae5261d83 Reviewed-on: https://gerrit.libreoffice.org/34987 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/text/txtprhdl.cxx | 94 ++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'xmloff/source/text/txtprhdl.cxx') diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index d29452b7de3a..b3712ea3fb7f 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -68,7 +68,7 @@ using namespace ::xmloff::token; //UUUU using namespace ::com::sun::star::drawing; -static SvXMLEnumMapEntry const pXML_HoriPos_Enum[] = +static SvXMLEnumMapEntry const pXML_HoriPos_Enum[] = { { XML_FROM_LEFT, HoriOrientation::NONE }, { XML_FROM_INSIDE, HoriOrientation::NONE }, // import only @@ -80,7 +80,7 @@ static SvXMLEnumMapEntry const pXML_HoriPos_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_HoriPosMirrored_Enum[] = +static SvXMLEnumMapEntry const pXML_HoriPosMirrored_Enum[] = { { XML_FROM_INSIDE, HoriOrientation::NONE }, { XML_INSIDE, HoriOrientation::LEFT }, @@ -89,7 +89,7 @@ static SvXMLEnumMapEntry const pXML_HoriPosMirrored_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_HoriRel_Enum[] = +static SvXMLEnumMapEntry const pXML_HoriRel_Enum[] = { { XML_PARAGRAPH, RelOrientation::FRAME }, { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA }, @@ -107,7 +107,7 @@ static SvXMLEnumMapEntry const pXML_HoriRel_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_HoriRelFrame_Enum[] = +static SvXMLEnumMapEntry const pXML_HoriRelFrame_Enum[] = { { XML_FRAME, RelOrientation::FRAME }, { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, @@ -121,19 +121,19 @@ static SvXMLEnumMapEntry const pXML_HoriRelFrame_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_HoriMirror_Enum[] = +static SvXMLEnumMapEntry const pXML_HoriMirror_Enum[] = { - { XML_FROM_LEFT, sal_uInt16(false) }, - { XML_FROM_INSIDE, sal_uInt16(true) }, - { XML_LEFT, sal_uInt16(false) }, - { XML_INSIDE, sal_uInt16(true) }, - { XML_CENTER, sal_uInt16(false) }, - { XML_RIGHT, sal_uInt16(false) }, - { XML_OUTSIDE, sal_uInt16(true) }, - { XML_TOKEN_INVALID, 0 } + { XML_FROM_LEFT, false }, + { XML_FROM_INSIDE, true }, + { XML_LEFT, false }, + { XML_INSIDE, true }, + { XML_CENTER, false }, + { XML_RIGHT, false }, + { XML_OUTSIDE, true }, + { XML_TOKEN_INVALID, false } }; -static SvXMLEnumMapEntry const pXML_VertPosAtChar_Enum[] = +static SvXMLEnumMapEntry const pXML_VertPosAtChar_Enum[] = { { XML_FROM_TOP, VertOrientation::NONE }, { XML_TOP, VertOrientation::TOP }, @@ -148,7 +148,7 @@ static SvXMLEnumMapEntry const pXML_VertPosAtChar_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_VertRel_Enum[] = +static SvXMLEnumMapEntry const pXML_VertRel_Enum[] = { { XML_PARAGRAPH, RelOrientation::FRAME }, { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA }, @@ -163,7 +163,7 @@ static SvXMLEnumMapEntry const pXML_VertRel_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_VertRelPage_Enum[] = +static SvXMLEnumMapEntry const pXML_VertRelPage_Enum[] = { { XML_PAGE, RelOrientation::FRAME }, { XML_PAGE_CONTENT, RelOrientation::PRINT_AREA }, @@ -172,14 +172,14 @@ static SvXMLEnumMapEntry const pXML_VertRelPage_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_VertRelFrame_Enum[] = +static SvXMLEnumMapEntry const pXML_VertRelFrame_Enum[] = { { XML_FRAME, RelOrientation::FRAME }, { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_VertRelAsChar_Enum[] = +static SvXMLEnumMapEntry const pXML_VertRelAsChar_Enum[] = { { XML_BASELINE, VertOrientation::TOP }, { XML_BASELINE, VertOrientation::CENTER }, // export only @@ -193,17 +193,17 @@ static SvXMLEnumMapEntry const pXML_VertRelAsChar_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_RubyAdjust_Enum[] = +static SvXMLEnumMapEntry const pXML_RubyAdjust_Enum[] = { { XML_LEFT, RubyAdjust_LEFT }, { XML_CENTER, RubyAdjust_CENTER }, { XML_RIGHT, RubyAdjust_RIGHT }, { XML_DISTRIBUTE_LETTER, RubyAdjust_BLOCK }, { XML_DISTRIBUTE_SPACE, RubyAdjust_INDENT_BLOCK }, - { XML_TOKEN_INVALID, 0 } + { XML_TOKEN_INVALID, (RubyAdjust)0 } }; -static SvXMLEnumMapEntry const pXML_FontRelief_Enum[] = +static SvXMLEnumMapEntry const pXML_FontRelief_Enum[] = { { XML_NONE, FontRelief::NONE }, { XML_ENGRAVED, FontRelief::ENGRAVED }, @@ -211,7 +211,7 @@ static SvXMLEnumMapEntry const pXML_FontRelief_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_ParaVerticalAlign_Enum[] = +static SvXMLEnumMapEntry const pXML_ParaVerticalAlign_Enum[] = { { XML_TOP, ParagraphVertAlign::TOP }, { XML_MIDDLE, ParagraphVertAlign::CENTER }, @@ -222,7 +222,7 @@ static SvXMLEnumMapEntry const pXML_ParaVerticalAlign_Enum[] = }; // OD 2004-05-05 #i28701# -static SvXMLEnumMapEntry const pXML_WrapInfluenceOnPosition_Enum[] = +static SvXMLEnumMapEntry const pXML_WrapInfluenceOnPosition_Enum[] = { // Tokens have been renamed and has been added (#i35017#) { XML_ONCE_SUCCESSIVE, WrapInfluenceOnPosition::ONCE_SUCCESSIVE }, @@ -231,13 +231,13 @@ static SvXMLEnumMapEntry const pXML_WrapInfluenceOnPosition_Enum[] = { XML_TOKEN_INVALID, 0 } }; -static SvXMLEnumMapEntry const pXML_VerticalAlign_Enum[] = +static SvXMLEnumMapEntry const pXML_VerticalAlign_Enum[] = { { XML_TOP, drawing::TextVerticalAdjust_TOP }, { XML_MIDDLE, drawing::TextVerticalAdjust_CENTER }, { XML_BOTTOM, drawing::TextVerticalAdjust_BOTTOM }, { XML_JUSTIFY, drawing::TextVerticalAdjust_BLOCK }, - { XML_TOKEN_INVALID, 0 } + { XML_TOKEN_INVALID, (drawing::TextVerticalAdjust)0 } }; class XMLDropCapPropHdl_Impl : public XMLPropertyHandler @@ -425,7 +425,7 @@ bool XMLParagraphOnlyPropHdl_Impl::exportXML( return true; } -SvXMLEnumMapEntry const pXML_Wrap_Enum[] = +SvXMLEnumMapEntry const pXML_Wrap_Enum[] = { { XML_NONE, WrapTextMode_NONE }, { XML_RUN_THROUGH, WrapTextMode_THROUGHT }, @@ -433,7 +433,7 @@ SvXMLEnumMapEntry const pXML_Wrap_Enum[] = { XML_DYNAMIC, WrapTextMode_DYNAMIC }, { XML_LEFT, WrapTextMode_LEFT }, { XML_RIGHT, WrapTextMode_RIGHT }, - { XML_TOKEN_INVALID, 0 } + { XML_TOKEN_INVALID, (WrapTextMode)0 } }; class XMLWrapPropHdl_Impl : public XMLPropertyHandler @@ -454,12 +454,12 @@ bool XMLWrapPropHdl_Impl::importXML( Any& rValue, const SvXMLUnitConverter& ) const { - sal_uInt16 nWrap; + WrapTextMode nWrap; bool bRet = SvXMLUnitConverter::convertEnum( nWrap, rStrImpValue, pXML_Wrap_Enum ); if( bRet ) - rValue <<= (WrapTextMode)nWrap; + rValue <<= nWrap; return bRet; } @@ -552,14 +552,14 @@ bool XMLFrameProtectPropHdl_Impl::exportXML( return true; } -SvXMLEnumMapEntry const pXML_Anchor_Enum[] = +SvXMLEnumMapEntry const pXML_Anchor_Enum[] = { - { XML_CHAR, TextContentAnchorType_AT_CHARACTER }, - { XML_PAGE, TextContentAnchorType_AT_PAGE }, - { XML_FRAME, TextContentAnchorType_AT_FRAME }, - { XML_PARAGRAPH, TextContentAnchorType_AT_PARAGRAPH }, - { XML_AS_CHAR, TextContentAnchorType_AS_CHARACTER }, - { XML_TOKEN_INVALID, 0 } + { XML_CHAR, TextContentAnchorType_AT_CHARACTER }, + { XML_PAGE, TextContentAnchorType_AT_PAGE }, + { XML_FRAME, TextContentAnchorType_AT_FRAME }, + { XML_PARAGRAPH, TextContentAnchorType_AT_PARAGRAPH }, + { XML_AS_CHAR, TextContentAnchorType_AS_CHARACTER }, + { XML_TOKEN_INVALID, (TextContentAnchorType)0 } }; bool XMLAnchorTypePropHdl::importXML( @@ -567,12 +567,12 @@ bool XMLAnchorTypePropHdl::importXML( Any& rValue, const SvXMLUnitConverter& ) const { - sal_uInt16 nAnchor; + TextContentAnchorType nAnchor; bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue, pXML_Anchor_Enum ); if( bRet ) - rValue <<= (TextContentAnchorType)nAnchor; + rValue <<= nAnchor; return bRet; } @@ -601,11 +601,11 @@ XMLAnchorTypePropHdl::~XMLAnchorTypePropHdl() bool XMLAnchorTypePropHdl::convert( const OUString& rStrImpValue, TextContentAnchorType& rType ) { - sal_uInt16 nAnchor; + TextContentAnchorType nAnchor; bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue, pXML_Anchor_Enum ); if( bRet ) - rType = (TextContentAnchorType)nAnchor; + rType = nAnchor; return bRet; } @@ -686,13 +686,13 @@ bool XMLHoriMirrorPropHdl_Impl::importXML( Any& rValue, const SvXMLUnitConverter& ) const { - sal_uInt16 nHoriMirror; + bool nHoriMirror; bool bRet = SvXMLUnitConverter::convertEnum( nHoriMirror, rStrImpValue, pXML_HoriMirror_Enum ); if( bRet ) { - rValue <<= (nHoriMirror != 0); + rValue <<= nHoriMirror; } return bRet; @@ -793,7 +793,7 @@ bool XMLGrfMirrorPropHdl_Impl::exportXML( return true; } -SvXMLEnumMapEntry const pXML_Emphasize_Enum[] = +SvXMLEnumMapEntry const pXML_Emphasize_Enum[] = { { XML_NONE, FontEmphasis::NONE }, { XML_DOT, FontEmphasis::DOT_ABOVE }, @@ -871,7 +871,7 @@ bool XMLTextEmphasizePropHdl_Impl::exportXML( { OUStringBuffer aOut( 15 ); bool bRet = true; - sal_Int16 nType = sal_Int16(); + sal_uInt16 nType = sal_uInt16(); if( rValue >>= nType ) { bool bBelow = false; @@ -1297,7 +1297,7 @@ static const XMLPropertyHandler *GetPropertyHandler //UUUU case XML_SW_TYPE_FILLSTYLE: - pHdl = new XMLEnumPropertyHdl( aXML_FillStyle_EnumMap, cppu::UnoType::get()); + pHdl = new XMLEnumPropertyHdl( aXML_FillStyle_EnumMap); break; case XML_SW_TYPE_FILLBITMAPSIZE: pHdl = new XMLFillBitmapSizePropertyHandler(); @@ -1306,10 +1306,10 @@ static const XMLPropertyHandler *GetPropertyHandler pHdl = new XMLBitmapLogicalSizePropertyHandler(); break; case XML_SW_TYPE_BITMAP_REFPOINT: - pHdl = new XMLEnumPropertyHdl( aXML_RefPoint_EnumMap, cppu::UnoType::get()); + pHdl = new XMLEnumPropertyHdl( aXML_RefPoint_EnumMap); break; case XML_SW_TYPE_BITMAP_MODE: - pHdl = new XMLEnumPropertyHdl( aXML_BitmapMode_EnumMap, cppu::UnoType::get()); + pHdl = new XMLEnumPropertyHdl( aXML_BitmapMode_EnumMap); break; case XML_SW_TYPE_BITMAPREPOFFSETX: case XML_SW_TYPE_BITMAPREPOFFSETY: -- cgit