summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-02 09:46:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-02 11:06:46 +0100
commit6b332a25d7b413e24d05928343f6e4e943e725b1 (patch)
tree5ec14408e0a630c28339fb2f1a4c05b37762f0f4
parentb9459499d951d4530d6a271e0f0bc42b22c03130 (diff)
convert in one pass, rather than point by point
-rw-r--r--filter/source/msfilter/msdffimp.cxx18
1 files changed, 7 insertions, 11 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 84d742104..7d6e923dc 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -143,6 +143,7 @@
#include <com/sun/star/drawing/ProjectionMode.hpp>
#include "svx/EnhancedCustomShape2d.hxx"
#include <rtl/strbuf.hxx>
+#include <boost/scoped_array.hpp>
using namespace ::com::sun::star ;
using namespace ::com::sun::star::drawing;
@@ -4126,16 +4127,14 @@ void SvxMSDffManager::MSDFFReadZString( SvStream& rIn, String& rStr,
sal_uInt16 nLen = (sal_uInt16)nRecLen;
if( nLen )
{
- if ( bUniCode )
- nLen >>= 1;
-
String sBuf;
- sal_Unicode* pBuf = sBuf.AllocBuffer( nLen );
if( bUniCode )
{
- rIn.Read( (sal_Char*)pBuf, nLen << 1 );
+ nLen >>= 1;
+ sal_Unicode* pBuf = sBuf.AllocBuffer(nLen);
+ rIn.Read( (sal_Char*)pBuf, nLen << 1 );
#ifdef OSL_BIGENDIAN
for( sal_uInt16 n = 0; n < nLen; ++n, ++pBuf )
*pBuf = SWAPSHORT( *pBuf );
@@ -4143,12 +4142,9 @@ void SvxMSDffManager::MSDFFReadZString( SvStream& rIn, String& rStr,
}
else
{
- // use the String-Data as buffer for the 8bit characters and
- // change then all to unicode
- sal_Char* pReadPos = ((sal_Char*)pBuf) + nLen;
- rIn.Read( (sal_Char*)pReadPos, nLen );
- for( sal_uInt16 n = 0; n < nLen; ++n, ++pBuf, ++pReadPos )
- *pBuf = ByteString::ConvertToUnicode( *pReadPos, RTL_TEXTENCODING_MS_1252 );
+ boost::scoped_array<sal_Char> xBuffer(new sal_Char[nLen]);
+ nLen = rIn.Read(xBuffer.get(), nLen);
+ sBuf = rtl::OUString(xBuffer.get(), nLen, RTL_TEXTENCODING_MS_1252);
}
rStr = sBuf.EraseTrailingChars( 0 );