diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-12 12:43:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-13 08:38:53 +0200 |
commit | fdfd517a6f75e394ddcb1e195decbfed33ba56b9 (patch) | |
tree | e3bff14e5531affcd908415b4e85d7ceac4aa1fd /oox | |
parent | e568c9dca8b93b96a8a130a8fb6f1bba1a33d6ea (diff) |
loplugin:stringviewparam whitelist some more functions
for which we have o3tl:: equivalents
Change-Id: I4670fd8b703ac47214be213f41e88d1c6ede7032
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132913
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/drawingml/chart/chartdrawingfragment.hxx | 2 | ||||
-rw-r--r-- | oox/source/docprop/docprophandler.cxx | 4 | ||||
-rw-r--r-- | oox/source/docprop/docprophandler.hxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/chart/chartdrawingfragment.cxx | 7 | ||||
-rw-r--r-- | oox/source/drawingml/customshapegeometry.cxx | 5 | ||||
-rw-r--r-- | oox/source/dump/dumperbase.cxx | 58 | ||||
-rw-r--r-- | oox/source/helper/attributelist.cxx | 12 | ||||
-rw-r--r-- | oox/source/ole/axcontrol.cxx | 34 | ||||
-rw-r--r-- | oox/source/ole/olehelper.cxx | 2 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 6 |
10 files changed, 70 insertions, 62 deletions
diff --git a/oox/inc/drawingml/chart/chartdrawingfragment.hxx b/oox/inc/drawingml/chart/chartdrawingfragment.hxx index 1613b5ee2d5b..af5b16145633 100644 --- a/oox/inc/drawingml/chart/chartdrawingfragment.hxx +++ b/oox/inc/drawingml/chart/chartdrawingfragment.hxx @@ -56,7 +56,7 @@ public: /** Imports the absolute anchor size from the cdr:ext element. */ void importExt( const AttributeList& rAttribs ); /** Sets the relative anchor position from the cdr:from or cdr:to element. */ - void setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue ); + void setPos( sal_Int32 nElement, sal_Int32 nParentContext, std::u16string_view rValue ); /** Calculates the resulting shape anchor in EMUs. */ EmuRectangle calcAnchorRectEmu( const EmuRectangle& rChartRect ) const; diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index c346a63db1f6..c2609a8227d8 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -214,7 +214,7 @@ uno::Sequence< OUString > OOXMLDocPropHandler::GetKeywordsSet( std::u16string_vi return uno::Sequence< OUString >(); } -void OOXMLDocPropHandler::UpdateDocStatistic( const OUString& aChars ) +void OOXMLDocPropHandler::UpdateDocStatistic( std::u16string_view aChars ) { uno::Sequence< beans::NamedValue > aSet = m_xDocProp->getDocumentStatistics(); OUString aName; @@ -257,7 +257,7 @@ void OOXMLDocPropHandler::UpdateDocStatistic( const OUString& aChars ) if (nInd == aSet.getLength()) aSet.realloc( nInd + 1 ); - aSet.getArray()[nInd] = { aName, uno::Any(aChars.toInt32()) }; + aSet.getArray()[nInd] = { aName, uno::Any(o3tl::toInt32(aChars)) }; m_xDocProp->setDocumentStatistics( aSet ); } diff --git a/oox/source/docprop/docprophandler.hxx b/oox/source/docprop/docprophandler.hxx index c7e902634543..69e091850348 100644 --- a/oox/source/docprop/docprophandler.hxx +++ b/oox/source/docprop/docprophandler.hxx @@ -60,7 +60,7 @@ public: static css::util::DateTime GetDateTimeFromW3CDTF( const OUString& aChars ); static css::uno::Sequence< OUString > GetKeywordsSet( std::u16string_view aChars ); - void UpdateDocStatistic( const OUString& aChars ); + void UpdateDocStatistic( std::u16string_view aChars ); // com.sun.star.xml.sax.XFastDocumentHandler diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index 9509ad4ea01e..b9977c933b6b 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -31,6 +31,7 @@ #include <oox/helper/attributelist.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/tokens.hxx> +#include <o3tl/string_view.hxx> namespace oox::drawingml::chart { @@ -51,7 +52,7 @@ void ShapeAnchor::importExt( const AttributeList& rAttribs ) maSize.Height = rAttribs.getHyper( XML_cy, 0 ); } -void ShapeAnchor::setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue ) +void ShapeAnchor::setPos( sal_Int32 nElement, sal_Int32 nParentContext, std::u16string_view rValue ) { AnchorPosModel* pAnchorPos = nullptr; switch( nParentContext ) @@ -68,8 +69,8 @@ void ShapeAnchor::setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OU } if( pAnchorPos ) switch( nElement ) { - case CDR_TOKEN( x ): pAnchorPos->mfX = rValue.toDouble(); break; - case CDR_TOKEN( y ): pAnchorPos->mfY = rValue.toDouble(); break; + case CDR_TOKEN( x ): pAnchorPos->mfX = o3tl::toDouble(rValue); break; + case CDR_TOKEN( y ): pAnchorPos->mfY = o3tl::toDouble(rValue); break; default: OSL_FAIL( "ShapeAnchor::setPos - unexpected element" ); } } diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx index f54cd4a2ca68..2f508382cdc9 100644 --- a/oox/source/drawingml/customshapegeometry.cxx +++ b/oox/source/drawingml/customshapegeometry.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/xml/sax/FastToken.hpp> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <oox/helper/helper.hxx> #include <oox/helper/attributelist.hxx> #include <oox/token/namespaces.hxx> @@ -449,7 +450,7 @@ GeomGuideListContext::GeomGuideListContext( ContextHandler2Helper const & rParen { } -static OUString convertToOOEquation( CustomShapeProperties& rCustomShapeProperties, const OUString& rSource ) +static OUString convertToOOEquation( CustomShapeProperties& rCustomShapeProperties, std::u16string_view rSource ) { if ( !pCommandHashMap ) { @@ -463,7 +464,7 @@ static OUString convertToOOEquation( CustomShapeProperties& rCustomShapeProperti sal_Int32 nIndex = 0; do { - OUString aToken( rSource.getToken( 0, ' ', nIndex ) ); + OUString aToken( o3tl::getToken(rSource, 0, ' ', nIndex ) ); if ( !aToken.isEmpty() ) aTokens.push_back( aToken ); } diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index 2f7d7edc7815..092ab09ff319 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -526,9 +526,9 @@ void StringHelper::appendIndex( OUStringBuffer& rStr, sal_Int64 nIdx ) rStr.append( '[' ).append( aToken.makeStringAndClear() ).append( ']' ); } -OUString StringHelper::getToken( const OUString& rData, sal_Int32& rnPos, sal_Unicode cSep ) +std::u16string_view StringHelper::getToken( std::u16string_view rData, sal_Int32& rnPos, sal_Unicode cSep ) { - return trimSpaces( rData.getToken( 0, cSep, rnPos ) ); + return trimSpaces( o3tl::getToken(rData, 0, cSep, rnPos ) ); } void StringHelper::enclose( OUStringBuffer& rStr, sal_Unicode cOpen, sal_Unicode cClose ) @@ -599,15 +599,15 @@ OUString lclTrimQuotedStringList( const OUString& rStr ) } // namespace -OUString StringHelper::trimSpaces( const OUString& rStr ) +std::u16string_view StringHelper::trimSpaces( std::u16string_view rStr ) { - sal_Int32 nBeg = 0; - while( (nBeg < rStr.getLength()) && ((rStr[ nBeg ] == ' ') || (rStr[ nBeg ] == '\t')) ) + size_t nBeg = 0; + while( (nBeg < rStr.size()) && ((rStr[ nBeg ] == ' ') || (rStr[ nBeg ] == '\t')) ) ++nBeg; - sal_Int32 nEnd = rStr.getLength(); + size_t nEnd = rStr.size(); while( (nEnd > nBeg) && ((rStr[ nEnd - 1 ] == ' ') || (rStr[ nEnd - 1 ] == '\t')) ) --nEnd; - return rStr.copy( nBeg, nEnd - nBeg ); + return rStr.substr( nBeg, nEnd - nBeg ); } OUString StringHelper::trimTrailingNul( const OUString& rStr ) @@ -667,10 +667,10 @@ FormatType StringHelper::convertToFormatType( std::u16string_view rStr ) return eType; } -bool StringHelper::convertFromDec( sal_Int64& ornData, const OUString& rData ) +bool StringHelper::convertFromDec( sal_Int64& ornData, std::u16string_view rData ) { - sal_Int32 nPos = 0; - sal_Int32 nLen = rData.getLength(); + size_t nPos = 0; + size_t nLen = rData.size(); bool bNeg = false; if( (nLen > 0) && (rData[ 0 ] == '-') ) { @@ -690,10 +690,10 @@ bool StringHelper::convertFromDec( sal_Int64& ornData, const OUString& rData ) return true; } -bool StringHelper::convertFromHex( sal_Int64& ornData, const OUString& rData ) +bool StringHelper::convertFromHex( sal_Int64& ornData, std::u16string_view rData ) { ornData = 0; - for( sal_Int32 nPos = 0, nLen = rData.getLength(); nPos < nLen; ++nPos ) + for( size_t nPos = 0, nLen = rData.size(); nPos < nLen; ++nPos ) { sal_Unicode cChar = rData[ nPos ]; if( ('0' <= cChar) && (cChar <= '9') ) @@ -709,26 +709,32 @@ bool StringHelper::convertFromHex( sal_Int64& ornData, const OUString& rData ) return true; } -bool StringHelper::convertStringToInt( sal_Int64& ornData, const OUString& rData ) +bool StringHelper::convertStringToInt( sal_Int64& ornData, std::u16string_view rData ) { - if( (rData.getLength() > 2) && (rData[ 0 ] == '0') && ((rData[ 1 ] == 'X') || (rData[ 1 ] == 'x')) ) - return convertFromHex( ornData, rData.copy( 2 ) ); + if( (rData.size() > 2) && (rData[ 0 ] == '0') && ((rData[ 1 ] == 'X') || (rData[ 1 ] == 'x')) ) + return convertFromHex( ornData, rData.substr( 2 ) ); return convertFromDec( ornData, rData ); } -bool StringHelper::convertStringToDouble( double& orfData, const OUString& rData ) +bool StringHelper::convertStringToDouble( double& orfData, std::u16string_view rData ) { rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok; sal_Int32 nSize = 0; - orfData = rtl::math::stringToDouble( rData, '.', '\0', &eStatus, &nSize ); - return (eStatus == rtl_math_ConversionStatus_Ok) && (nSize == rData.getLength()); + sal_Unicode const * pBegin = rData.data(); + sal_Unicode const * pEnd; + orfData = rtl_math_uStringToDouble(pBegin, + pBegin + rData.size(), + '.', '\0', + &eStatus, &pEnd); + nSize = static_cast<sal_Int32>(pEnd - pBegin); + return (eStatus == rtl_math_ConversionStatus_Ok) && (nSize == static_cast<sal_Int32>(rData.size())); } -bool StringHelper::convertStringToBool( const OUString& rData ) +bool StringHelper::convertStringToBool( std::u16string_view rData ) { - if ( rData == "true" ) + if ( rData == u"true" ) return true; - if ( rData == "false" ) + if ( rData == u"false" ) return false; sal_Int64 nData; return convertStringToInt( nData, rData ) && (nData != 0); @@ -746,8 +752,8 @@ OUStringPair StringHelper::convertStringToPair( const OUString& rString, sal_Uni } else { - aPair.first = StringHelper::trimSpaces( rString.copy( 0, nEqPos ) ); - aPair.second = StringHelper::trimSpaces( rString.copy( nEqPos + 1 ) ); + aPair.first = StringHelper::trimSpaces( rString.subView( 0, nEqPos ) ); + aPair.second = StringHelper::trimSpaces( rString.subView( nEqPos + 1 ) ); } } return aPair; @@ -761,9 +767,9 @@ void StringHelper::convertStringToStringList( OUStringVector& orVec, const OUStr sal_Int32 nLen = aUnquotedData.getLength(); while( (0 <= nPos) && (nPos < nLen) ) { - OUString aToken = getToken( aUnquotedData, nPos, OOX_DUMP_LF ); - if( !bIgnoreEmpty || !aToken.isEmpty() ) - orVec.push_back( aToken ); + std::u16string_view aToken = getToken( aUnquotedData, nPos, OOX_DUMP_LF ); + if( !bIgnoreEmpty || !aToken.empty() ) + orVec.push_back( OUString(aToken) ); } } diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index a566069c3a2e..6afab21c33d8 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -105,19 +105,19 @@ OUString AttributeConversion::decodeXString( const OUString& rValue ) return aBuffer.makeStringAndClear(); } -sal_Int32 AttributeConversion::decodeInteger( const OUString& rValue ) +sal_Int32 AttributeConversion::decodeInteger( std::u16string_view rValue ) { - return rValue.toInt32(); + return o3tl::toInt32(rValue); } -sal_uInt32 AttributeConversion::decodeUnsigned( const OUString& rValue ) +sal_uInt32 AttributeConversion::decodeUnsigned( std::u16string_view rValue ) { - return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64(), 0, SAL_MAX_UINT32 ); + return getLimitedValue< sal_uInt32, sal_Int64 >( o3tl::toInt64(rValue), 0, SAL_MAX_UINT32 ); } -sal_Int64 AttributeConversion::decodeHyper( const OUString& rValue ) +sal_Int64 AttributeConversion::decodeHyper( std::u16string_view rValue ) { - return rValue.toInt64(); + return o3tl::toInt64(rValue); } sal_Int32 AttributeConversion::decodeIntegerHex( const OUString& rValue ) diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index b8415111d38c..d2ec8b9b95ef 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -2659,23 +2659,23 @@ EmbeddedControl::EmbeddedControl( const OUString& rName ) : { } -ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId ) -{ - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_LABEL ) ) return &createModel< AxLabelModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_IMAGE ) ) return &createModel< AxImageModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >(); - if( rClassId.equalsIgnoreAsciiCase( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >(); - if( rClassId.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 ); - if( rClassId.equalsIgnoreAsciiCase( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >(); - if( rClassId.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >(); +ControlModelBase* EmbeddedControl::createModelFromGuid( std::u16string_view rClassId ) +{ + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_LABEL ) ) return &createModel< AxLabelModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_IMAGE ) ) return &createModel< AxImageModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" AX_GUID_FRAME ) ) return &createModel< AxFrameModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 ); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >(); + if( o3tl::equalsIgnoreAsciiCase(rClassId, u"" HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >(); mxModel.reset(); return nullptr; diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 0a50bc23327c..16b38919a213 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -421,7 +421,7 @@ MSConvertOCXControls::~MSConvertOCXControls() } bool -MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const OUString& rGuidString ) +MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, std::u16string_view rGuidString ) { ::oox::ole::EmbeddedControl aControl( "Unknown" ); if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) ) diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index a4d87bb0e9c9..9b489ce9b351 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -591,7 +591,7 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri return ShapeTypeContext::onCreateContext( nElement, rAttribs ); } -void ShapeContext::setPoints(const OUString& rPoints) +void ShapeContext::setPoints(std::u16string_view rPoints) { mrShapeModel.maPoints.clear(); sal_Int32 nIndex = 0; @@ -599,10 +599,10 @@ void ShapeContext::setPoints(const OUString& rPoints) while (nIndex >= 0) { sal_Int32 nX = ConversionHelper::decodeMeasureToTwip( - mrShape.getDrawing().getFilter().getGraphicHelper(), rPoints.getToken(0, ',', nIndex), + mrShape.getDrawing().getFilter().getGraphicHelper(), OUString(o3tl::getToken(rPoints, 0, ',', nIndex)), 0, true, true); sal_Int32 nY = ConversionHelper::decodeMeasureToTwip( - mrShape.getDrawing().getFilter().getGraphicHelper(), rPoints.getToken(0, ',', nIndex), + mrShape.getDrawing().getFilter().getGraphicHelper(), OUString(o3tl::getToken(rPoints, 0, ',', nIndex)), 0, false, true); mrShapeModel.maPoints.emplace_back(nX, nY); } |