summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-10 20:17:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 14:45:38 +0200
commit85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 (patch)
treef7d7f6fce51d1a4443608971da7d9c42b1201fa3 /xmloff
parent117688bd3f51a7a50b2620aa7dcc0c065f29d402 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx3
-rw-r--r--xmloff/source/chart/SchXMLTableContext.cxx3
-rw-r--r--xmloff/source/meta/xmlversion.cxx13
3 files changed, 11 insertions, 8 deletions
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 <xmloff/SchXMLSeriesHelper.hxx>
#include <rtl/math.hxx>
#include <o3tl/sorted_vector.hxx>
+#include <o3tl/string_view.hxx>
#include <limits>
#include <vector>
@@ -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 <XMLStringBufferImportContext.hxx>
#include <o3tl/safeint.hxx>
+#include <o3tl/string_view.hxx>
#include <sal/log.hxx>
#include <xmloff/xmlnamespace.hxx>
#include <xmloff/xmltoken.hxx>
@@ -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 <xmloff/xmlmetae.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
#include <xmloff/xmltoken.hxx>
#include <comphelper/processfactory.hxx>
@@ -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;
}