Kaydet (Commit) d3bda969 authored tarafından Caolán McNamara's avatar Caolán McNamara

just return a new string rather than pass by reference

üst 1aec5907
...@@ -476,7 +476,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText ) ...@@ -476,7 +476,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText )
bRet = false; bRet = false;
break; break;
} }
ReadCsvLine(*mpDatStream, rText, !bFixed, maFieldSeparators, rText = ReadCsvLine(*mpDatStream, !bFixed, maFieldSeparators,
mcTextSep); mcTextSep);
mnStreamPos = mpDatStream->Tell(); mnStreamPos = mpDatStream->Tell();
mpRowPosArray[++mnRowPosCount] = mnStreamPos; mpRowPosArray[++mnRowPosCount] = mnStreamPos;
...@@ -494,7 +494,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText ) ...@@ -494,7 +494,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText )
else else
{ {
Seek( mpRowPosArray[nLine]); Seek( mpRowPosArray[nLine]);
ReadCsvLine(*mpDatStream, rText, !bFixed, maFieldSeparators, mcTextSep); rText = ReadCsvLine(*mpDatStream, !bFixed, maFieldSeparators, mcTextSep);
mnStreamPos = mpDatStream->Tell(); mnStreamPos = mpDatStream->Tell();
} }
......
...@@ -1180,7 +1180,7 @@ sal_Bool ScImportExport::ExtText2Doc( SvStream& rStrm ) ...@@ -1180,7 +1180,7 @@ sal_Bool ScImportExport::ExtText2Doc( SvStream& rStrm )
while(--nSkipLines>0) while(--nSkipLines>0)
{ {
ReadCsvLine(rStrm, aLine, !bFixed, rSeps, cStr); // content is ignored aLine = ReadCsvLine(rStrm, !bFixed, rSeps, cStr); // content is ignored
if ( rStrm.IsEof() ) if ( rStrm.IsEof() )
break; break;
} }
...@@ -1203,7 +1203,7 @@ sal_Bool ScImportExport::ExtText2Doc( SvStream& rStrm ) ...@@ -1203,7 +1203,7 @@ sal_Bool ScImportExport::ExtText2Doc( SvStream& rStrm )
{ {
for( ;; ) for( ;; )
{ {
ReadCsvLine(rStrm, aLine, !bFixed, rSeps, cStr); aLine = ReadCsvLine(rStrm, !bFixed, rSeps, cStr);
if ( rStrm.IsEof() ) if ( rStrm.IsEof() )
break; break;
...@@ -2123,11 +2123,12 @@ inline const sal_Unicode* lcl_UnicodeStrChr( const sal_Unicode* pStr, ...@@ -2123,11 +2123,12 @@ inline const sal_Unicode* lcl_UnicodeStrChr( const sal_Unicode* pStr,
return 0; return 0;
} }
void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak, String ReadCsvLine(SvStream &rStream, sal_Bool bEmbeddedLineBreak,
const String& rFieldSeparators, sal_Unicode cFieldQuote, const String& rFieldSeparators, sal_Unicode cFieldQuote,
sal_Bool bAllowBackslashEscape) sal_Bool bAllowBackslashEscape)
{ {
rStream.ReadUniOrByteStringLine(rStr, rStream.GetStreamCharSet()); String aStr;
rStream.ReadUniOrByteStringLine(aStr, rStream.GetStreamCharSet());
if (bEmbeddedLineBreak) if (bEmbeddedLineBreak)
{ {
...@@ -2138,11 +2139,11 @@ void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak, ...@@ -2138,11 +2139,11 @@ void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak,
xub_StrLen nLastOffset = 0; xub_StrLen nLastOffset = 0;
xub_StrLen nQuotes = 0; xub_StrLen nQuotes = 0;
while (!rStream.IsEof() && rStr.Len() < STRING_MAXLEN) while (!rStream.IsEof() && aStr.Len() < STRING_MAXLEN)
{ {
bool bBackslashEscaped = false; bool bBackslashEscaped = false;
const sal_Unicode *p, *pStart; const sal_Unicode *p, *pStart;
p = pStart = rStr.GetBuffer(); p = pStart = aStr.GetBuffer();
p += nLastOffset; p += nLastOffset;
while (*p) while (*p)
{ {
...@@ -2180,14 +2181,15 @@ void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak, ...@@ -2180,14 +2181,15 @@ void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak,
break; break;
else else
{ {
nLastOffset = rStr.Len(); nLastOffset = aStr.Len();
String aNext; String aNext;
rStream.ReadUniOrByteStringLine(aNext, rStream.GetStreamCharSet()); rStream.ReadUniOrByteStringLine(aNext, rStream.GetStreamCharSet());
rStr += sal_Unicode(_LF); aStr += sal_Unicode(_LF);
rStr += aNext; aStr += aNext;
} }
} }
} }
return aStr;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -239,7 +239,7 @@ public: ...@@ -239,7 +239,7 @@ public:
characters will be spoiled, and a subsequent ReadCsvLine() characters will be spoiled, and a subsequent ReadCsvLine()
may start under false preconditions. may start under false preconditions.
*/ */
SC_DLLPUBLIC void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak, SC_DLLPUBLIC String ReadCsvLine(SvStream &rStream, sal_Bool bEmbeddedLineBreak,
const String& rFieldSeparators, sal_Unicode cFieldQuote, const String& rFieldSeparators, sal_Unicode cFieldQuote,
sal_Bool bAllowBackslashEscape = sal_False); sal_Bool bAllowBackslashEscape = sal_False);
......
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