Kaydet (Commit) 7d01bed2 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

we need a reference to the DifParser.aData, fdo#64920

regression from 6191fa08

Change-Id: If7fc18e7d0bcbf1075a0ecdb1c0dcf3d207f1bda
üst 376830eb
...@@ -61,7 +61,7 @@ FltError ScFormatFilterPluginImpl::ScImportDif( SvStream& rIn, ScDocument* pDoc, ...@@ -61,7 +61,7 @@ FltError ScFormatFilterPluginImpl::ScImportDif( SvStream& rIn, ScDocument* pDoc,
bool bSyntErrWarn = false; bool bSyntErrWarn = false;
bool bOverflowWarn = false; bool bOverflowWarn = false;
OUString aData = aDifParser.aData; OUString& aData = aDifParser.aData;
bool bData = false; bool bData = false;
rIn.Seek( 0 ); rIn.Seek( 0 );
...@@ -377,7 +377,7 @@ TOPIC DifParser::GetNextTopic( void ) ...@@ -377,7 +377,7 @@ TOPIC DifParser::GetNextTopic( void )
if( aLine.getLength() > 2 ) if( aLine.getLength() > 2 )
aData = aLine.copy( 1, aLine.getLength() - 2 ); aData = aLine.copy( 1, aLine.getLength() - 2 );
else else
aData.Erase(); aData = OUString();
eS = S_END; eS = S_END;
break; break;
case S_END: case S_END:
...@@ -400,20 +400,14 @@ TOPIC DifParser::GetNextTopic( void ) ...@@ -400,20 +400,14 @@ TOPIC DifParser::GetNextTopic( void )
} }
static void lcl_DeEscapeQuotesDif( String& rString ) static void lcl_DeEscapeQuotesDif( OUString& rString )
{ {
// Special handling for DIF import: Escaped (duplicated) quotes are resolved. // Special handling for DIF import: Escaped (duplicated) quotes are resolved.
// Single quote characters are left in place because older versions didn't // Single quote characters are left in place because older versions didn't
// escape quotes in strings (and Excel doesn't when using the clipboard). // escape quotes in strings (and Excel doesn't when using the clipboard).
// The quotes around the string are removed before this function is called. // The quotes around the string are removed before this function is called.
static const sal_Unicode aDQ[] = { '"', '"', 0 }; rString = rString.replaceAll("\"\"", "\"");
xub_StrLen nPos = 0;
while ( (nPos = rString.Search( aDQ, nPos )) != STRING_NOTFOUND )
{
rString.Erase( nPos, 1 );
++nPos;
}
} }
// Determine if passed in string is numeric data and set fVal/nNumFormat if so // Determine if passed in string is numeric data and set fVal/nNumFormat if so
...@@ -501,9 +495,9 @@ bool DifParser::LookAhead() ...@@ -501,9 +495,9 @@ bool DifParser::LookAhead()
DATASET DifParser::GetNextDataset( void ) DATASET DifParser::GetNextDataset( void )
{ {
DATASET eRet = D_UNKNOWN; DATASET eRet = D_UNKNOWN;
OUString aLine; OUString aLine;
const sal_Unicode* pAktBuffer; const sal_Unicode* pAktBuffer;
ReadNextLine( aLine ); ReadNextLine( aLine );
...@@ -533,15 +527,14 @@ DATASET DifParser::GetNextDataset( void ) ...@@ -533,15 +527,14 @@ DATASET DifParser::GetNextDataset( void )
ReadNextLine( aTmpLine ); ReadNextLine( aTmpLine );
if ( eRet == D_SYNT_ERROR ) if ( eRet == D_SYNT_ERROR )
{ // for broken records write "#ERR: data" to cell { // for broken records write "#ERR: data" to cell
OUString aTmp = "#ERR: " + OUString( pAktBuffer ) + " ("; OUStringBuffer aTmp("#ERR: ");
OSL_ENSURE( aTmpLine.getLength() <= STRING_MAXLEN - aTmp.getLength() - 1, "GetNextDataset(): line doesn't fit into data"); aTmp.append(pAktBuffer).append(" (");
aTmp += aTmpLine + ")"; aTmp.append(aTmpLine).append(')');
aData = aTmp; aData = aTmp.makeStringAndClear();
eRet = D_STRING; eRet = D_STRING;
} }
else else
{ {
OSL_ENSURE( aTmpLine.getLength() <= STRING_MAXLEN, "GetNextDataset(): line doesn't fit into data");
aData = aTmpLine; aData = aTmpLine;
} }
} }
...@@ -563,7 +556,6 @@ DATASET DifParser::GetNextDataset( void ) ...@@ -563,7 +556,6 @@ DATASET DifParser::GetNextDataset( void )
// Single line string // Single line string
if( nLineLength >= 2 && pLine[nLineLength - 1] == '"' ) if( nLineLength >= 2 && pLine[nLineLength - 1] == '"' )
{ {
OSL_ENSURE( aLine.getLength() - 2 <= STRING_MAXLEN, "GetNextDataset(): line doesn't fit into data");
aData = aLine.copy( 1, nLineLength - 2 ); aData = aLine.copy( 1, nLineLength - 2 );
lcl_DeEscapeQuotesDif( aData ); lcl_DeEscapeQuotesDif( aData );
eRet = D_STRING; eRet = D_STRING;
...@@ -572,12 +564,11 @@ DATASET DifParser::GetNextDataset( void ) ...@@ -572,12 +564,11 @@ DATASET DifParser::GetNextDataset( void )
else else
{ {
// Multiline string // Multiline string
OSL_ENSURE( aLine.getLength() - 1 <= STRING_MAXLEN, "GetNextDataset(): line doesn't fit into data");
aData = aLine.copy( 1 ); aData = aLine.copy( 1 );
bool bContinue = true; bool bContinue = true;
while ( bContinue ) while ( bContinue )
{ {
aData.Append( '\n' ); aData = aData + "\n";
bContinue = !rIn.IsEof() && ReadNextLine( aLine ); bContinue = !rIn.IsEof() && ReadNextLine( aLine );
if( bContinue ) if( bContinue )
{ {
...@@ -588,13 +579,11 @@ DATASET DifParser::GetNextDataset( void ) ...@@ -588,13 +579,11 @@ DATASET DifParser::GetNextDataset( void )
bContinue = !LookAhead(); bContinue = !LookAhead();
if( bContinue ) if( bContinue )
{ {
OSL_ENSURE( aLine.getLength() <= STRING_MAXLEN - aData.Len(), "GetNextDataset(): line doesn't fit into data"); aData = aData + aLine;
aData.Append( aLine );
} }
else if( pLine[nLineLength - 1] == '"' ) else if( pLine[nLineLength - 1] == '"' )
{ {
OSL_ENSURE( nLineLength - 1 <= STRING_MAXLEN - aData.Len(), "GetNextDataset(): line doesn't fit into data"); aData = aData + aLine.copy(0, nLineLength -1 );
aData.Append( pLine, nLineLength - 1 );
lcl_DeEscapeQuotesDif( aData ); lcl_DeEscapeQuotesDif( aData );
eRet = D_STRING; eRet = D_STRING;
} }
......
...@@ -62,7 +62,7 @@ class ScPatternAttr; ...@@ -62,7 +62,7 @@ class ScPatternAttr;
class DifParser class DifParser
{ {
public: public:
String aData; OUString aData;
double fVal; double fVal;
sal_uInt32 nVector; sal_uInt32 nVector;
sal_uInt32 nVal; sal_uInt32 nVal;
......
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