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

New commits:
commit 2defeda9f061e7b1b8e94191e48b17e112761bb5
Author: Tomaž Vajngerl <[email protected]>
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;
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to