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 /sw | |
parent | db95e0b75903a34a1b88a3701334e154f32eeceb (diff) |
String::AllocBuffer replacements
Change-Id: I278cd66fb4819721bb473796c28598aaf04eb123
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/edit/edglss.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 29 | ||||
-rw-r--r-- | sw/source/filter/ascii/parasc.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/basflt/iodetect.cxx | 9 |
4 files changed, 21 insertions, 39 deletions
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 71dd8b047814..50f479fe68d1 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include <comphelper/string.hxx> #include <osl/endian.h> #include <hintids.hxx> #include <svl/urihelper.hxx> @@ -344,15 +345,16 @@ sal_Bool SwEditShell::GetSelectedText( String &rBuf, int nHndlParaBrk ) const sal_Unicode *p = (sal_Unicode*)aStream.GetBuffer(); if( p ) - rBuf = p; + rBuf = rtl::OUString(p); else { - sal_Unicode* pStrBuf = rBuf.AllocBuffer( xub_StrLen( - ( lLen / sizeof( sal_Unicode ))) ); + using comphelper::string::rtl_uString_alloc; + rtl_uString *pStr = rtl_uString_alloc(lLen / sizeof( sal_Unicode )); aStream.Seek( 0 ); aStream.ResetError(); - aStream.Read( pStrBuf, lLen ); - pStrBuf[ lLen / sizeof( sal_Unicode ) ] = '\0'; + //endian specific?, yipes! + aStream.Read(pStr->buffer, lLen); + rBuf = rtl::OUString(pStr, SAL_NO_ACQUIRE); } } } diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 28d4557f318b..d419533f4b22 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -27,7 +27,7 @@ ************************************************************************/ #include <com/sun/star/table/TableSortField.hpp> - +#include <comphelper/string.hxx> #include <osl/endian.h> #include <rtl/ustrbuf.hxx> #include <unotools/collatorwrapper.hxx> @@ -211,30 +211,13 @@ void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer) { aStream << (sal_Unicode)'\0'; - long lUniLen = (lLen / sizeof( sal_Unicode )); - ::rtl::OUStringBuffer aStrBuffer( lUniLen ); aStream.Seek( 0 ); aStream.ResetError(); - while(lUniLen) - { - String sBuf; - sal_Int32 nLocalLen = 0; - if( lUniLen >= STRING_MAXLEN ) - { - nLocalLen = STRING_MAXLEN - 1; - } - else - { - nLocalLen = lUniLen; - } - sal_Unicode *const pStrBuf = - sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); - aStream.Read( pStrBuf, 2 * nLocalLen ); - pStrBuf[ nLocalLen ] = '\0'; - aStrBuffer.append( pStrBuf, nLocalLen ); - lUniLen -= nLocalLen; - } - rBuffer = aStrBuffer.makeStringAndClear(); + + long lUniLen = (lLen / sizeof( sal_Unicode )); + rtl_uString *pStr = comphelper::string::rtl_uString_alloc(lUniLen); + aStream.Read(pStr->buffer, lUniLen * sizeof(sal_Unicode)); + rBuffer = rtl::OUString(pStr, SAL_NO_ACQUIRE); } xWrt->bShowProgress = bOldShowProgress; } diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index 1dea0d1b18f1..ec68e011f138 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ - +#include <boost/scoped_array.hpp> #include <tools/stream.hxx> #include <hintids.hxx> #include <rtl/tencinfo.h> @@ -303,7 +303,7 @@ sal_uLong SwASCIIParser::ReadChars() bSwapUnicode = rInput.IsEndianSwap(); } - String sWork; + boost::scoped_array<sal_Unicode> aWork; sal_uLong nArrOffset = 0; do { @@ -331,7 +331,8 @@ sal_uLong SwASCIIParser::ReadChars() { sal_uInt32 nInfo; sal_Size nNewLen = lGCount, nCntBytes; - sal_Unicode* pBuf = sWork.AllocBuffer( static_cast< xub_StrLen >(nNewLen) ); + aWork.reset(new sal_Unicode[nNewLen]); + sal_Unicode* pBuf = aWork.get(); nNewLen = rtl_convertTextToUnicode( hConverter, hContext, pArr, lGCount, pBuf, nNewLen, @@ -345,9 +346,8 @@ sal_uLong SwASCIIParser::ReadChars() &nCntBytes ); if( 0 != ( nArrOffset = lGCount - nCntBytes ) ) memmove( pArr, pArr + nCntBytes, nArrOffset ); - sWork.ReleaseBufferAccess( static_cast< xub_StrLen >(nNewLen) ); - pStt = pLastStt = sWork.GetBufferAccess(); + pStt = pLastStt = aWork.get(); pEnd = pStt + nNewLen; } else diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx index 6c211f8e8bc7..88c26d7ff43e 100644 --- a/sw/source/filter/basflt/iodetect.cxx +++ b/sw/source/filter/basflt/iodetect.cxx @@ -28,7 +28,7 @@ #include <iodetect.hxx> - +#include <boost/scoped_array.hpp> #include <osl/endian.h> #include <sot/storage.hxx> #include <svtools/parhtml.hxx> @@ -450,8 +450,8 @@ bool SwIoSystem::IsDetectableText(const sal_Char* pBuf, sal_uLong &rLen, if (eCharSet != RTL_TEXTENCODING_DONTKNOW) { - String sWork; - sal_Unicode *pNewBuf = sWork.AllocBuffer( static_cast< xub_StrLen >(rLen)); + boost::scoped_array<sal_Unicode> aWork(new sal_Unicode[rLen]); + sal_Unicode *pNewBuf = aWork.get(); sal_Size nNewLen; if (eCharSet != RTL_TEXTENCODING_UCS2) { @@ -495,9 +495,6 @@ bool SwIoSystem::IsDetectableText(const sal_Char* pBuf, sal_uLong &rLen, } } - sWork.ReleaseBufferAccess( static_cast< xub_StrLen >(nNewLen) ); - pNewBuf = sWork.GetBufferAccess(); - for (sal_uLong nCnt = 0; nCnt < nNewLen; ++nCnt, ++pNewBuf) { switch (*pNewBuf) |