[Libreoffice-commits] core.git: vcl/source

Chr. Rossmanith ChrRossmanith at gmx.de
Mon Mar 18 03:46:43 PDT 2013


 vcl/source/control/field.cxx |   24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

New commits:
commit 38d0e65fa51a559b0f607b3f00f5db2527dbab57
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date:   Sat Mar 16 20:55:46 2013 +0100

    Reuse ImplPower10()
    
    Change-Id: I0a86e43065689d2478ced4804ab083244d8d35f5
    Reviewed-on: https://gerrit.libreoffice.org/2774
    Reviewed-by: Joren De Cuyper <joren.libreoffice at telenet.be>
    Reviewed-by: Thorsten Behrens <tbehrens at suse.com>
    Tested-by: Thorsten Behrens <tbehrens at suse.com>

diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index c0037e9..69cb02e 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -53,7 +53,7 @@ using namespace ::comphelper;
 
 static sal_Int64 ImplPower10( sal_uInt16 n )
 {
-    sal_uInt16 i;
+    sal_uInt16  i;
     sal_Int64   nValue = 1;
 
     for ( i=0; i < n; i++ )
@@ -1264,9 +1264,7 @@ double MetricField::ConvertDoubleValue( double nValue, sal_Int64 mnBaseValue, sa
         {
             if ( (mnBaseValue <= 0) || (nValue <= 0) )
                 return nValue;
-            nDiv = 100;
-            for ( sal_uInt16 i=0; i < nDecDigits; i++ )
-                nDiv *= 10;
+            nDiv = 100 * ImplPower10(nDecDigits);
 
             nMult = mnBaseValue;
         }
@@ -1333,11 +1331,7 @@ double MetricField::ConvertDoubleValue( double nValue, sal_uInt16 nDigits,
     }
     else
     {
-        while ( nDecDigits )
-        {
-            nValue *= 10;
-            nDecDigits--;
-        }
+        nValue *= ImplPower10(nDecDigits);
     }
 
     if ( eFieldUnit != eOutUnit )
@@ -1381,19 +1375,11 @@ double MetricField::ConvertDoubleValue( double nValue, sal_uInt16 nDigits,
 
     if ( nDecDigits < 0 )
     {
-        while ( nDecDigits )
-        {
-            nValue *= 10;
-            nDecDigits++;
-        }
+        nValue *= ImplPower10(-nDecDigits);
     }
     else
     {
-        while ( nDecDigits )
-        {
-            nValue /= 10;
-            nDecDigits--;
-        }
+        nValue /= ImplPower10(nDecDigits);
     }
 
     if ( eFieldUnit != eInUnit )


More information about the Libreoffice-commits mailing list