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

Tomaž Vajngerl quikee at gmail.com
Fri Sep 13 02:59:11 PDT 2013


 vcl/source/control/field.cxx |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 2defeda9f061e7b1b8e94191e48b17e112761bb5
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Fri Sep 13 11:55:19 2013 +0200

    Numeric fileds: round to the nearest spin value on spin up/down
    
    Change-Id: I8660ae764c7dd51b8d780929effe895243e4fc4c

diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index d994757..401f0a1 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -724,7 +724,12 @@ void NumericFormatter::Reformat()
 void NumericFormatter::FieldUp()
 {
     sal_Int64 nValue = GetValue();
-    nValue += mnSpinSize;
+    sal_Int64 nRemainder = nValue % mnSpinSize;
+    if (nValue >= 0)
+        nValue = (nRemainder == 0) ? nValue + mnSpinSize : nValue + mnSpinSize - nRemainder;
+    else
+        nValue = (nRemainder == 0) ? nValue + mnSpinSize : nValue - nRemainder;
+
     if ( nValue > mnMax )
         nValue = mnMax;
 
@@ -736,7 +741,12 @@ void NumericFormatter::FieldUp()
 void NumericFormatter::FieldDown()
 {
     sal_Int64 nValue = GetValue();
-    nValue -= mnSpinSize;
+    sal_Int64 nRemainder = nValue % mnSpinSize;
+    if (nValue >= 0)
+        nValue = (nRemainder == 0) ? nValue - mnSpinSize : nValue - nRemainder;
+    else
+        nValue = (nRemainder == 0) ? nValue - mnSpinSize : nValue - mnSpinSize - nRemainder;
+
     if ( nValue < mnMin )
         nValue = mnMin;
 


More information about the Libreoffice-commits mailing list