From 0a2be735c37dd7d5c7ecf2aeb8f8fa2b689dba45 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 12 Aug 2018 22:07:09 +0200 Subject: [PATCH] Avoid getTokenCount and use indexed getToken Change-Id: I14c22a3f04bd9ee31d7261f48ed64bad2477f8fd --- sc/source/ui/docshell/docsh8.cxx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 062c327ab9ee..9514e3b3f6ef 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -470,20 +469,18 @@ void lcl_GetColumnTypes( sal_Int32 nPrecision = 0; sal_Int32 nDbType = sdbc::DataType::SQLNULL; OUString aFieldName; - OUString aString; // Fieldname[,Type[,Width[,Prec]]] // Type etc.: L; D; C[,W]; N[,W[,P]] if ( bHasFieldNames ) { - aString = rDoc.GetString(nCol, nFirstRow, nTab); - aString = aString.toAsciiUpperCase(); - sal_Int32 nToken = comphelper::string::getTokenCount(aString, ','); - if ( nToken > 1 ) + OUString aString {rDoc.GetString(nCol, nFirstRow, nTab).toAsciiUpperCase()}; + sal_Int32 nIdx {0}; + aFieldName = aString.getToken( 0, ',', nIdx); + if ( nIdx>0 ) { - aFieldName = aString.getToken( 0, ',' ); aString = aString.replaceAll(" ", ""); - switch ( aString.getToken( 1, ',' )[0] ) + switch ( aString.getToken( 0, ',', nIdx )[0] ) { case 'L' : nDbType = sdbc::DataType::BIT; @@ -514,12 +511,12 @@ void lcl_GetColumnTypes( bTypeDefined = true; break; } - if ( bTypeDefined && !nFieldLen && nToken > 2 ) + if ( bTypeDefined && !nFieldLen && nIdx>0 ) { - nFieldLen = aString.getToken( 2, ',' ).toInt32(); - if ( !bPrecDefined && nToken > 3 ) + nFieldLen = aString.getToken( 0, ',', nIdx ).toInt32(); + if ( !bPrecDefined && nIdx>0 ) { - OUString aTmp( aString.getToken( 3, ',' ) ); + OUString aTmp( aString.getToken( 0, ',', nIdx ) ); if ( CharClass::isAsciiNumeric(aTmp) ) { nPrecision = aTmp.toInt32(); @@ -530,8 +527,6 @@ void lcl_GetColumnTypes( } } } - else - aFieldName = aString; // Check field name and generate valid field name if necessary. // First character has to be alphabetical, subsequent characters