diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-12 09:51:38 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-06-12 13:35:49 +0100 |
commit | df4c929bc36c168a55c3467c783fd0256b90dc45 (patch) | |
tree | 645c086662ca4b710e46c7427af39c2a05ba5c1f /editeng | |
parent | 17ebc5540e3f80b04d38ba2000a1db96822874f6 (diff) |
don't need to realloc string
Change-Id: I17ec5a54b0088b56bd8c8431eb255626dbb1fac8
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 110daf5e58d0..fe747c35786a 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ - +#include <comphelper/string.hxx> #include <vcl/wrkwin.hxx> #include <vcl/dialog.hxx> #include <vcl/msgbox.hxx> @@ -2037,7 +2037,7 @@ XubString EditDoc::GetText( LineEnd eEnd ) const sal_uLong nLen = GetTextLen(); size_t nNodes = Count(); if (nNodes == 0) - return String(); + return rtl::OUString(); rtl::OUString aSep = EditDoc::GetSepStr( eEnd ); sal_Int32 nSepSize = aSep.getLength(); @@ -2047,10 +2047,11 @@ XubString EditDoc::GetText( LineEnd eEnd ) const if ( nLen > 0xFFFb / sizeof(xub_Unicode) ) { OSL_FAIL( "Text too large for String" ); - return String(); + return rtl::OUString(); } - xub_Unicode* pStr = new xub_Unicode[nLen+1]; - xub_Unicode* pCur = pStr; + + rtl_uString* newStr = comphelper::string::rtl_uString_alloc(nLen); + xub_Unicode* pCur = newStr->buffer; size_t nLastNode = nNodes-1; for ( sal_uInt16 nNode = 0; nNode < nNodes; nNode++ ) { @@ -2063,10 +2064,7 @@ XubString EditDoc::GetText( LineEnd eEnd ) const pCur += nSepSize; } } - *pCur = '\0'; - String aASCIIText( pStr ); - delete[] pStr; - return aASCIIText; + return rtl::OUString(newStr, SAL_NO_ACQUIRE); } XubString EditDoc::GetParaAsString( sal_uInt16 nNode ) const |