From bf246fce77cdfac7e031d93a912d0bf2071a6e5e Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Mon, 19 Nov 2012 22:34:35 -0600 Subject: a replace() to OUStringBuffer Change-Id: I2cbfeea9800ad656c49ce1cae7ff1f4b830f1442 Reviewed-on: https://gerrit.libreoffice.org/1139 Reviewed-by: Norbert Thiebaud Tested-by: Norbert Thiebaud --- sal/inc/rtl/ustrbuf.hxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sal') diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index a82a30b15995..25195f1434da 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -924,6 +924,26 @@ public: return *this; } + /** + Replace all occurrences of + oldChar in this string buffer with newChar. + + @since LibreOffice 4.0 + + @param oldChar the old character. + @param newChar the new character. + @return this string buffer + */ + OUStringBuffer& replace( sal_Unicode oldChar, sal_Unicode newChar ) + { + sal_Int32 index = 0; + while((index = indexOf(oldChar, index)) >= 0) + { + pData->buffer[ index ] = newChar; + } + return *this; + } + /** Allows access to the internal data of this OUStringBuffer, for effective manipulation. -- cgit