SvStream::WriteUniOrByteChar should not need to specify encoding
Instead, rely on the stream being set into the correct encoding during stream initialisation. Change-Id: Ie019e9f7a668b943e418126b14b8bf852a4fa966 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200459 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -374,14 +374,12 @@ public:
|
||||
bool WriteUnicodeOrByteText(std::u16string_view rStr)
|
||||
{ return WriteUnicodeOrByteText(rStr, GetStreamEncoding(), /*bZero*/false); }
|
||||
|
||||
/** Write a Unicode character if eDestEncoding==RTL_TEXTENCODING_UNICODE,
|
||||
otherwise write as Bytecode converted to eDestEncoding.
|
||||
/** Write a Unicode character if GetStreamEncoding()==RTL_TEXTENCODING_UNICODE,
|
||||
otherwise write as Bytecode converted to GetStreamEncoding().
|
||||
|
||||
This may result in more than one byte being written if a multi byte
|
||||
encoding (e.g. UTF7, UTF8) is chosen. */
|
||||
bool WriteUniOrByteChar( sal_Unicode ch, rtl_TextEncoding eDestEncoding );
|
||||
bool WriteUniOrByteChar( sal_Unicode ch )
|
||||
{ return WriteUniOrByteChar( ch, GetStreamEncoding() ); }
|
||||
bool WriteUniOrByteChar( sal_Unicode ch );
|
||||
|
||||
void SetBufferSize( sal_uInt16 m_nBufSize );
|
||||
sal_uInt16 GetBufferSize() const { return m_nBufSize; }
|
||||
|
||||
@@ -210,9 +210,9 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument& rDoc,
|
||||
OUString strFrom(cStrDelim);
|
||||
OUString strTo = strFrom + strFrom;
|
||||
aTmpStr = aTmpStr.replaceAll(strFrom, strTo);
|
||||
rOut.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rOut.WriteUniOrByteChar( cStrDelim );
|
||||
rOut.WriteUnicodeOrByteText(aTmpStr, eCharSet);
|
||||
rOut.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rOut.WriteUniOrByteChar( cStrDelim );
|
||||
}
|
||||
else if ( bContextOrNotAsciiEncoding )
|
||||
{
|
||||
@@ -224,9 +224,9 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument& rDoc,
|
||||
OUString aStrTo = aStrDelimDecoded + aStrDelimDecoded;
|
||||
aStrDec = aStrDec.replaceAll(aStrDelimDecoded, aStrTo);
|
||||
// write byte re-encoded
|
||||
rOut.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rOut.WriteUniOrByteChar( cStrDelim );
|
||||
rOut.WriteUnicodeOrByteText( aStrDec, eCharSet );
|
||||
rOut.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rOut.WriteUniOrByteChar( cStrDelim );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,7 +239,7 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument& rDoc,
|
||||
rOut.WriteBytes(aStrEnc.getStr(), aStrEnc.getLength());
|
||||
rOut.WriteBytes(aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
|
||||
}
|
||||
rOut.WriteUniOrByteChar( '\n', eCharSet );
|
||||
rOut.WriteUniOrByteChar( '\n' );
|
||||
}
|
||||
}
|
||||
aPrgrsBar.SetState( nRowCnt );
|
||||
|
||||
@@ -2099,10 +2099,10 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
|
||||
// import.
|
||||
aString = "sep=" + OUStringChar(cDelim);
|
||||
if (cStrDelim != 0)
|
||||
rStream.WriteUniOrByteChar( '"', eCharSet);
|
||||
rStream.WriteUniOrByteChar( '"');
|
||||
rStream.WriteUnicodeOrByteText(aString, eCharSet);
|
||||
if (cStrDelim != 0)
|
||||
rStream.WriteUniOrByteChar( '"', eCharSet);
|
||||
rStream.WriteUniOrByteChar( '"');
|
||||
endlub( rStream );
|
||||
++nStartRow;
|
||||
}
|
||||
@@ -2316,10 +2316,10 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
|
||||
}
|
||||
|
||||
if ( bNeedQuotes || bForceQuotes )
|
||||
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rStream.WriteUniOrByteChar( cStrDelim );
|
||||
rStream.WriteUnicodeOrByteText(aUniString, eCharSet);
|
||||
if ( bNeedQuotes || bForceQuotes )
|
||||
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rStream.WriteUniOrByteChar( cStrDelim );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2355,10 +2355,10 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
|
||||
|
||||
// write byte re-encoded
|
||||
if ( bNeedQuotes || bForceQuotes )
|
||||
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rStream.WriteUniOrByteChar( cStrDelim );
|
||||
rStream.WriteUnicodeOrByteText( aStrDec, eCharSet );
|
||||
if ( bNeedQuotes || bForceQuotes )
|
||||
rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
|
||||
rStream.WriteUniOrByteChar( cStrDelim );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -672,8 +672,9 @@ bool SvStream::WriteLine(std::string_view rStr)
|
||||
return m_nError == ERRCODE_NONE;
|
||||
}
|
||||
|
||||
bool SvStream::WriteUniOrByteChar(sal_Unicode ch, rtl_TextEncoding eDestEncoding)
|
||||
bool SvStream::WriteUniOrByteChar(sal_Unicode ch)
|
||||
{
|
||||
auto eDestEncoding = GetStreamEncoding();
|
||||
if (eDestEncoding == RTL_TEXTENCODING_UNICODE)
|
||||
WriteUnicode(ch);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user