From 3b36ae1376038661554d2a61e7f1b4f2c6a13e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Timm?= Date: Fri, 6 Jun 2008 13:36:31 +0000 Subject: [PATCH] INTEGRATION: CWS dba30c (1.5.20); FILE MERGED 2008/05/13 06:53:56 fs 1.5.20.1: joining changes from CWS odbmacros3 to CWS dba30c 2008/04/16 20:54:43 fs 1.5.8.1: searchAndReplaceAllAsciiWithAscii --- comphelper/source/misc/string.cxx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index cc7c30b3297a..77a251372d85 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: string.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -55,7 +55,28 @@ rtl::OUString searchAndReplaceAsciiL( return n == -1 ? source : source.replaceAt(n, fromLength, to); } -COMPHELPER_DLLPUBLIC ::rtl::OUString& searchAndReplaceAsciiI( +::rtl::OUString searchAndReplaceAllAsciiWithAscii( + const ::rtl::OUString& _source, const sal_Char* _from, const sal_Char* _to, + const sal_Int32 _beginAt ) +{ + sal_Int32 fromLength = strlen( _from ); + sal_Int32 n = _source.indexOfAsciiL( _from, fromLength, _beginAt ); + if ( n == -1 ) + return _source; + + ::rtl::OUString dest( _source ); + ::rtl::OUString to( ::rtl::OUString::createFromAscii( _to ) ); + do + { + dest = dest.replaceAt( n, fromLength, to ); + n = dest.indexOfAsciiL( _from, fromLength, n + to.getLength() ); + } + while ( n != -1 ); + + return dest; +} + +::rtl::OUString& searchAndReplaceAsciiI( ::rtl::OUString & _source, sal_Char const * _asciiPattern, ::rtl::OUString const & _replace, sal_Int32 _beginAt, sal_Int32 * _replacedAt ) {