summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-06 08:50:03 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-01-06 09:52:42 +0000
commit2d3203b2db5b44592e70e52c9927324b65a45e06 (patch)
treea175859b1be2a2ee2ca598a6b8a9f34c25ea40f2 /tools
parent0100280a5c5b121fab2aa932092a7a887bbb507c (diff)
make ReadUniOrByteString return a string
Diffstat (limited to 'tools')
-rw-r--r--tools/inc/tools/stream.hxx2
-rw-r--r--tools/source/stream/stream.cxx21
2 files changed, 12 insertions, 11 deletions
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index 0ef6140007d1..52ae39498154 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -409,7 +409,7 @@ public:
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 );
+ String ReadUniOrByteString(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 );
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);
}
// -----------------------------------------------------------------------