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

List:       kde-commits
Subject:    koffice/lib/kofficecore
From:       Nicolas Goutte <nicolasg () snafu ! de>
Date:       2004-04-02 22:43:43
Message-ID: 20040402224343.B192F997E () office ! kde ! org
[Download RAW message or body]

CVS commit by goutte: 

KoUnit::ptFromUnit creates an oveflow with big numbers, as it tries to round.
However fr the unit widgets, we need a function that does not round and 
especially not create overflows: KoUnit::ptFromUnitUnrounded


  M +24 -0     koUnit.cc   1.14
  M +12 -2     koUnit.h   1.15


--- koffice/lib/kofficecore/koUnit.cc  #1.13:1.14
@@ -84,4 +84,28 @@ double KoUnit::ptToUnit( double ptValue,
 }
 
+double KoUnit::ptToUnitUnrounded( const double ptValue, const Unit unit )
+{
+    switch ( unit )
+    {
+    case U_MM:
+        return POINT_TO_MM( ptValue );
+    case U_CM:
+        return POINT_TO_CC( ptValue );
+    case U_DM:
+        return POINT_TO_DM( ptValue );
+    case U_INCH:
+        return POINT_TO_INCH( ptValue );
+    case U_PI:
+        return POINT_TO_PI( ptValue );
+    case U_DD:
+        return POINT_TO_DD( ptValue );
+    case U_CC:
+        return POINT_TO_CC( ptValue );
+    case U_PT:
+    default:
+        return ptValue;
+    }
+}
+
 QString KoUnit::userValue( double ptValue, Unit unit )
 {

--- koffice/lib/kofficecore/koUnit.h  #1.14:1.15
@@ -113,8 +113,18 @@ public:
     }
 
-    /// This method is the one to use to display a value in a dialog
-    /// @return the value @p ptValue converted to @p unit and rounded, ready to be \
displayed +    /**
+     * This method is the one to use to display a value in a dialog
+     * \warning: as the number is multiplied by 10000, beware of overflow of bigger \
numbers +     * \return the value @p ptValue converted to @p unit and rounded, ready \
to be displayed +     */
     static double ptToUnit( double ptValue, Unit unit );
 
+    /**
+     * Convert the value @p ptValue to a given unit @p unit
+     * Unlike KoUnit::ptToUnit the return value remains unrounded, so that it can be \
used in complex calculation +     * \return the converted value
+     */
+    static double ptToUnitUnrounded( const double ptValue, const Unit unit );
+
     /// This method is the one to use to display a value in a dialog
     /// @return the value @p ptValue converted to @p unit and rounded, ready to be \
displayed


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

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