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


Hi,

when changing (Xub)String to OUString I came across a strange for-loop. You find it at the end of the quotation. I've kept some context... (continue below the quotation)
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 387acea..e632b4a 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -89,29 +89,29 @@
// ----------------------------------------------------------------------- -static sal_Bool ImplNumericGetValue( const XubString& rStr, double& rValue,
+static sal_Bool ImplNumericGetValue( const OUString& rStr, double& rValue,
                                   sal_uInt16 nDecDigits, const LocaleDataWrapper& 
rLocaleDataWrappper,
                                   sal_Bool bCurrency = sal_False )
  {
-    XubString   aStr = rStr;
-    XubString   aStr1;
+    OUString   aStr = rStr;
+    OUString   aStr1;
      rtl::OUStringBuffer aStr2;
      sal_Bool        bNegative = sal_False;
-    xub_StrLen  nDecPos;
+    sal_Int32  nDecPos;
// react on empty string
-    if ( !rStr.Len() )
+    if ( rStr.isEmpty() )
          return sal_False;
// remove leading and trailing spaces
-    aStr = string::strip(aStr, ' ');
+    aStr = aStr.trim();
// find position of decimal point
-    nDecPos = aStr.Search( rLocaleDataWrappper.getNumDecimalSep() );
-    if ( nDecPos != STRING_NOTFOUND )
+    nDecPos = aStr.indexOf( rLocaleDataWrappper.getNumDecimalSep() );
+    if ( nDecPos >= 0)
      {
-        aStr1 = aStr.Copy( 0, nDecPos );
-        aStr2.append(aStr.Copy(nDecPos+1));
+        aStr1 = aStr.copy( 0, nDecPos );
+        aStr2.append(aStr.getStr()+nDecPos+1);
      }
      else
          aStr1 = aStr;
@@ -119,32 +119,32 @@
      // negative?
      if ( bCurrency )
      {
-        if ( (aStr.GetChar( 0 ) == '(') && (aStr.GetChar( aStr.Len()-1 ) == ')') )
+        if ( aStr.startsWith("(") && aStr.endsWith(")") )
              bNegative = sal_True;
          if ( !bNegative )
          {
-            for (xub_StrLen i=0; i < aStr.Len(); i++ )
+            for (sal_Int32 i=0; i < aStr.getLength(); i++ )
              {
-                if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') )
+                if ( (aStr[i] >= '0') && (aStr[i] <= '9') )
                      break;
-                else if ( aStr.GetChar( i ) == '-' )
+                else if ( aStr[i] == '-' )
                  {
                      bNegative = sal_True;
                      break;
                  }
              }
          }
-        if ( !bNegative && bCurrency && aStr.Len() )
+        if ( !bNegative && bCurrency && !aStr.isEmpty() )
          {
              sal_uInt16 nFormat = rLocaleDataWrappper.getCurrNegativeFormat();
-            if ( (nFormat == 3) || (nFormat == 6)  ||
-                 (nFormat == 7) || (nFormat == 10) )
+            if ( (nFormat == 3) || (nFormat == 6)  || // $1- || 1-$
+                 (nFormat == 7) || (nFormat == 10) )  // 1$- || 1 $-
              {
-                for (xub_StrLen i = (xub_StrLen)(aStr.Len()-1); i > 0; i++ )
+                for (sal_Int32 i = aStr.getLength()-1; i > 0; i++ )
                  {
-                    if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') )
+                    if ( (aStr[i] >= '0') && (aStr[i] <= '9') )
                          break;
-                    else if ( aStr.GetChar( i ) == '-' )
+                    else if ( aStr[i] == '-' )
                      {
                          bNegative = sal_True;
                          break;

In

for (sal_Int32 i = aStr.getLength()-1; i > 0; i++ )

i starts with at least -1 is tested to be non negative and incremented. Is this code ever used??? Or am I failing to see the magic behind the scenes?

Christina

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.