[Libreoffice-commits] .: 2 commits - basic/source comphelper/inc editeng/source svtools/source
Caolán McNamara
caolan at kemper.freedesktop.org
Tue Jun 12 05:37:38 PDT 2012
basic/source/comp/scanner.cxx | 5 ++---
comphelper/inc/comphelper/string.hxx | 3 ++-
editeng/source/editeng/editdoc.cxx | 16 +++++++---------
svtools/source/edit/textdoc.cxx | 2 +-
4 files changed, 12 insertions(+), 14 deletions(-)
New commits:
commit 7d042c50f5b8e1d61f0615ae8aff5714840be01b
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Jun 12 13:33:37 2012 +0100
use rtl_ustr_getLength instead of a temporary string just to find length
Change-Id: Ibbf777e57af6b98611cb5dce5a31517de80305b7
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 6f7f0bd..cef84c9 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -433,8 +433,7 @@ bool SbiScanner::NextSym()
// from 4.1.1996: buffer full, go on scanning empty
if( (p-buf) == (BUF_SIZE-1) )
bBufOverflow = true;
- else if( String( cmp ).Search( ch ) != STRING_NOTFOUND )
- //else if( strchr( cmp, ch ) )
+ else if( rtl::OUString( cmp ).indexOf( ch ) != -1 )
*p++ = ch;
else
{
@@ -522,7 +521,7 @@ PrevLineCommentLbl:
{
bPrevLineExtentsComment = false;
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REM"));
- sal_Int32 nLen = String( pLine ).Len();
+ sal_Int32 nLen = rtl_ustr_getLength(pLine);
if( bCompatible && pLine[ nLen - 1 ] == '_' && pLine[ nLen - 2 ] == ' ' )
bPrevLineExtentsComment = true;
nCol2 = nCol2 + nLen;
diff --git a/svtools/source/edit/textdoc.cxx b/svtools/source/edit/textdoc.cxx
index 5ca9997..a8062ec 100644
--- a/svtools/source/edit/textdoc.cxx
+++ b/svtools/source/edit/textdoc.cxx
@@ -553,7 +553,7 @@ sal_uLong TextDoc::GetTextLen( const xub_Unicode* pSep, const TextSelection* pSe
}
if ( pSep )
- nLen += (nEndNode-nStartNode) * String( pSep ).Len();
+ nLen += (nEndNode-nStartNode) * rtl_ustr_getLength(pSep);
}
return nLen;
commit df4c929bc36c168a55c3467c783fd0256b90dc45
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Jun 12 09:51:38 2012 +0100
don't need to realloc string
Change-Id: I17ec5a54b0088b56bd8c8431eb255626dbb1fac8
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 8a763e8..9088327 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -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
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 110daf5..fe747c3 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
More information about the Libreoffice-commits
mailing list