diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-10 21:11:32 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-11 07:10:31 +0100 |
commit | 2b4094195eb89d9bfd41908cbb32a8b964efd9fe (patch) | |
tree | 6cc9a0bef1d31990522c62c761e350743b7d60d9 /tools | |
parent | 90d732a5311551ae79969ee24d98cf21ffbacac7 (diff) |
Clean up SvStream API a bit
Change-Id: Ic9847185e8f551eeb05715902374d7a9a9032f60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160546
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index b948c12847c6..0fd67ccb2704 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -647,9 +647,9 @@ OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStream, rtl_TextEncodi read_zeroTerminated_uInt8s_ToOString(rStream), eEnc); } -/** Attempt to write a prefixed sequence of nUnits 16bit units from an OUString, +/** Attempt to write a sequence of nUnits 16bit units from an OUString, returned value is number of bytes written */ -std::size_t write_uInt16s_FromOUString(SvStream& rStrm, std::u16string_view rStr, +static std::size_t write_uInt16s_FromOUString(SvStream& rStrm, std::u16string_view rStr, std::size_t nUnits) { DBG_ASSERT( sizeof(sal_Unicode) == sizeof(sal_uInt16), "write_uInt16s_FromOUString: swapping sizeof(sal_Unicode) not implemented" ); @@ -676,19 +676,22 @@ std::size_t write_uInt16s_FromOUString(SvStream& rStrm, std::u16string_view rStr return nWritten; } -bool SvStream::WriteUnicodeOrByteText( std::u16string_view rStr, rtl_TextEncoding eDestCharSet ) +bool SvStream::WriteUnicodeOrByteText(std::u16string_view rStr, rtl_TextEncoding eDestCharSet, bool bZero) { if ( eDestCharSet == RTL_TEXTENCODING_UNICODE ) { write_uInt16s_FromOUString(*this, rStr, rStr.size()); - return m_nError == ERRCODE_NONE; + if (bZero) + WriteUnicode(0); } else { OString aStr(OUStringToOString(rStr, eDestCharSet)); - write_uInt8s_FromOString(*this, aStr, aStr.getLength()); - return m_nError == ERRCODE_NONE; + WriteBytes(aStr.getStr(), aStr.getLength()); + if (bZero) + WriteChar(0); } + return m_nError == ERRCODE_NONE; } bool SvStream::WriteByteStringLine( std::u16string_view rStr, rtl_TextEncoding eDestCharSet ) @@ -1985,7 +1988,7 @@ std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream& rStrm, if (rStrm.good()) { nWritten += sizeof(sal_uInt16); - nWritten += write_uInt8s_FromOString(rStrm, rStr, nUnits); + nWritten += rStrm.WriteBytes(rStr.data(), nUnits); } return nWritten; } |