diff options
author | Noel <noelgrandin@gmail.com> | 2020-11-25 08:14:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-30 12:32:14 +0100 |
commit | 8332d6d8200e8ca1f22dd98d9373efd5a431d09c (patch) | |
tree | dd45d452202998297b8562743ea6345462304d04 /oox | |
parent | d05a4cfbdcece491f7385dbeaa7eca03f2fdc1d5 (diff) |
loplugin:stringviewparam include comparisons with string literals
Change-Id: I8ba1214500dddaf413c506a4b82f43d63cda804b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106559
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/filterdetect.cxx | 32 | ||||
-rw-r--r-- | oox/source/crypto/AgileEngine.cxx | 10 | ||||
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 14 | ||||
-rw-r--r-- | oox/source/drawingml/color.cxx | 58 | ||||
-rw-r--r-- | oox/source/dump/dumperbase.cxx | 36 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 42 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 20 | ||||
-rw-r--r-- | oox/source/helper/attributelist.cxx | 4 | ||||
-rw-r--r-- | oox/source/ppt/slidetransition.cxx | 4 |
9 files changed, 110 insertions, 110 deletions
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index b57c4696cb13..68dbf6d802ec 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -174,11 +174,11 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) } } -OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& rContentType, const OUString& rFileName ) +OUString FilterDetectDocHandler::getFilterNameFromContentType( std::u16string_view rContentType, const OUString& rFileName ) { bool bDocm = rFileName.endsWithIgnoreAsciiCase(".docm"); - if( rContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" && !bDocm ) + if( rContentType == u"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" && !bDocm ) { switch (maOOXMLVariant) { @@ -190,11 +190,11 @@ OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& r } } - if( rContentType == "application/vnd.ms-word.document.macroEnabled.main+xml" || bDocm ) + if( rContentType == u"application/vnd.ms-word.document.macroEnabled.main+xml" || bDocm ) return "writer_MS_Word_2007_VBA"; - if( rContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" || - rContentType == "application/vnd.ms-word.template.macroEnabledTemplate.main+xml" ) + if( rContentType == u"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" || + rContentType == u"application/vnd.ms-word.template.macroEnabledTemplate.main+xml" ) { switch (maOOXMLVariant) { @@ -206,31 +206,31 @@ OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& r } } - if( rContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml") + if( rContentType == u"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml") return "MS Excel 2007 XML"; - if (rContentType == "application/vnd.ms-excel.sheet.macroEnabled.main+xml") + if (rContentType == u"application/vnd.ms-excel.sheet.macroEnabled.main+xml") return "MS Excel 2007 VBA XML"; - if( rContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" || - rContentType == "application/vnd.ms-excel.template.macroEnabled.main+xml" ) + if( rContentType == u"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" || + rContentType == u"application/vnd.ms-excel.template.macroEnabled.main+xml" ) return "MS Excel 2007 XML Template"; - if ( rContentType == "application/vnd.ms-excel.sheet.binary.macroEnabled.main" ) + if ( rContentType == u"application/vnd.ms-excel.sheet.binary.macroEnabled.main" ) return "MS Excel 2007 Binary"; - if (rContentType == "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml") + if (rContentType == u"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml") return "MS PowerPoint 2007 XML"; - if (rContentType == "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml") + if (rContentType == u"application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml") return "MS PowerPoint 2007 XML VBA"; - if( rContentType == "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml" || - rContentType == "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml" ) + if( rContentType == u"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml" || + rContentType == u"application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml" ) return "MS PowerPoint 2007 XML AutoPlay"; - if( rContentType == "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml" || - rContentType == "application/vnd.ms-powerpoint.template.macroEnabled.main+xml" ) + if( rContentType == u"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml" || + rContentType == u"application/vnd.ms-powerpoint.template.macroEnabled.main+xml" ) return "MS PowerPoint 2007 XML Template"; return OUString(); diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx index 179317510880..63712d01b3ef 100644 --- a/oox/source/crypto/AgileEngine.cxx +++ b/oox/source/crypto/AgileEngine.cxx @@ -195,15 +195,15 @@ const std::vector<sal_uInt8> constBlockHmac2 { 0xa0, 0x67, 0x7f, 0x02, 0xb2, 0x2 bool hashCalc(std::vector<sal_uInt8>& output, std::vector<sal_uInt8>& input, - const OUString& sAlgorithm ) + std::u16string_view sAlgorithm ) { - if (sAlgorithm == "SHA1") + if (sAlgorithm == u"SHA1") { std::vector<unsigned char> out = comphelper::Hash::calculateHash(input.data(), input.size(), comphelper::HashType::SHA1); output = out; return true; } - else if (sAlgorithm == "SHA512") + else if (sAlgorithm == u"SHA512") { std::vector<unsigned char> out = comphelper::Hash::calculateHash(input.data(), input.size(), comphelper::HashType::SHA512); output = out; @@ -212,9 +212,9 @@ bool hashCalc(std::vector<sal_uInt8>& output, return false; } -CryptoHashType cryptoHashTypeFromString(OUString const & sAlgorithm) +CryptoHashType cryptoHashTypeFromString(std::u16string_view sAlgorithm) { - if (sAlgorithm == "SHA512") + if (sAlgorithm == u"SHA512") return CryptoHashType::SHA512; return CryptoHashType::SHA1; } diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 2de8ee82d2f9..6e0b21071553 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -239,19 +239,19 @@ void importFillProperties( PropertySet& rPropSet, Shape& rShape, const GraphicHe } -DataPointCustomLabelFieldType lcl_ConvertFieldNameToFieldEnum( const OUString& rField ) +DataPointCustomLabelFieldType lcl_ConvertFieldNameToFieldEnum( std::u16string_view rField ) { - if (rField == "VALUE") + if (rField == u"VALUE") return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE; - else if (rField == "SERIESNAME") + else if (rField == u"SERIESNAME") return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME; - else if (rField == "CATEGORYNAME") + else if (rField == u"CATEGORYNAME") return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CATEGORYNAME; - else if (rField == "CELLREF") + else if (rField == u"CELLREF") return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLREF; - else if (rField == "CELLRANGE") + else if (rField == u"CELLRANGE") return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLRANGE; - else if (rField == "PERCENTAGE") + else if (rField == u"PERCENTAGE") return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_PERCENTAGE; else return DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT; diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 33e3c3dcd053..e87079945600 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -402,63 +402,63 @@ OUString Color::getColorTransformationName( sal_Int32 nElement ) return OUString(); } -sal_Int32 Color::getColorTransformationToken( const OUString& sName ) +sal_Int32 Color::getColorTransformationToken( std::u16string_view sName ) { - if( sName == "red" ) + if( sName == u"red" ) return XML_red; - else if( sName == "redMod" ) + else if( sName == u"redMod" ) return XML_redMod; - else if( sName == "redOff" ) + else if( sName == u"redOff" ) return XML_redOff; - else if( sName == "green" ) + else if( sName == u"green" ) return XML_green; - else if( sName == "greenMod" ) + else if( sName == u"greenMod" ) return XML_greenMod; - else if( sName == "greenOff" ) + else if( sName == u"greenOff" ) return XML_greenOff; - else if( sName == "blue" ) + else if( sName == u"blue" ) return XML_blue; - else if( sName == "blueMod" ) + else if( sName == u"blueMod" ) return XML_blueMod; - else if( sName == "blueOff" ) + else if( sName == u"blueOff" ) return XML_blueOff; - else if( sName == "alpha" ) + else if( sName == u"alpha" ) return XML_alpha; - else if( sName == "alphaMod" ) + else if( sName == u"alphaMod" ) return XML_alphaMod; - else if( sName == "alphaOff" ) + else if( sName == u"alphaOff" ) return XML_alphaOff; - else if( sName == "hue" ) + else if( sName == u"hue" ) return XML_hue; - else if( sName == "hueMod" ) + else if( sName == u"hueMod" ) return XML_hueMod; - else if( sName == "hueOff" ) + else if( sName == u"hueOff" ) return XML_hueOff; - else if( sName == "sat" ) + else if( sName == u"sat" ) return XML_sat; - else if( sName == "satMod" ) + else if( sName == u"satMod" ) return XML_satMod; - else if( sName == "satOff" ) + else if( sName == u"satOff" ) return XML_satOff; - else if( sName == "lum" ) + else if( sName == u"lum" ) return XML_lum; - else if( sName == "lumMod" ) + else if( sName == u"lumMod" ) return XML_lumMod; - else if( sName == "lumOff" ) + else if( sName == u"lumOff" ) return XML_lumOff; - else if( sName == "shade" ) + else if( sName == u"shade" ) return XML_shade; - else if( sName == "tint" ) + else if( sName == u"tint" ) return XML_tint; - else if( sName == "gray" ) + else if( sName == u"gray" ) return XML_gray; - else if( sName == "comp" ) + else if( sName == u"comp" ) return XML_comp; - else if( sName == "inv" ) + else if( sName == u"inv" ) return XML_inv; - else if( sName == "gamma" ) + else if( sName == u"gamma" ) return XML_gamma; - else if( sName == "invGamma" ) + else if( sName == u"invGamma" ) return XML_invGamma; SAL_WARN( "oox.drawingml", "Color::getColorTransformationToken - unexpected transformation type" ); diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index d553dd092ff7..df18516a0aef 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -622,46 +622,46 @@ OString StringHelper::convertToUtf8( const OUString& rStr ) return OUStringToOString( rStr, RTL_TEXTENCODING_UTF8 ); } -DataType StringHelper::convertToDataType( const OUString& rStr ) +DataType StringHelper::convertToDataType( std::u16string_view rStr ) { DataType eType = DATATYPE_VOID; - if ( rStr == "int8" ) + if ( rStr == u"int8" ) eType = DATATYPE_INT8; - else if ( rStr == "uint8" ) + else if ( rStr == u"uint8" ) eType = DATATYPE_UINT8; - else if ( rStr == "int16" ) + else if ( rStr == u"int16" ) eType = DATATYPE_INT16; - else if ( rStr == "uint16" ) + else if ( rStr == u"uint16" ) eType = DATATYPE_UINT16; - else if ( rStr == "int32" ) + else if ( rStr == u"int32" ) eType = DATATYPE_INT32; - else if ( rStr == "uint32" ) + else if ( rStr == u"uint32" ) eType = DATATYPE_UINT32; - else if ( rStr == "int64" ) + else if ( rStr == u"int64" ) eType = DATATYPE_INT64; - else if ( rStr == "uint64" ) + else if ( rStr == u"uint64" ) eType = DATATYPE_UINT64; - else if ( rStr == "float" ) + else if ( rStr == u"float" ) eType = DATATYPE_FLOAT; - else if ( rStr == "double" ) + else if ( rStr == u"double" ) eType = DATATYPE_DOUBLE; return eType; } -FormatType StringHelper::convertToFormatType( const OUString& rStr ) +FormatType StringHelper::convertToFormatType( std::u16string_view rStr ) { FormatType eType = FORMATTYPE_NONE; - if ( rStr == "dec" ) + if ( rStr == u"dec" ) eType = FORMATTYPE_DEC; - else if ( rStr == "hex" ) + else if ( rStr == u"hex" ) eType = FORMATTYPE_HEX; - else if ( rStr == "shorthex" ) + else if ( rStr == u"shorthex" ) eType = FORMATTYPE_SHORTHEX; - else if ( rStr == "bin" ) + else if ( rStr == u"bin" ) eType = FORMATTYPE_BIN; - else if ( rStr == "fix" ) + else if ( rStr == u"fix" ) eType = FORMATTYPE_FIX; - else if ( rStr == "bool" ) + else if ( rStr == u"bool" ) eType = FORMATTYPE_BOOL; return eType; } diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 38295504105b..e87fba060646 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -435,38 +435,38 @@ static ::std::vector< double > lcl_getAllValuesFromSequence( const Reference< ch return aResult; } -static sal_Int32 lcl_getChartType( const OUString& sChartType ) +static sal_Int32 lcl_getChartType( std::u16string_view sChartType ) { chart::TypeId eChartTypeId = chart::TYPEID_UNKNOWN; - if( sChartType == "com.sun.star.chart.BarDiagram" - || sChartType == "com.sun.star.chart2.ColumnChartType" ) + if( sChartType == u"com.sun.star.chart.BarDiagram" + || sChartType == u"com.sun.star.chart2.ColumnChartType" ) eChartTypeId = chart::TYPEID_BAR; - else if( sChartType == "com.sun.star.chart.AreaDiagram" - || sChartType == "com.sun.star.chart2.AreaChartType" ) + else if( sChartType == u"com.sun.star.chart.AreaDiagram" + || sChartType == u"com.sun.star.chart2.AreaChartType" ) eChartTypeId = chart::TYPEID_AREA; - else if( sChartType == "com.sun.star.chart.LineDiagram" - || sChartType == "com.sun.star.chart2.LineChartType" ) + else if( sChartType == u"com.sun.star.chart.LineDiagram" + || sChartType == u"com.sun.star.chart2.LineChartType" ) eChartTypeId = chart::TYPEID_LINE; - else if( sChartType == "com.sun.star.chart.PieDiagram" - || sChartType == "com.sun.star.chart2.PieChartType" ) + else if( sChartType == u"com.sun.star.chart.PieDiagram" + || sChartType == u"com.sun.star.chart2.PieChartType" ) eChartTypeId = chart::TYPEID_PIE; - else if( sChartType == "com.sun.star.chart.DonutDiagram" - || sChartType == "com.sun.star.chart2.DonutChartType" ) + else if( sChartType == u"com.sun.star.chart.DonutDiagram" + || sChartType == u"com.sun.star.chart2.DonutChartType" ) eChartTypeId = chart::TYPEID_DOUGHNUT; - else if( sChartType == "com.sun.star.chart.XYDiagram" - || sChartType == "com.sun.star.chart2.ScatterChartType" ) + else if( sChartType == u"com.sun.star.chart.XYDiagram" + || sChartType == u"com.sun.star.chart2.ScatterChartType" ) eChartTypeId = chart::TYPEID_SCATTER; - else if( sChartType == "com.sun.star.chart.NetDiagram" - || sChartType == "com.sun.star.chart2.NetChartType" ) + else if( sChartType == u"com.sun.star.chart.NetDiagram" + || sChartType == u"com.sun.star.chart2.NetChartType" ) eChartTypeId = chart::TYPEID_RADARLINE; - else if( sChartType == "com.sun.star.chart.FilledNetDiagram" - || sChartType == "com.sun.star.chart2.FilledNetChartType" ) + else if( sChartType == u"com.sun.star.chart.FilledNetDiagram" + || sChartType == u"com.sun.star.chart2.FilledNetChartType" ) eChartTypeId = chart::TYPEID_RADARAREA; - else if( sChartType == "com.sun.star.chart.StockDiagram" - || sChartType == "com.sun.star.chart2.CandleStickChartType" ) + else if( sChartType == u"com.sun.star.chart.StockDiagram" + || sChartType == u"com.sun.star.chart2.CandleStickChartType" ) eChartTypeId = chart::TYPEID_STOCK; - else if( sChartType == "com.sun.star.chart.BubbleDiagram" - || sChartType == "com.sun.star.chart2.BubbleChartType" ) + else if( sChartType == u"com.sun.star.chart.BubbleDiagram" + || sChartType == u"com.sun.star.chart2.BubbleChartType" ) eChartTypeId = chart::TYPEID_BUBBLE; return eChartTypeId; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index fc5051cb4bb0..eca53a92d5a8 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3821,7 +3821,7 @@ void DrawingML::WriteShapeStyle( const Reference< XPropertySet >& xPropSet ) mpFS->singleElementNS(XML_a, XML_fontRef, XML_idx, "minor"); } -void DrawingML::WriteShapeEffect( const OUString& sName, const Sequence< PropertyValue >& aEffectProps ) +void DrawingML::WriteShapeEffect( std::u16string_view sName, const Sequence< PropertyValue >& aEffectProps ) { if( !aEffectProps.hasElements() ) return; @@ -3829,26 +3829,26 @@ void DrawingML::WriteShapeEffect( const OUString& sName, const Sequence< Propert // assign the proper tag and enable bContainsColor if necessary sal_Int32 nEffectToken = 0; bool bContainsColor = false; - if( sName == "outerShdw" ) + if( sName == u"outerShdw" ) { nEffectToken = FSNS( XML_a, XML_outerShdw ); bContainsColor = true; } - else if( sName == "innerShdw" ) + else if( sName == u"innerShdw" ) { nEffectToken = FSNS( XML_a, XML_innerShdw ); bContainsColor = true; } - else if( sName == "glow" ) + else if( sName == u"glow" ) { nEffectToken = FSNS( XML_a, XML_glow ); bContainsColor = true; } - else if( sName == "softEdge" ) + else if( sName == u"softEdge" ) nEffectToken = FSNS( XML_a, XML_softEdge ); - else if( sName == "reflection" ) + else if( sName == u"reflection" ) nEffectToken = FSNS( XML_a, XML_reflection ); - else if( sName == "blur" ) + else if( sName == u"blur" ) nEffectToken = FSNS( XML_a, XML_blur ); OUString sSchemeClr; @@ -4080,7 +4080,7 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) aShadowGrabBag[2].Name = "RgbClrTransparency"; aShadowGrabBag[2].Value = rXPropSet->getPropertyValue( "ShadowTransparence" ); - WriteShapeEffect( "outerShdw", aShadowGrabBag ); + WriteShapeEffect( u"outerShdw", aShadowGrabBag ); } WriteSoftEdgeEffect(rXPropSet); mpFS->endElementNS(XML_a, XML_effectLst); @@ -4181,7 +4181,7 @@ void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet) aGlowProps[2].Value = rXPropSet->getPropertyValue("GlowEffectTransparency"); // TODO other stuff like saturation or luminance - WriteShapeEffect("glow", aGlowProps); + WriteShapeEffect(u"glow", aGlowProps); } void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet) @@ -4198,7 +4198,7 @@ void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPrope aProps[0].Name = "Attribs"; aProps[0].Value <<= aAttribs; - WriteShapeEffect("softEdge", aProps); + WriteShapeEffect(u"softEdge", aProps); } bool DrawingML::HasEnhancedCustomShapeSegmentCommand( diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 725ebde132fd..afc6ebc483c7 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -62,8 +62,8 @@ sal_Unicode lclGetXChar( const sal_Unicode*& rpcStr, const sal_Unicode* pcEnd ) } // namespace -#define STRING_TO_TOKEN(color) if (sColorName == #color) return XML_##color -sal_Int32 getHighlightColorTokenFromString(const OUString& sColorName) +#define STRING_TO_TOKEN(color) if (sColorName == u"" #color) return XML_##color +sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName) { STRING_TO_TOKEN(black); STRING_TO_TOKEN(blue); diff --git a/oox/source/ppt/slidetransition.cxx b/oox/source/ppt/slidetransition.cxx index e65959634161..b65bd9db8b72 100644 --- a/oox/source/ppt/slidetransition.cxx +++ b/oox/source/ppt/slidetransition.cxx @@ -449,9 +449,9 @@ namespace oox::ppt { } } - void SlideTransition::setPresetTransition(OUString const & sPresetTransition) + void SlideTransition::setPresetTransition(std::u16string_view sPresetTransition) { - if (sPresetTransition == "fallOver") + if (sPresetTransition == u"fallOver") { mnTransitionType = TransitionType::MISCSHAPEWIPE; mnTransitionSubType = TransitionSubType::LEFTTORIGHT; |