From 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 10 Apr 2022 20:17:54 +0200 Subject: loplugin:stringview add check for getToken().toInt32 where we can convert that to o3tl::toInt32(o3tl::getToken( and avoid the heap allocation of a temporary string Change-Id: Ib11c19c6e6cdc0de3e551affd3578d181e292de4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132810 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/chart/SchXMLExport.cxx | 3 ++- xmloff/source/chart/SchXMLTableContext.cxx | 3 ++- xmloff/source/meta/xmlversion.cxx | 13 +++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 8bc776e5e421..992989665952 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -772,7 +773,7 @@ struct lcl_SequenceToMapElement nIndex = aRangeRep.toInt32(); } else if( rContent.first.is()) //has labels - nIndex = rContent.first->getSourceRangeRepresentation().copy( sizeof("label ")).toInt32(); + nIndex = o3tl::toInt32(rContent.first->getSourceRangeRepresentation().subView( sizeof("label "))); return std::make_pair(nIndex, rContent); } }; diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index a59a28b2546b..9ee4016087fe 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -27,6 +27,7 @@ #include "transporttypes.hxx" #include #include +#include #include #include #include @@ -946,7 +947,7 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( if( xLabel.is() ) { aRange = xLabel->getSourceRangeRepresentation(); - const sal_Int32 nId {aRange.getToken(1, ' ').toInt32()}; + const sal_Int32 nId = o3tl::toInt32(o3tl::getToken(aRange, 1, ' ')); if( ::std::find( rTable.aHiddenColumns.begin(), rTable.aHiddenColumns.end(), nId ) == rTable.aHiddenColumns.end() ) bHasUnhiddenColumns = true; } diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx index 2b332e2afe9d..47acf7737be6 100644 --- a/xmloff/source/meta/xmlversion.cxx +++ b/xmloff/source/meta/xmlversion.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -236,17 +237,17 @@ bool XMLVersionContext::ParseISODateTimeString( else { sal_Int32 n = 0; - nYear = aDateStr.getToken( 0, '-', n ).toInt32(); + nYear = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nYear > 9999 ) bSuccess = false; else if ( nDateTokens >= 2 ) { - nMonth = aDateStr.getToken( 0, '-', n ).toInt32(); + nMonth = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nMonth > 12 ) bSuccess = false; else if ( nDateTokens >= 3 ) { - nDay = aDateStr.getToken( 0, '-', n ).toInt32(); + nDay = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nDay > 31 ) bSuccess = false; } @@ -268,17 +269,17 @@ bool XMLVersionContext::ParseISODateTimeString( else { sal_Int32 n = 0; - nHour = aTimeStr.getToken( 0, ':', n ).toInt32(); + nHour = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nHour > 23 ) bSuccess = false; else if ( nTimeTokens >= 2 ) { - nMin = aTimeStr.getToken( 0, ':', n ).toInt32(); + nMin = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nMin > 59 ) bSuccess = false; else if ( nTimeTokens >= 3 ) { - nSec = aTimeStr.getToken( 0, ':', n ).toInt32(); + nSec = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nSec > 59 ) bSuccess = false; } -- cgit