don't need to realloc string
Change-Id: I17ec5a54b0088b56bd8c8431eb255626dbb1fac8
This commit is contained in:
parent
17ebc5540e
commit
df4c929bc3
2 changed files with 9 additions and 10 deletions
|
@ -49,7 +49,8 @@ namespace comphelper { namespace string {
|
|||
/** Allocate a new string containing space for a given number of characters.
|
||||
|
||||
The reference count of the new string will be 1. The length of the string
|
||||
will be nLen. This function does not handle out-of-memory conditions.
|
||||
will be nLen. This function throws std::bad_alloc on out-of-memory
|
||||
conditions.
|
||||
|
||||
The characters of the capacity are not cleared, and the length is set to
|
||||
nLen, unlike the similar method of rtl_uString_new_WithLength which
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue