diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-12-21 10:45:54 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-12-21 13:44:52 +0000 |
commit | 5c24789ca33d7b2b0c39626208cf0708fb470d95 (patch) | |
tree | a58015a4f6cafb9d567ca24831a442a4e976d972 /tools | |
parent | c4f0efc2378cebc3b581bc949da70a2b2f149961 (diff) |
disentangle Read/WriteByteString OUString variants
The ones which use a definite 8-bit encoding read/write pascal-style
strings with a 16bit length prefix.
The ones which use a definite 16-bit encoding read/write pascal-style
UTF-16 strings with a 32bit length prefix, i.e. not ByteStrings at all
The "I dunno" ones might be UTF-16 strings or 8-bit strings, depending
on the charset. Rename to ReadUniOrByteString like the other
similar horrors to flag this misery
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inc/tools/stream.hxx | 11 | ||||
-rw-r--r-- | tools/source/inet/inetmsg.cxx | 4 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 4 |
3 files changed, 10 insertions, 9 deletions
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index e6e939bbbd1b..4d316708b152 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -363,11 +363,6 @@ public: SvStream& operator<<( const unsigned char* pBuf ); SvStream& operator<<( SvStream& rStream ); - SvStream& ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ); - SvStream& ReadByteString( UniString& rStr ) { return ReadByteString( rStr, GetStreamCharSet() ); } - SvStream& WriteByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet ); - SvStream& WriteByteString( const UniString& rStr ) { return WriteByteString( rStr, GetStreamCharSet() ); } - SvStream& WriteNumber( sal_uInt32 nUInt32 ); SvStream& WriteNumber( sal_Int32 nInt32 ); @@ -412,6 +407,12 @@ public: /// Read a line of Unicode sal_Bool ReadUniStringLine( String& rStr ); + /// Read a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise read a 16bit length prefixed sequence of bytes and convert from eSrcCharSet + SvStream& ReadUniOrByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ); + /// Write a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise convert to eSrcCharSet and write a 16bit length prefixed sequence of bytes + SvStream& WriteUniOrByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet ); /// Read a line of Unicode if eSrcCharSet==RTL_TEXTENCODING_UNICODE, /// otherwise read a line of Bytecode and convert from eSrcCharSet sal_Bool ReadUniOrByteStringLine( String& rStr, rtl_TextEncoding eSrcCharSet ); diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index f626dcccd508..a49d382ef158 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -137,7 +137,7 @@ sal_uIntPtr INetMessage::SetHeaderField ( SvStream& INetMessage::operator<< (SvStream& rStrm) const { rStrm << static_cast<sal_uInt32>(m_nDocSize); - rStrm.WriteByteString (m_aDocName, RTL_TEXTENCODING_UTF8); + write_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8); sal_uIntPtr i, n = m_aHeaderList.size(); rStrm << static_cast<sal_uInt32>(n); @@ -163,7 +163,7 @@ SvStream& INetMessage::operator>> (SvStream& rStrm) // Copy. rStrm >> nTemp; m_nDocSize = nTemp; - rStrm.ReadByteString (m_aDocName, RTL_TEXTENCODING_UTF8); + m_aDocName = read_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8); sal_uIntPtr i, n = 0; rStrm >> nTemp; diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index b70195978008..aab11a6ffc51 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1489,7 +1489,7 @@ SvStream& SvStream::operator<< ( SvStream& rStream ) // ----------------------------------------------------------------------- -SvStream& SvStream::ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ) +SvStream& SvStream::ReadUniOrByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ) { // read UTF-16 string directly from stream ? if (eSrcCharSet == RTL_TEXTENCODING_UNICODE) @@ -1523,7 +1523,7 @@ SvStream& SvStream::ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSe // ----------------------------------------------------------------------- -SvStream& SvStream::WriteByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet ) +SvStream& SvStream::WriteUniOrByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet ) { // write UTF-16 string directly into stream ? if (eDestCharSet == RTL_TEXTENCODING_UNICODE) |