[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/koffice/1.5/koffice/kspread trunk/koffice/kspread
From:       Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date:       2006-04-22 12:59:27
Message-ID: 1145710767.812073.15802.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 532664 by nikolaus:

value	Fix 'Bug 125828: Integer-valued cells unaffected by "Increase/decrease the \
decimal precision shown onscreen"'

Note:	'Bug 118122: Text numbers are modified during copy and paste' remains fixed.

BUG: 125828
CCBUG: 118122


 M  +8 -51     branches/koffice/1.5/koffice/kspread/valueformatter.cc  
 M  +0 -2      branches/koffice/1.5/koffice/kspread/valueformatter.h  
 M  +8 -51     trunk/koffice/kspread/valueformatter.cc  
 M  +0 -2      trunk/koffice/kspread/valueformatter.h  


--- branches/koffice/1.5/koffice/kspread/valueformatter.cc #532663:532664
@@ -95,21 +95,8 @@
     str = fractionFormat (value.asFloat(), fmtType);
 
   //another
-  else if (value.isInteger())
-  {
-	long v = value.asInteger();
-	// Always unsigned ?
-    if ((floatFormat == Format::AlwaysUnsigned) && (v < 0))
-      v *= -1;
-    str = createNumberFormat (v, fmtType,
-        (floatFormat == Format::AlwaysSigned), currencySymbol);
-  }
   else
   {
-    QChar decimal_point = converter->locale()->decimalSymbol()[0];
-    if ( decimal_point.isNull() )
-      decimal_point = '.';
-
     //some cell parameters ...
     double v = converter->asFloat (value).asFloat();
 
@@ -124,7 +111,13 @@
     // Remove trailing zeros and the decimal point if necessary
     // unless the number has no decimal point
     if (precision == -1)
+    {
+      QChar decimal_point = converter->locale()->decimalSymbol()[0];
+      if ( decimal_point.isNull() )
+        decimal_point = '.';
+
       removeTrailingZeros (str, decimal_point);
+    }
   }
 
   if (!prefix.isEmpty())
@@ -240,49 +233,13 @@
   }
 }
 
-
-QString ValueFormatter::createNumberFormat ( long value, FormatType fmt,
-	 bool alwaysSigned, const QString& currencySymbol)
-{
-  QString number;
-
-  //multiply value by 100 for percentage format
-  if (fmt == Percentage_format)
-    value *= 100;
-
-  switch (fmt)
-  {
-    case Number_format:
-    case Scientific_format:
-      number = QString::number(value);
-      break;
-    case Percentage_format:
-      number = QString::number(value) + " %";
-      break;
-    case Money_format:
-      number = converter->locale()->formatMoney (value, currencySymbol.isEmpty() ? \
                converter->locale()->currencySymbol() : currencySymbol);
-      break;
-    default :
-      //other formatting?
-      // This happens with Custom_format...
-      kdDebug(36001)<<"Wrong usage of ValueFormatter::createNumberFormat fmt=" << \
                fmt << "\n";
-      break;
-  }
-
-  //prepend positive sign if needed
-  if (alwaysSigned && value >= 0 )
-    if (converter->locale()->positiveSign().isEmpty())
-      number='+'+number;
-
-  return number;
-}
-
 QString ValueFormatter::createNumberFormat ( double value, int precision,
     FormatType fmt, bool alwaysSigned, const QString& currencySymbol)
 {
   // if precision is -1, ask for a huge number of decimals, we'll remove
   // the zeros later. Is 8 ok ?
-  int p = (precision == -1) ? 8 : precision;
+  // Stefan: No. Use maximum possible decimal precision (DBL_DIG) instead.
+  int p = (precision == -1) ? DBL_DIG : precision;
   QString localizedNumber;
   int pos = 0;
 
--- branches/koffice/1.5/koffice/kspread/valueformatter.h #532663:532664
@@ -67,8 +67,6 @@
       FormatType fmtType);
 
   /** create a number format */
-  QString createNumberFormat (long value, FormatType fmt, bool alwaysSigned,
-                              const QString& currencySymbol);
   QString createNumberFormat (double value, int precision, FormatType fmt,
       bool alwaysSigned, const QString& currencySymbol);
 
--- trunk/koffice/kspread/valueformatter.cc #532663:532664
@@ -95,21 +95,8 @@
     str = fractionFormat (value.asFloat(), fmtType);
 
   //another
-  else if (value.isInteger())
-  {
-	long v = value.asInteger();
-	// Always unsigned ?
-    if ((floatFormat == Style::AlwaysUnsigned) && (v < 0))
-      v *= -1;
-    str = createNumberFormat (v, fmtType,
-        (floatFormat == Style::AlwaysSigned), currencySymbol);
-  }
   else
   {
-    QChar decimal_point = converter->locale()->decimalSymbol()[0];
-    if ( decimal_point.isNull() )
-      decimal_point = '.';
-
     //some cell parameters ...
     double v = converter->asFloat (value).asFloat();
 
@@ -124,7 +111,13 @@
     // Remove trailing zeros and the decimal point if necessary
     // unless the number has no decimal point
     if (precision == -1)
+    {
+      QChar decimal_point = converter->locale()->decimalSymbol()[0];
+      if ( decimal_point.isNull() )
+        decimal_point = '.';
+
       removeTrailingZeros (str, decimal_point);
+    }
   }
 
   if (!prefix.isEmpty())
@@ -240,49 +233,13 @@
   }
 }
 
-
-QString ValueFormatter::createNumberFormat ( long value, FormatType fmt,
-	 bool alwaysSigned, const QString& currencySymbol)
-{
-  QString number;
-
-  //multiply value by 100 for percentage format
-  if (fmt == Percentage_format)
-    value *= 100;
-
-  switch (fmt)
-  {
-    case Number_format:
-    case Scientific_format:
-      number = QString::number(value);
-      break;
-    case Percentage_format:
-      number = QString::number(value) + " %";
-      break;
-    case Money_format:
-      number = converter->locale()->formatMoney (value, currencySymbol.isEmpty() ? \
                converter->locale()->currencySymbol() : currencySymbol);
-      break;
-    default :
-      //other formatting?
-      // This happens with Custom_format...
-      kDebug(36001)<<"Wrong usage of ValueFormatter::createNumberFormat fmt=" << fmt \
                << "\n";
-      break;
-  }
-
-  //prepend positive sign if needed
-  if (alwaysSigned && value >= 0 )
-    if (converter->locale()->positiveSign().isEmpty())
-      number='+'+number;
-
-  return number;
-}
-
 QString ValueFormatter::createNumberFormat ( double value, int precision,
     FormatType fmt, bool alwaysSigned, const QString& currencySymbol)
 {
   // if precision is -1, ask for a huge number of decimals, we'll remove
   // the zeros later. Is 8 ok ?
-  int p = (precision == -1) ? 8 : precision;
+  // Stefan: No. Use maximum possible decimal precision (DBL_DIG) instead.
+  int p = (precision == -1) ? DBL_DIG : precision;
   QString localizedNumber;
   int pos = 0;
 
--- trunk/koffice/kspread/valueformatter.h #532663:532664
@@ -67,8 +67,6 @@
       FormatType fmtType);
 
   /** create a number format */
-  QString createNumberFormat (long value, FormatType fmt, bool alwaysSigned,
-                              const QString& currencySymbol);
   QString createNumberFormat (double value, int precision, FormatType fmt,
       bool alwaysSigned, const QString& currencySymbol);
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic