diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-06 08:50:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-01-06 09:52:42 +0000 |
commit | 2d3203b2db5b44592e70e52c9927324b65a45e06 (patch) | |
tree | a175859b1be2a2ee2ca598a6b8a9f34c25ea40f2 /tools/source | |
parent | 0100280a5c5b121fab2aa932092a7a887bbb507c (diff) |
make ReadUniOrByteString return a string
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/stream/stream.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 8e2cbb0646e2..1b31103b0e03 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1489,36 +1489,37 @@ SvStream& SvStream::operator<< ( SvStream& rStream ) // ----------------------------------------------------------------------- -SvStream& SvStream::ReadUniOrByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ) +String SvStream::ReadUniOrByteString( rtl_TextEncoding eSrcCharSet ) { // read UTF-16 string directly from stream ? if (eSrcCharSet == RTL_TEXTENCODING_UNICODE) { - sal_uInt32 nLen; + String aStr; + sal_uInt32 nLen(0); operator>> (nLen); if (nLen) { - if (nLen > STRING_MAXLEN) { + if (nLen > STRING_MAXLEN) + { SetError(SVSTREAM_GENERALERROR); - return *this; + return aStr; } - sal_Unicode *pStr = rStr.AllocBuffer( + sal_Unicode *pStr = aStr.AllocBuffer( static_cast< xub_StrLen >(nLen)); BOOST_STATIC_ASSERT(STRING_MAXLEN <= SAL_MAX_SIZE / 2); Read( pStr, nLen << 1 ); if (bSwap) + { for (sal_Unicode *pEnd = pStr + nLen; pStr < pEnd; pStr++) SwapUShort(*pStr); + } } - else - rStr.Erase(); - return *this; + return aStr; } - rStr = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(*this, eSrcCharSet); - return *this; + return read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(*this, eSrcCharSet); } // ----------------------------------------------------------------------- |