Kaydet (Commit) a9d9b1e0 authored tarafından Matteo Casalin's avatar Matteo Casalin

Use positioned getToken in ScAsciiOptions::ReadFromString (1)

Change-Id: I59f1ff177e197db07ac9a9a33487d04c2a5e768e
üst 1353be80
...@@ -197,49 +197,45 @@ static OUString lcl_decodeSepString( const OUString & rSepNums, bool & o_bMergeF ...@@ -197,49 +197,45 @@ static OUString lcl_decodeSepString( const OUString & rSepNums, bool & o_bMergeF
void ScAsciiOptions::ReadFromString( const OUString& rString ) void ScAsciiOptions::ReadFromString( const OUString& rString )
{ {
sal_Int32 nCount = comphelper::string::getTokenCount(rString, ','); sal_Int32 nPos = rString.isEmpty() ? -1 : 0;
OUString aToken;
// Field separator. // Token 0: Field separator.
if ( nCount >= 1 ) if ( nPos >= 0 )
{ {
bFixedLen = bMergeFieldSeps = false; bFixedLen = bMergeFieldSeps = false;
aToken = rString.getToken(0,','); const OUString aToken = rString.getToken(0, ',', nPos);
if ( aToken == pStrFix ) if ( aToken == pStrFix )
bFixedLen = true; bFixedLen = true;
aFieldSeps = lcl_decodeSepString( aToken, bMergeFieldSeps); aFieldSeps = lcl_decodeSepString( aToken, bMergeFieldSeps);
} }
// Text separator. // Token 1: Text separator.
if ( nCount >= 2 ) if ( nPos >= 0 )
{ {
aToken = rString.getToken(1,','); const sal_Int32 nVal = rString.getToken(0, ',', nPos).toInt32();
sal_Int32 nVal = aToken.toInt32(); cTextSep = static_cast<sal_Unicode>(nVal);
cTextSep = (sal_Unicode) nVal;
} }
// Text encoding. // Token 2: Text encoding.
if ( nCount >= 3 ) if ( nPos >= 0 )
{ {
aToken = rString.getToken(2,','); eCharSet = ScGlobal::GetCharsetValue( rString.getToken(0, ',', nPos) );
eCharSet = ScGlobal::GetCharsetValue( aToken );
} }
// Number of start row. // Token 3: Number of start row.
if ( nCount >= 4 ) if ( nPos >= 0 )
{ {
aToken = rString.getToken(3,','); nStartRow = rString.getToken(0, ',', nPos).toInt32();
nStartRow = aToken.toInt32();
} }
// Column info. // Token 4: Column info.
if ( nCount >= 5 ) if ( nPos >= 0 )
{ {
delete[] pColStart; delete[] pColStart;
delete[] pColFormat; delete[] pColFormat;
aToken = rString.getToken(4,','); const OUString aToken = rString.getToken(0, ',', nPos);
sal_Int32 nSub = comphelper::string::getTokenCount(aToken, '/'); sal_Int32 nSub = comphelper::string::getTokenCount(aToken, '/');
nInfoCount = nSub / 2; nInfoCount = nSub / 2;
if (nInfoCount) if (nInfoCount)
...@@ -259,25 +255,22 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) ...@@ -259,25 +255,22 @@ void ScAsciiOptions::ReadFromString( const OUString& rString )
} }
} }
// Language // Token 5: Language.
if (nCount >= 6) if (nPos >= 0)
{ {
aToken = rString.getToken(5, ','); eLang = static_cast<LanguageType>(rString.getToken(0, ',', nPos).toInt32());
eLang = static_cast<LanguageType>(aToken.toInt32());
} }
// Import quoted field as text. // Token 6: Import quoted field as text.
if (nCount >= 7) if (nPos >= 0)
{ {
aToken = rString.getToken(6, ','); bQuotedFieldAsText = rString.getToken(0, ',', nPos) == "true";
bQuotedFieldAsText = aToken == "true";
} }
// Detect special numbers. // Token 7: Detect special numbers.
if (nCount >= 8) if (nPos >= 0)
{ {
aToken = rString.getToken(7, ','); bDetectSpecialNumber = rString.getToken(0, ',', nPos) == "true";
bDetectSpecialNumber = aToken == "true";
} }
else else
bDetectSpecialNumber = true; // default of versions that didn't add the parameter bDetectSpecialNumber = true; // default of versions that didn't add the parameter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment