diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-07 09:13:47 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-08-07 16:14:45 +0100 |
commit | aac04652fda01b0299e17087b151f07d6115e894 (patch) | |
tree | 26a71ba651eb138d81f538b0d43b66f8da8e305d /tools/source/stream | |
parent | db95e0b75903a34a1b88a3701334e154f32eeceb (diff) |
String::AllocBuffer replacements
Change-Id: I278cd66fb4819721bb473796c28598aaf04eb123
Diffstat (limited to 'tools/source/stream')
-rw-r--r-- | tools/source/stream/stream.cxx | 55 |
1 files changed, 4 insertions, 51 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index b188cabdc0af..0f3e9b53b139 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1399,32 +1399,7 @@ rtl::OUString SvStream::ReadUniOrByteString( rtl_TextEncoding eSrcCharSet ) { // read UTF-16 string directly from stream ? if (eSrcCharSet == RTL_TEXTENCODING_UNICODE) - { - String aStr; - sal_uInt32 nLen(0); - operator>> (nLen); - if (nLen) - { - if (nLen > STRING_MAXLEN) - { - SetError(SVSTREAM_GENERALERROR); - return aStr; - } - 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); - } - } - - return aStr; - } - + return read_lenPrefixed_uInt16s_ToOUString<sal_uInt32>(*this); return read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(*this, eSrcCharSet); } @@ -1434,31 +1409,9 @@ SvStream& SvStream::WriteUniOrByteString( const rtl::OUString& rStr, rtl_TextEnc { // write UTF-16 string directly into stream ? if (eDestCharSet == RTL_TEXTENCODING_UNICODE) - { - sal_Int32 nLen = rStr.getLength(); - operator<< (nLen); - if (nLen) - { - if (bSwap) - { - const sal_Unicode *pStr = rStr.getStr(); - const sal_Unicode *pEnd = pStr + nLen; - - for (; pStr < pEnd; pStr++) - { - sal_Unicode c = *pStr; - SwapUShort(c); - WRITENUMBER_WITHOUT_SWAP(sal_uInt16,c) - } - } - else - Write( rStr.getStr(), nLen << 1 ); - } - - return *this; - } - - write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(*this, rStr, eDestCharSet); + write_lenPrefixed_uInt16s_FromOUString<sal_uInt32>(*this, rStr); + else + write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(*this, rStr, eDestCharSet); return *this; } |