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

Get rid of ScStringUtil::GetQuotedTokenCount()

Change-Id: If50beb8edaf2c0bb0d336c81b4144ff58147771f
Reviewed-on: https://gerrit.libreoffice.org/65657
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: 's avatarMatteo Casalin <matteo.casalin@yahoo.com>
üst 66b919c8
......@@ -151,7 +151,6 @@ public:
static bool parseSimpleNumber(
const char* p, size_t n, char dsep, char gsep, double& rVal);
static sal_Int32 SC_DLLPUBLIC GetQuotedTokenCount(const OUString &rIn, const OUString& rQuotedPairs, sal_Unicode cTok );
static OUString SC_DLLPUBLIC GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString& rQuotedPairs,
sal_Unicode cTok, sal_Int32& rIndex );
......
......@@ -346,58 +346,6 @@ bool ScStringUtil::parseSimpleNumber(
return true;
}
sal_Int32 ScStringUtil::GetQuotedTokenCount(const OUString &rIn, const OUString& rQuotedPairs, sal_Unicode cTok )
{
assert( !(rQuotedPairs.getLength()%2) );
assert( rQuotedPairs.indexOf(cTok) == -1 );
// empty string: TokenCount is 0 per definition
if ( rIn.isEmpty() )
return 0;
sal_Int32 nTokCount = 1;
sal_Int32 nLen = rIn.getLength();
sal_Int32 nQuotedLen = rQuotedPairs.getLength();
sal_Unicode cQuotedEndChar = 0;
const sal_Unicode* pQuotedStr = rQuotedPairs.getStr();
const sal_Unicode* pStr = rIn.getStr();
sal_Int32 nIndex = 0;
while ( nIndex < nLen )
{
sal_Unicode c = *pStr;
if ( cQuotedEndChar )
{
// reached end of the quote?
if ( c == cQuotedEndChar )
cQuotedEndChar = 0;
}
else
{
// Is the char a quote-begin char?
sal_Int32 nQuoteIndex = 0;
while ( nQuoteIndex < nQuotedLen )
{
if ( pQuotedStr[nQuoteIndex] == c )
{
cQuotedEndChar = pQuotedStr[nQuoteIndex+1];
break;
}
else
nQuoteIndex += 2;
}
// If the token-char matches then increase TokCount
if ( c == cTok )
++nTokCount;
}
++pStr;
++nIndex;
}
return nTokCount;
}
OUString ScStringUtil::GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString& rQuotedPairs,
sal_Unicode cTok, sal_Int32& rIndex )
{
......
......@@ -1001,11 +1001,9 @@ void XclImpWebQuery::ReadWqtables( XclImpStream& rStrm )
OUString aTables( rStrm.ReadUniString() );
const sal_Unicode cSep = ';';
OUString aQuotedPairs( "\"\"" );
sal_Int32 nTokenCnt = ScStringUtil::GetQuotedTokenCount( aTables, aQuotedPairs, ',' );
const OUString aQuotedPairs( "\"\"" );
maTables.clear();
sal_Int32 nStringIx = 0;
for( sal_Int32 nToken = 0; nToken < nTokenCnt; ++nToken )
for ( sal_Int32 nStringIx {aTables.isEmpty() ? -1 : 0}; nStringIx>=0; )
{
OUString aToken( ScStringUtil::GetQuotedToken( aTables, 0, aQuotedPairs, ',', nStringIx ) );
sal_Int32 nTabNum = CharClass::isAsciiNumeric( aToken ) ? aToken.toInt32() : 0;
......
......@@ -299,14 +299,13 @@ void lclGetFormulaFromStringList( OUString& rFmlaStr, const OUString& rStringLis
@return true = Conversion successful. */
bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaStr, sal_Unicode cFmlaSep )
{
OUString aQuotes( "\"\"" );
sal_Int32 nTokenCnt = ScStringUtil::GetQuotedTokenCount(rFmlaStr, aQuotes, cFmlaSep );
const OUString aQuotes( "\"\"" );
rStringList.clear();
bool bIsStringList = (nTokenCnt > 0);
bool bIsStringList = !rFmlaStr.isEmpty();
bool bTokenAdded = false;
for( sal_Int32 nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
for ( sal_Int32 nStringIx = 0; bIsStringList && nStringIx>=0; )
{
OUString aToken( ScStringUtil::GetQuotedToken(rFmlaStr, 0, aQuotes, cFmlaSep, nStringIx ) );
aToken = comphelper::string::strip(aToken, ' ');
......
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