[Libreoffice-commits] .: 3 commits - basic/source editeng/source sc/inc sc/source svl/inc svl/source sw/source tools/inc tools/source vcl/inc vcl/Library_vclplug_gen.mk vcl/source vcl/unx
Caolán McNamara
caolan at kemper.freedesktop.org
Tue Aug 7 08:15:41 PDT 2012
basic/source/sbx/sbxscan.cxx | 7
editeng/source/editeng/editobj.cxx | 16 +-
editeng/source/items/flditem.cxx | 34 ++--
sc/inc/stringutil.hxx | 5
sc/source/core/tool/stringutil.cxx | 127 +++++++++++++++++
sc/source/filter/excel/xicontent.cxx | 5
sc/source/ui/dbgui/validate.cxx | 5
svl/inc/svl/zformat.hxx | 2
svl/source/numbers/zformat.cxx | 50 +++---
sw/source/core/edit/edglss.cxx | 12 -
sw/source/core/unocore/unoobj.cxx | 29 ----
sw/source/filter/ascii/parasc.cxx | 10 -
sw/source/filter/basflt/iodetect.cxx | 9 -
tools/inc/tools/stream.hxx | 7
tools/inc/tools/string.hxx | 13 -
tools/source/stream/stream.cxx | 55 -------
tools/source/string/tustring.cxx | 135 ------------------
vcl/Library_vclplug_gen.mk | 1
vcl/inc/unx/XIM.h | 17 --
vcl/source/gdi/cvtsvm.cxx | 14 -
vcl/unx/generic/app/i18n_wrp.cxx | 251 -----------------------------------
21 files changed, 225 insertions(+), 579 deletions(-)
New commits:
commit 4d6dab2cde759551ceee7e6aaec89fa5235b1ecc
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Aug 7 15:04:50 2012 +0100
ditch obsolete XvaOpenIM stuff
Change-Id: Id6977932781909c81e4a5dc071f50308a58748cf
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 845c568..88e997b 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -68,7 +68,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
vcl/unx/generic/app/i18n_im \
vcl/unx/generic/app/i18n_keysym \
vcl/unx/generic/app/i18n_status \
- vcl/unx/generic/app/i18n_wrp \
vcl/unx/generic/app/i18n_xkb \
vcl/unx/generic/app/keysymnames \
vcl/unx/generic/app/randrwrapper \
diff --git a/vcl/inc/unx/XIM.h b/vcl/inc/unx/XIM.h
index d124264..8826148 100644
--- a/vcl/inc/unx/XIM.h
+++ b/vcl/inc/unx/XIM.h
@@ -22,11 +22,6 @@
#include <X11/Xlib.h>
#include <X11/Xresource.h>
-#ifdef __cplusplus
-extern "C"
-#endif
-XIM XvaOpenIM( Display*, XrmDatabase, char*, char*, ... );
-
extern Status XCloseIM(XIM);
#ifndef XIMCallback1
@@ -110,22 +105,10 @@ typedef struct _XIMSwitchIMNotifyCallbackStruct {
XIMUnicodeCharacterSubset *to;
} XIMSwitchIMNotifyCallbackStruct;
-/* XIM attributes for multilingual IM extension */
-#define XNMultiLingualInput "multiLingualInput"
-#define XNQueryUnicodeCharacterSubset "unicodeCharacterSubset"
-
/* XIC attributes for multilingual IM extension */
#define XNUnicodeCharacterSubset "UnicodeChararcterSubset"
-#define XNSwitchIMNotifyCallback "switchIMNotifyCallback"
-#define XNCommitStringCallback "commitStringCallback"
-#define XNForwardEventCallback "forwardEventCallback"
-
-#define XNLookupStartCallback "lookupStartCallback"
-#define XNLookupDrawCallback "lookupDrawCallback"
-#define XNLookupDoneCallback "lookupDoneCallback"
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/app/i18n_wrp.cxx b/vcl/unx/generic/app/i18n_wrp.cxx
deleted file mode 100644
index e152135..0000000
--- a/vcl/unx/generic/app/i18n_wrp.cxx
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-struct XIMArg
-{
- char *name;
- char *value;
-};
-
-#if defined(SOLARIS) && !defined(__GNUC__)
-#include <varargs.h>
-#else
-#include <stdarg.h>
-#endif
-#include <sal/alloca.h>
-
-#include <string.h>
-#include <dlfcn.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xlibint.h>
-#include "unx/XIM.h"
-
-#define XIIIMP_LIB "xiiimp.so.2"
-
-#ifdef SOLARIS
-#define XIIIMP_PATH "/usr/openwin/lib/locale/common/" XIIIMP_LIB
-#else /* Linux */
-#define XIIIMP_PATH "/usr/lib/im/" XIIIMP_LIB
-#endif
-
-extern "C" {
-typedef XIM (*OpenFunction)(Display*, XrmDatabase, char*, char*, XIMArg*);
-}
-
-/* global variables */
-static void *g_dlmodule = 0;
-static OpenFunction g_open_im = (OpenFunction)NULL;
-
-/* utility function to transform vararg list into an array of XIMArg */
-
-int
-XvaCountArgs( XIMArg *pInArgs )
-{
- int nArgs = 0;
- char *pName, *pValue;
-
- while ( (pName = pInArgs->name) != NULL )
- {
- pValue = pInArgs->value;
-
- if ( strcmp(pName, XNVaNestedList) == 0 )
- {
- nArgs += XvaCountArgs( (XIMArg*)pValue );
- }
- else
- {
- nArgs += 1;
- }
- pInArgs++;
- }
-
- return nArgs;
-}
-
-int
-XvaCountArgs( va_list pInArgs )
-{
- int nArgs = 0;
- char *pName, *pValue;
-
- while ( (pName = va_arg(pInArgs, char*)) != NULL)
- {
- pValue = va_arg(pInArgs, char*);
-
- if ( strcmp(pName, XNVaNestedList) == 0 )
- {
- nArgs += XvaCountArgs( (XIMArg*)pValue );
- }
- else
- {
- nArgs += 1;
- }
- }
-
- return nArgs;
-}
-
-XIMArg*
-XvaGetArgs( XIMArg *pInArgs, XIMArg *pOutArgs )
-{
- char *pName, *pValue;
-
- while ( (pName = pInArgs->name) != NULL )
- {
- pValue = pInArgs->value;
-
- if ( strcmp(pName, XNVaNestedList) == 0 )
- {
- pOutArgs = XvaGetArgs( (XIMArg*)pValue, pOutArgs );
- }
- else
- {
- pOutArgs->name = pName;
- pOutArgs->value = pValue;
- pOutArgs++;
- }
- pInArgs++;
- }
-
- return pOutArgs;
-}
-
-void
-XvaGetArgs( va_list pInArgs, XIMArg *pOutArgs )
-{
- char *pName, *pValue;
-
- while ((pName = va_arg(pInArgs, char*)) != NULL)
- {
- pValue = va_arg(pInArgs, char*);
-
- if ( strcmp(pName, XNVaNestedList) == 0 )
- {
- pOutArgs = XvaGetArgs( (XIMArg*)pValue, pOutArgs );
- }
- else
- {
- pOutArgs->name = pName;
- pOutArgs->value = pValue;
- pOutArgs++;
- }
- }
-
- pOutArgs->name = NULL;
- pOutArgs->value = NULL;
-}
-
-
-/* Puplic functions */
-
-#ifdef __cplusplus
-extern "C"
-#endif
-XIM
-XvaOpenIM(Display *display, XrmDatabase rdb,
- char *res_name, char *res_class, ...)
-{
- XIM xim = (XIM)0;
- va_list variable;
- int total_count = 0;
-
- /*
- * so count the stuff dangling here
- */
-
-#if defined(SOLARIS) && !defined(__GNUC__)
- va_start(variable);
-#else
- va_start(variable, res_class);
-#endif
- total_count = XvaCountArgs(variable);
- va_end(variable);
-
- if (total_count > 0)
- {
- /* call a new open IM method */
-
- XIMArg* args = (XIMArg*)alloca( (total_count + 1) * sizeof(XIMArg) );
-
- /*
- * now package it up so we can set it along
- */
-#if defined(SOLARIS) && !defined(__GNUC__)
- va_start(variable);
-#else
- va_start(variable, res_class);
-#endif
- XvaGetArgs( variable, args );
- va_end(variable);
-
- if (!g_dlmodule)
- {
- g_dlmodule = dlopen(XIIIMP_LIB, RTLD_LAZY);
- if(!g_dlmodule)
- {
- g_dlmodule = dlopen(XIIIMP_PATH, RTLD_LAZY);
- if (!g_dlmodule)
- goto legacy_XIM;
- }
- g_open_im = (OpenFunction)(long)dlsym(g_dlmodule, "__XOpenIM");
- if (!g_open_im)
- goto legacy_XIM;
-
- xim = (*g_open_im)(display, (XrmDatabase)rdb,
- (char*)res_name, (char *)res_class, (XIMArg*)args);
- }
- else
- {
- goto legacy_XIM;
- }
- }
-
-// in #if to prevent warning "warning: label 'legacy_XIM' defined but not used"
- legacy_XIM:
-
- if (!xim)
- xim = XOpenIM(display, rdb, res_name, res_class);
-
- return xim;
-}
-
-/*
- * Close the connection to the input manager, and free the XIM structure
- */
-
-Status XvaCloseIM(XIM)
-{
- Status s = False;
-
- if (g_dlmodule)
- {
- /* assuming one XvaOpenIM call */
- dlclose(g_dlmodule);
- g_dlmodule = (void*)0;
- g_open_im = (OpenFunction)NULL;
- s = True;
- }
- return (s);
-}
-
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit aac04652fda01b0299e17087b151f07d6115e894
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Aug 7 09:13:47 2012 +0100
String::AllocBuffer replacements
Change-Id: I278cd66fb4819721bb473796c28598aaf04eb123
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index 9a47d8e..32db97f 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -785,9 +785,10 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const
if( nMin < 10 && aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_NN ) )
{
// Minute in two digits
- sal_Unicode* p = rRes.AllocBuffer( 2 );
- *p++ = '0';
- *p = sal_Unicode( '0' + nMin );
+ sal_Unicode aBuf[2];
+ aBuf[0] = '0';
+ aBuf[1] = '0' + nMin;
+ rRes = rtl::OUString(aBuf, SAL_N_ELEMENTS(aBuf));
}
else
{
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index ef84d0b..605bf68 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -26,7 +26,7 @@
*
************************************************************************/
-
+#include <comphelper/string.hxx>
#include <rtl/strbuf.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/dialog.hxx>
@@ -1444,6 +1444,8 @@ void BinTextObject::CreateData( SvStream& rIStream )
rIStream >> bUnicodeStrings;
if ( bUnicodeStrings )
{
+ using comphelper::string::rtl_uString_alloc;
+
for ( sal_uInt16 nPara = 0; nPara < nParagraphs; nPara++ )
{
ContentInfo& rC = aContents[nPara];
@@ -1453,18 +1455,18 @@ void BinTextObject::CreateData( SvStream& rIStream )
rIStream >> nL;
if ( nL )
{
- rC.GetText().AllocBuffer( nL );
- rIStream.Read(rC.GetText().GetBufferAccess(), nL*sizeof(sal_Unicode));
- rC.GetText().ReleaseBufferAccess(nL);
+ rtl_uString *pStr = rtl_uString_alloc(nL);
+ rIStream.Read(pStr->buffer, nL*sizeof(sal_Unicode));
+ rC.GetText() = rtl::OUString(pStr, SAL_NO_ACQUIRE);
}
// StyleSheetName
rIStream >> nL;
if ( nL )
{
- rC.GetStyle().AllocBuffer(nL);
- rIStream.Read(rC.GetStyle().GetBufferAccess(), nL*sizeof(sal_Unicode) );
- rC.GetStyle().ReleaseBufferAccess(nL);
+ rtl_uString *pStr = rtl_uString_alloc(nL);
+ rIStream.Read(pStr->buffer, nL*sizeof(sal_Unicode) );
+ rC.GetStyle() = rtl::OUString(pStr, SAL_NO_ACQUIRE);
}
}
}
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index 6a42e4b..632e00e 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -26,6 +26,7 @@
*
************************************************************************/
+#include <comphelper/string.hxx>
#include <vcl/metaact.hxx>
#include <svl/zforlist.hxx>
#include <tools/urlobj.hxx>
@@ -550,25 +551,28 @@ int SvxURLField::operator==( const SvxFieldData& rOther ) const
// -----------------------------------------------------------------------
-static void write_unicode( SvPersistStream & rStm, const String& rString )
+static void write_unicode( SvPersistStream & rStm, const rtl::OUString& rString )
{
- sal_uInt16 nL = rString.Len();
+ sal_uInt16 nL = sal::static_int_cast<sal_uInt16>(rString.getLength());
rStm << nL;
- rStm.Write( rString.GetBuffer(), nL*sizeof(sal_Unicode) );
+ //endian specific?, yipes!
+ rStm.Write( rString.getStr(), nL*sizeof(sal_Unicode) );
}
-static void read_unicode( SvPersistStream & rStm, rtl::OUString& rString )
+static rtl::OUString read_unicode( SvPersistStream & rStm )
{
+ rtl_uString *pStr = NULL;
sal_uInt16 nL = 0;
rStm >> nL;
- String aStr;
if ( nL )
{
- aStr.AllocBuffer( nL );
- rStm.Read( aStr.GetBufferAccess(), nL*sizeof(sal_Unicode) );
- aStr.ReleaseBufferAccess( nL );
+ using comphelper::string::rtl_uString_alloc;
+ pStr = rtl_uString_alloc(nL);
+ //endian specific?, yipes!
+ rStm.Read(pStr->buffer, nL*sizeof(sal_Unicode));
}
- rString = aStr;
+ //take ownership of buffer and return, otherwise return empty string
+ return pStr ? rtl::OUString(pStr, SAL_NO_ACQUIRE) : rtl::OUString();
}
void SvxURLField::Load( SvPersistStream & rStm )
@@ -578,9 +582,9 @@ void SvxURLField::Load( SvPersistStream & rStm )
rStm >> nFormat;
eFormat= (SvxURLFormat)nFormat;
- read_unicode( rStm, aURL );
- read_unicode( rStm, aRepresentation );
- read_unicode( rStm, aTargetFrame );
+ aURL = read_unicode( rStm );
+ aRepresentation = read_unicode( rStm );
+ aTargetFrame = read_unicode( rStm );
}
// -----------------------------------------------------------------------
@@ -1088,9 +1092,9 @@ void SvxAuthorField::Load( SvPersistStream & rStm )
{
sal_uInt16 nType = 0, nFormat = 0;
- read_unicode( rStm, aName );
- read_unicode( rStm, aFirstName );
- read_unicode( rStm, aShortName );
+ aName = read_unicode( rStm );
+ aFirstName = read_unicode( rStm );
+ aShortName = read_unicode( rStm );
rStm >> nType;
rStm >> nFormat;
diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx
index 0b7438c..05a30e2 100644
--- a/svl/inc/svl/zformat.hxx
+++ b/svl/inc/svl/zformat.hxx
@@ -239,7 +239,7 @@ public:
// Load a string which might contain an Euro symbol,
// in fact that could be any string used in number formats.
- static void LoadString( SvStream& rStream, String& rStr );
+ static rtl::OUString LoadString( SvStream& rStream );
/**
* Get output string from a numeric value that fits the number of
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 5f30f3c..729ea17 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -170,9 +170,9 @@ void ImpSvNumberformatInfo::Save(SvStream& rStream, sal_uInt16 nAnz) const
void ImpSvNumberformatInfo::Load(SvStream& rStream, sal_uInt16 nAnz)
{
- for (sal_uInt16 i = 0; i < nAnz; i++)
+ for (sal_uInt16 i = 0; i < nAnz; ++i)
{
- SvNumberformat::LoadString( rStream, sStrArray[i] );
+ sStrArray[i] = SvNumberformat::LoadString( rStream );
rStream >> nTypeArray[i];
}
sal_Bool bStreamThousand;
@@ -1565,7 +1565,7 @@ NfHackConversion SvNumberformat::Load( SvStream& rStream,
{
rHdr.StartEntry();
sal_uInt16 nOp1, nOp2;
- SvNumberformat::LoadString( rStream, sFormatstring );
+ sFormatstring = SvNumberformat::LoadString( rStream );
sal_Bool bStreamStandard, bStreamUsed;
rStream >> eType >> fLimit1 >> fLimit2
>> nOp1 >> nOp2 >> bStreamStandard >> bStreamUsed;
@@ -1623,7 +1623,7 @@ NfHackConversion SvNumberformat::Load( SvStream& rStream,
String aComment; // wird nach dem NewCurrency-Geraffel richtig gesetzt
if ( rHdr.BytesLeft() )
{ // ab SV_NUMBERFORMATTER_VERSION_NEWSTANDARD
- SvNumberformat::LoadString( rStream, aComment );
+ aComment = SvNumberformat::LoadString( rStream );
rStream >> nNewStandardDefined;
}
@@ -1752,32 +1752,27 @@ void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter,
}
// static
-void SvNumberformat::LoadString( SvStream& rStream, String& rStr )
+rtl::OUString SvNumberformat::LoadString( SvStream& rStream )
{
CharSet eStream = rStream.GetStreamCharSet();
rtl::OString aStr = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rStream);
sal_Char cStream = NfCurrencyEntry::GetEuroSymbol( eStream );
if (aStr.indexOf(cStream) == -1)
{ // simple conversion to unicode
- rStr = rtl::OStringToOUString(aStr, eStream);
+ return rtl::OStringToOUString(aStr, eStream);
}
- else
+
+ sal_Unicode cTarget = NfCurrencyEntry::GetEuroSymbol();
+ rtl::OUStringBuffer aBuf(aStr.getLength());
+ for (sal_Int32 i = 0; i < aStr.getLength(); ++i)
{
- sal_Unicode cTarget = NfCurrencyEntry::GetEuroSymbol();
- register const sal_Char* p = aStr.getStr();
- register const sal_Char* const pEnd = p + aStr.getLength();
- register sal_Unicode* pUni = rStr.AllocBuffer(aStr.getLength());
- while ( p < pEnd )
- {
- if ( *p == cStream )
- *pUni = cTarget;
- else
- *pUni = rtl::OUString(p, 1, eStream).toChar();
- ++p;
- ++pUni;
- }
- *pUni = 0;
+ if (aStr[i] == cStream)
+ aBuf.append(cTarget);
+ else
+ aBuf.append(rtl::OUString(aStr.getStr()+i, 1, eStream).toChar());
}
+
+ return aBuf.makeStringAndClear();
}
void SvNumberformat::Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr ) const
@@ -4735,16 +4730,17 @@ String SvNumberformat::ImpGetNatNumString( const SvNumberNatNum& rNum,
{ // speed up the most common case
if ( 0 <= nVal && nVal < 10 )
{
- sal_Unicode* p = aStr.AllocBuffer( 2 );
- *p++ = '0';
- *p = sal_Unicode( '0' + nVal );
+ sal_Unicode aBuf[2];
+ aBuf[0] = '0';
+ aBuf[1] = '0' + nVal;
+ aStr = rtl::OUString(aBuf, SAL_N_ELEMENTS(aBuf));
}
else
- aStr = String::CreateFromInt32( nVal );
+ aStr = rtl::OUString::valueOf( nVal );
}
else
{
- String aValStr( String::CreateFromInt32( nVal ) );
+ String aValStr( rtl::OUString::valueOf( nVal ) );
if ( aValStr.Len() >= nMinDigits )
aStr = aValStr;
else
@@ -4755,7 +4751,7 @@ String SvNumberformat::ImpGetNatNumString( const SvNumberNatNum& rNum,
}
}
else
- aStr = String::CreateFromInt32( nVal );
+ aStr = rtl::OUString::valueOf( nVal );
ImpTransliterate( aStr, rNum );
return aStr;
}
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 71dd8b0..50f479f 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 28d4557..d419533 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 1dea0d1..ec68e01 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 6c211f8..88c26d7 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)
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index a955e7d..a72f203 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -576,12 +576,11 @@ namespace streamdetail
template<typename prefix, typename S, sal_Size (*writeOper)(SvStream&, const S&, sal_Size)>
sal_Size write_lenPrefixed_seq_From_str(SvStream& rStrm, const S &rStr)
{
- SAL_WARN_IF(rStr.getLength() > std::numeric_limits<prefix>::max(),
- "tools.stream",
- "string too long for prefix count to fit in output type");
-
sal_Size nWritten = 0;
prefix nUnits = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<prefix>::max());
+ SAL_WARN_IF(static_cast<sal_Size>(nUnits) != static_cast<sal_Size>(rStr.getLength()),
+ "tools.stream",
+ "string too long for prefix count to fit in output type");
rStrm << nUnits;
if (rStrm.good())
{
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index b188cab..0f3e9b5 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1399,32 +1399,7 @@ rtl::OUString SvStream::ReadUniOrByteString( rtl_TextEncoding eSrcCharSet )
{
// read UTF-16 string directly from stream ?
if (eSrcCharSet == RTL_TEXTENCODING_UNICODE)
- {
- String aStr;
- sal_uInt32 nLen(0);
- operator>> (nLen);
- if (nLen)
- {
- if (nLen > STRING_MAXLEN)
- {
- SetError(SVSTREAM_GENERALERROR);
- return aStr;
- }
- sal_Unicode *pStr = aStr.AllocBuffer(
- static_cast< xub_StrLen >(nLen));
- BOOST_STATIC_ASSERT(STRING_MAXLEN <= SAL_MAX_SIZE / 2);
- Read( pStr, nLen << 1 );
-
- if (bSwap)
- {
- for (sal_Unicode *pEnd = pStr + nLen; pStr < pEnd; pStr++)
- SwapUShort(*pStr);
- }
- }
-
- return aStr;
- }
-
+ return read_lenPrefixed_uInt16s_ToOUString<sal_uInt32>(*this);
return read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(*this, eSrcCharSet);
}
@@ -1434,31 +1409,9 @@ SvStream& SvStream::WriteUniOrByteString( const rtl::OUString& rStr, rtl_TextEnc
{
// write UTF-16 string directly into stream ?
if (eDestCharSet == RTL_TEXTENCODING_UNICODE)
- {
- sal_Int32 nLen = rStr.getLength();
- operator<< (nLen);
- if (nLen)
- {
- if (bSwap)
- {
- const sal_Unicode *pStr = rStr.getStr();
- const sal_Unicode *pEnd = pStr + nLen;
-
- for (; pStr < pEnd; pStr++)
- {
- sal_Unicode c = *pStr;
- SwapUShort(c);
- WRITENUMBER_WITHOUT_SWAP(sal_uInt16,c)
- }
- }
- else
- Write( rStr.getStr(), nLen << 1 );
- }
-
- return *this;
- }
-
- write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(*this, rStr, eDestCharSet);
+ write_lenPrefixed_uInt16s_FromOUString<sal_uInt32>(*this, rStr);
+ else
+ write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(*this, rStr, eDestCharSet);
return *this;
}
diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx
index f4a0152..feaeadd 100644
--- a/vcl/source/gdi/cvtsvm.cxx
+++ b/vcl/source/gdi/cvtsvm.cxx
@@ -302,18 +302,14 @@ void ImplWriteRasterOpAction( SvStream& rOStm, sal_Int16 nRasterOp )
sal_Bool ImplWriteUnicodeComment( SvStream& rOStm, const String& rString )
{
- xub_StrLen i, nStringLen = rString.Len();
+ xub_StrLen nStringLen = rString.Len();
if ( nStringLen )
{
sal_uInt32 nSize = ( nStringLen << 1 ) + 4;
sal_uInt16 nType = GDI_UNICODE_COMMENT;
rOStm << nType << nSize;
- for ( i = 0; i < nStringLen; i++ )
- {
- sal_Unicode nUni = rString.GetChar( i );
- rOStm << nUni;
- }
+ write_uInt16s_FromOUString(rOStm, rString);
}
return nStringLen != 0;
}
@@ -336,11 +332,7 @@ void ImplReadUnicodeComment( sal_uInt32 nStrmPos, SvStream& rIStm, String& rStri
nStringLen = sal::static_int_cast<xub_StrLen>(( nActionSize - 4 ) >> 1);
if ( nStringLen && ( nType == GDI_UNICODE_COMMENT ) )
- {
- sal_Unicode* pBuffer = rString.AllocBuffer( nStringLen );
- while ( nStringLen-- )
- rIStm >> *pBuffer++;
- }
+ rString = read_uInt16s_ToOUString(rIStm, nStringLen);
}
rIStm.Seek( nOld );
}
commit db95e0b75903a34a1b88a3701334e154f32eeceb
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Aug 4 10:33:53 2012 +0100
move UniString::GetQuotedToken to sc, you can keep it
Change-Id: I6bc724186d9d701316e3e945d877bfaa88ac120d
diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index 954d4bc..a178beb 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -30,6 +30,7 @@
#define SC_STRINGUTIL_HXX
#include "rtl/ustring.hxx"
+#include "tools/string.hxx"
#include "scdllapi.h"
class SvNumberFormatter;
@@ -95,6 +96,10 @@ public:
*/
static bool parseSimpleNumber(
const ::rtl::OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal);
+
+ static xub_StrLen SC_DLLPUBLIC GetQuotedTokenCount(const UniString &rIn, const UniString& rQuotedPairs, sal_Unicode cTok = ';' );
+ static UniString SC_DLLPUBLIC GetQuotedToken(const UniString &rIn, xub_StrLen nToken, const UniString& rQuotedPairs,
+ sal_Unicode cTok, xub_StrLen& rIndex );
};
diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index 7866b99..6465c8e 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -192,4 +192,131 @@ bool ScStringUtil::parseSimpleNumber(
return true;
}
+xub_StrLen ScStringUtil::GetQuotedTokenCount(const UniString &rIn, const UniString& rQuotedPairs, sal_Unicode cTok )
+{
+ assert( !(rQuotedPairs.Len()%2) );
+ assert( rQuotedPairs.Search(cTok) );
+
+ // Leerer String: TokenCount per Definition 0
+ if ( !rIn.Len() )
+ return 0;
+
+ xub_StrLen nTokCount = 1;
+ sal_Int32 nLen = rIn.Len();
+ xub_StrLen nQuotedLen = rQuotedPairs.Len();
+ sal_Unicode cQuotedEndChar = 0;
+ const sal_Unicode* pQuotedStr = rQuotedPairs.GetBuffer();
+ const sal_Unicode* pStr = rIn.GetBuffer();
+ sal_Int32 nIndex = 0;
+ while ( nIndex < nLen )
+ {
+ sal_Unicode c = *pStr;
+ if ( cQuotedEndChar )
+ {
+ // Ende des Quotes erreicht ?
+ if ( c == cQuotedEndChar )
+ cQuotedEndChar = 0;
+ }
+ else
+ {
+ // Ist das Zeichen ein Quote-Anfang-Zeichen ?
+ xub_StrLen nQuoteIndex = 0;
+ while ( nQuoteIndex < nQuotedLen )
+ {
+ if ( pQuotedStr[nQuoteIndex] == c )
+ {
+ cQuotedEndChar = pQuotedStr[nQuoteIndex+1];
+ break;
+ }
+ else
+ nQuoteIndex += 2;
+ }
+
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( c == cTok )
+ ++nTokCount;
+ }
+
+ ++pStr,
+ ++nIndex;
+ }
+
+ return nTokCount;
+}
+
+UniString ScStringUtil::GetQuotedToken(const UniString &rIn, xub_StrLen nToken, const UniString& rQuotedPairs,
+ sal_Unicode cTok, xub_StrLen& rIndex )
+{
+ assert( !(rQuotedPairs.Len()%2) );
+ assert( rQuotedPairs.Search(cTok) == STRING_NOTFOUND );
+
+ const sal_Unicode* pStr = rIn.GetBuffer();
+ const sal_Unicode* pQuotedStr = rQuotedPairs.GetBuffer();
+ sal_Unicode cQuotedEndChar = 0;
+ xub_StrLen nQuotedLen = rQuotedPairs.Len();
+ xub_StrLen nLen = rIn.Len();
+ xub_StrLen nTok = 0;
+ xub_StrLen nFirstChar = rIndex;
+ xub_StrLen i = nFirstChar;
+
+ // Bestimme die Token-Position und Laenge
+ pStr += i;
+ while ( i < nLen )
+ {
+ sal_Unicode c = *pStr;
+ if ( cQuotedEndChar )
+ {
+ // Ende des Quotes erreicht ?
+ if ( c == cQuotedEndChar )
+ cQuotedEndChar = 0;
+ }
+ else
+ {
+ // Ist das Zeichen ein Quote-Anfang-Zeichen ?
+ xub_StrLen nQuoteIndex = 0;
+ while ( nQuoteIndex < nQuotedLen )
+ {
+ if ( pQuotedStr[nQuoteIndex] == c )
+ {
+ cQuotedEndChar = pQuotedStr[nQuoteIndex+1];
+ break;
+ }
+ else
+ nQuoteIndex += 2;
+ }
+
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( c == cTok )
+ {
+ ++nTok;
+
+ if ( nTok == nToken )
+ nFirstChar = i+1;
+ else
+ {
+ if ( nTok > nToken )
+ break;
+ }
+ }
+ }
+
+ ++pStr,
+ ++i;
+ }
+
+ if ( nTok >= nToken )
+ {
+ if ( i < nLen )
+ rIndex = i+1;
+ else
+ rIndex = STRING_NOTFOUND;
+ return rIn.Copy( nFirstChar, i-nFirstChar );
+ }
+ else
+ {
+ rIndex = STRING_NOTFOUND;
+ return UniString();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 424b91b..8597d9f 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -45,6 +45,7 @@
#include <editeng/postitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/crsditem.hxx>
+#include "stringutil.hxx"
#include "document.hxx"
#include "editutil.hxx"
#include "cell.hxx"
@@ -946,12 +947,12 @@ void XclImpWebQuery::ReadWqtables( XclImpStream& rStrm )
const sal_Unicode cSep = ';';
String aQuotedPairs( RTL_CONSTASCII_USTRINGPARAM( "\"\"" ) );
- xub_StrLen nTokenCnt = aTables.GetQuotedTokenCount( aQuotedPairs, ',' );
+ xub_StrLen nTokenCnt = ScStringUtil::GetQuotedTokenCount( aTables, aQuotedPairs, ',' );
maTables.Erase();
xub_StrLen nStringIx = 0;
for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken )
{
- String aToken( aTables.GetQuotedToken( 0, aQuotedPairs, ',', nStringIx ) );
+ String aToken( ScStringUtil::GetQuotedToken( aTables, 0, aQuotedPairs, ',', nStringIx ) );
sal_Int32 nTabNum = CharClass::isAsciiNumeric( aToken ) ? aToken.ToInt32() : 0;
if( nTabNum > 0 )
ScGlobal::AddToken( maTables, ScfTools::GetNameFromHTMLIndex( static_cast< sal_uInt32 >( nTabNum ) ), cSep );
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index 494672b..b8db869 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -45,6 +45,7 @@
#include "scresid.hxx"
#include "sc.hrc" // -> Slot IDs
+#include "stringutil.hxx"
#include "validat.hxx"
#include "validate.hrc"
#include "validate.hxx"
@@ -283,7 +284,7 @@ void lclGetFormulaFromStringList( String& rFmlaStr, const String& rStringList, s
bool lclGetStringListFromFormula( String& rStringList, const String& rFmlaStr, sal_Unicode cFmlaSep )
{
String aQuotes( RTL_CONSTASCII_USTRINGPARAM( "\"\"" ) );
- xub_StrLen nTokenCnt = rFmlaStr.GetQuotedTokenCount( aQuotes, cFmlaSep );
+ xub_StrLen nTokenCnt = ScStringUtil::GetQuotedTokenCount(rFmlaStr, aQuotes, cFmlaSep );
rStringList.Erase();
bool bIsStringList = (nTokenCnt > 0);
@@ -291,7 +292,7 @@ bool lclGetStringListFromFormula( String& rStringList, const String& rFmlaStr, s
for( xub_StrLen nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
{
- String aToken( rFmlaStr.GetQuotedToken( 0, aQuotes, cFmlaSep, nStringIx ) );
+ String aToken( ScStringUtil::GetQuotedToken(rFmlaStr, 0, aQuotes, cFmlaSep, nStringIx ) );
aToken = comphelper::string::strip(aToken, ' ');
if( aToken.Len() ) // ignore empty tokens, i.e. "a";;"b"
{
diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx
index e070fb5..d3528df 100644
--- a/tools/inc/tools/string.hxx
+++ b/tools/inc/tools/string.hxx
@@ -287,12 +287,6 @@ public:
UniString GetToken( xub_StrLen nToken, sal_Unicode cTok, xub_StrLen& rIndex ) const;
UniString GetToken( xub_StrLen nToken, sal_Unicode cTok = ';' ) const;
- xub_StrLen GetQuotedTokenCount( const UniString& rQuotedPairs, sal_Unicode cTok = ';' ) const;
- UniString GetQuotedToken( xub_StrLen nToken, const UniString& rQuotedPairs,
- sal_Unicode cTok, xub_StrLen& rIndex ) const;
- UniString GetQuotedToken( xub_StrLen nToken, const UniString& rQuotedPairs,
- sal_Unicode cTok = ';' ) const;
-
const sal_Unicode* GetBuffer() const { return mpData->maStr; }
sal_Unicode* GetBufferAccess();
void ReleaseBufferAccess( xub_StrLen nLen = STRING_LEN );
@@ -323,13 +317,6 @@ inline UniString UniString::GetToken( xub_StrLen nToken, sal_Unicode cTok ) cons
return GetToken( nToken, cTok, nTempPos );
}
-inline UniString UniString::GetQuotedToken( xub_StrLen nToken, const UniString& rQuotedPairs,
- sal_Unicode cTok ) const
-{
- xub_StrLen nTempPos = 0;
- return GetQuotedToken( nToken, rQuotedPairs, cTok, nTempPos );
-}
-
template< typename charT, typename traits > std::basic_ostream<charT, traits> &
operator <<(
std::basic_ostream<charT, traits> & stream, UniString const & string)
diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx
index 120bf00..e21b2d0 100644
--- a/tools/source/string/tustring.cxx
+++ b/tools/source/string/tustring.cxx
@@ -188,141 +188,6 @@ STRING& STRING::Insert( const STRING& rStr, xub_StrLen nPos, xub_StrLen nLen,
// -----------------------------------------------------------------------
-xub_StrLen STRING::GetQuotedTokenCount( const STRING& rQuotedPairs, STRCODE cTok ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rQuotedPairs, STRING, DBGCHECKSTRING );
- DBG_ASSERT( !(rQuotedPairs.Len()%2), "String::GetQuotedTokenCount() - QuotedString%2 != 0" );
- DBG_ASSERT( rQuotedPairs.Search(cTok) == STRING_NOTFOUND, "String::GetQuotedTokenCount() - cTok in QuotedString" );
-
- // Leerer String: TokenCount per Definition 0
- if ( !mpData->mnLen )
- return 0;
-
- xub_StrLen nTokCount = 1;
- sal_Int32 nLen = mpData->mnLen;
- xub_StrLen nQuotedLen = rQuotedPairs.Len();
- STRCODE cQuotedEndChar = 0;
- const STRCODE* pQuotedStr = rQuotedPairs.mpData->maStr;
- const STRCODE* pStr = mpData->maStr;
- sal_Int32 nIndex = 0;
- while ( nIndex < nLen )
- {
- STRCODE c = *pStr;
- if ( cQuotedEndChar )
- {
- // Ende des Quotes erreicht ?
- if ( c == cQuotedEndChar )
- cQuotedEndChar = 0;
- }
- else
- {
- // Ist das Zeichen ein Quote-Anfang-Zeichen ?
- xub_StrLen nQuoteIndex = 0;
- while ( nQuoteIndex < nQuotedLen )
- {
- if ( pQuotedStr[nQuoteIndex] == c )
- {
- cQuotedEndChar = pQuotedStr[nQuoteIndex+1];
- break;
- }
- else
- nQuoteIndex += 2;
- }
-
- // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
- if ( c == cTok )
- ++nTokCount;
- }
-
- ++pStr,
- ++nIndex;
- }
-
- return nTokCount;
-}
-
-// -----------------------------------------------------------------------
-
-STRING STRING::GetQuotedToken( xub_StrLen nToken, const STRING& rQuotedPairs,
- STRCODE cTok, xub_StrLen& rIndex ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rQuotedPairs, STRING, DBGCHECKSTRING );
- DBG_ASSERT( !(rQuotedPairs.Len()%2), "String::GetQuotedToken() - QuotedString%2 != 0" );
- DBG_ASSERT( rQuotedPairs.Search(cTok) == STRING_NOTFOUND, "String::GetQuotedToken() - cTok in QuotedString" );
-
- const STRCODE* pStr = mpData->maStr;
- const STRCODE* pQuotedStr = rQuotedPairs.mpData->maStr;
- STRCODE cQuotedEndChar = 0;
- xub_StrLen nQuotedLen = rQuotedPairs.Len();
- xub_StrLen nLen = (xub_StrLen)mpData->mnLen;
- xub_StrLen nTok = 0;
- xub_StrLen nFirstChar = rIndex;
- xub_StrLen i = nFirstChar;
-
- // Bestimme die Token-Position und Laenge
- pStr += i;
- while ( i < nLen )
- {
- STRCODE c = *pStr;
- if ( cQuotedEndChar )
- {
- // Ende des Quotes erreicht ?
- if ( c == cQuotedEndChar )
- cQuotedEndChar = 0;
- }
- else
- {
- // Ist das Zeichen ein Quote-Anfang-Zeichen ?
- xub_StrLen nQuoteIndex = 0;
- while ( nQuoteIndex < nQuotedLen )
- {
- if ( pQuotedStr[nQuoteIndex] == c )
- {
- cQuotedEndChar = pQuotedStr[nQuoteIndex+1];
- break;
- }
- else
- nQuoteIndex += 2;
- }
-
- // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
- if ( c == cTok )
- {
- ++nTok;
-
- if ( nTok == nToken )
- nFirstChar = i+1;
- else
- {
- if ( nTok > nToken )
- break;
- }
- }
- }
-
- ++pStr,
- ++i;
- }
-
- if ( nTok >= nToken )
- {
- if ( i < nLen )
- rIndex = i+1;
- else
- rIndex = STRING_NOTFOUND;
- return Copy( nFirstChar, i-nFirstChar );
- }
- else
- {
- rIndex = STRING_NOTFOUND;
- return STRING();
- }
-}
-
-// -----------------------------------------------------------------------
-
static sal_Int32 ImplStringICompareWithoutZero( const STRCODE* pStr1, const STRCODE* pStr2,
sal_Int32 nCount )
{
More information about the Libreoffice-commits
mailing list