summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2014-03-01 20:20:59 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2014-03-02 20:17:59 +0100
commita90760a056056fdf1fc4dbdb6464f2a84b0fc617 (patch)
tree73c46c3437821d3125f85553b27ebbc84f09516c /editeng
parent0ea119318a9102e145ad007811759281afbe7305 (diff)
Use OUStringBuffer instead of rtl_uString in EditDoc::GetText
Change-Id: I292c2b726de3e6c27f05fdf7612fe057ae9f94ad
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.cxx29
1 files changed, 12 insertions, 17 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 86a9548911b7..78124b853446 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -55,6 +55,8 @@
#include <editeng/eerdll.hxx>
#include <eerdll2.hxx>
+#include <rtl/ustrbuf.hxx>
+
#include <tools/stream.hxx>
#include <tools/debug.hxx>
#include <tools/shl.hxx>
@@ -2082,33 +2084,26 @@ OUString EditDoc::GetSepStr( LineEnd eEnd )
OUString EditDoc::GetText( LineEnd eEnd ) const
{
- sal_uLong nLen = GetTextLen();
- sal_Int32 nNodes = Count();
+ const sal_Int32 nNodes = Count();
if (nNodes == 0)
return OUString();
- OUString aSep = EditDoc::GetSepStr( eEnd );
- sal_Int32 nSepSize = aSep.getLength();
+ const OUString aSep = EditDoc::GetSepStr( eEnd );
+ const sal_Int32 nSepSize = aSep.getLength();
+ const sal_uLong nLen = GetTextLen() + (nNodes - 1)*nSepSize;
- if ( nSepSize )
- nLen += (nNodes - 1) * nSepSize;
+ OUStringBuffer aBuffer(nLen + 16); // leave some slack
- rtl_uString* newStr = rtl_uString_alloc(nLen);
- sal_Unicode* pCur = newStr->buffer;
- sal_Int32 nLastNode = nNodes-1;
for ( sal_Int32 nNode = 0; nNode < nNodes; nNode++ )
{
- OUString aTmp( GetParaAsString( GetObject(nNode) ) );
- memcpy( pCur, aTmp.getStr(), aTmp.getLength() * sizeof(sal_Unicode) );
- pCur += aTmp.getLength();
- if ( nSepSize && ( nNode != nLastNode ) )
+ if ( nSepSize && nNode>0 )
{
- memcpy( pCur, aSep.getStr(), nSepSize * sizeof(sal_Unicode ) );
- pCur += nSepSize;
+ aBuffer.append(aSep);
}
+ aBuffer.append(GetParaAsString( GetObject(nNode) ));
}
- assert(pCur - newStr->buffer == newStr->length);
- return OUString(newStr, SAL_NO_ACQUIRE);
+
+ return aBuffer.makeStringAndClear();
}
OUString EditDoc::GetParaAsString( sal_Int32 nNode ) const