Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On 01/30/2013 03:13 PM, Libreoffice Gerrit user wrote:
commit 1ba8986446dbaa77c9aed6d141ee99da74bf1afb
Author: Luboš Luňák <l.lunak@suse.cz>
Date:   Wed Jan 30 15:12:34 2013 +0100

     fix for the awkward OUString::replaceAll() behaviour

     Change-Id: I6ee919bb17ea7eb29cb9cfc0fc69d02d728d9a0f

diff --git a/forms/source/xforms/resourcehelper.cxx b/forms/source/xforms/resourcehelper.cxx
index a39f767..50cd74f 100644
--- a/forms/source/xforms/resourcehelper.cxx
+++ b/forms/source/xforms/resourcehelper.cxx
@@ -55,12 +55,10 @@ OUString getResource( sal_uInt16 nResourceId,
      OUString sResource = frm::ResourceManager::loadString( nResourceId );
      OSL_ENSURE( !sResource.isEmpty(), "resource not found?" );

-    // use old style String class for search and replace, so we don't have to
-    // code this again.
      OUString sString( sResource );
-    sString.replaceAll( "$1", rInfo1 );
-    sString.replaceAll( "$2", rInfo2 );
-    sString.replaceAll( "$3", rInfo3 );
+    sString = sString.replaceAll( "$1", rInfo1 );
+    sString = sString.replaceAll( "$2", rInfo2 );
+    sString = sString.replaceAll( "$3", rInfo3 );
      return sString;
  }

Seeing this, that's the reason I've always been unhappy with such a replaceAll function: While it may appear "obviously useful," it easily leads to broken code (like if rInfo1 is "wanna bet $2 this doesn't work?", say, in the above snippet).

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.