summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-09-13 11:55:19 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-09-13 11:58:18 +0200
commit2defeda9f061e7b1b8e94191e48b17e112761bb5 (patch)
tree640a3c6e0d4588799d8fa4d112b86ec62fdb8abf /vcl
parent751e238c78247bec81c1c7c50bc4758b1faea151 (diff)
Numeric fileds: round to the nearest spin value on spin up/down
Change-Id: I8660ae764c7dd51b8d780929effe895243e4fc4c
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/field.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index d994757afb17..401f0a1f0d33 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;