Kaydet (Commit) e1a5ae39 authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: fdo#83010 move NumericFormatter clipping to min/max into one place

Change-Id: I60cfe651a6ec25fc7e482192d908acca25c1ad8b
üst 259ab763
......@@ -184,6 +184,8 @@ public:
void SetMax( sal_Int64 nNewMax );
sal_Int64 GetMax() const { return mnMax; }
sal_Int64 ClipAgainstMinMax(sal_Int64 nValue) const;
void SetFirst( sal_Int64 nNewFirst ) { mnFirst = nNewFirst; }
sal_Int64 GetFirst() const { return mnFirst; }
void SetLast( sal_Int64 nNewLast ) { mnLast = nNewLast; }
......
......@@ -417,11 +417,7 @@ bool NumericFormatter::ImplNumericReformat( const OUString& rStr, sal_Int64& rVa
return true;
else
{
sal_Int64 nTempVal = rValue;
if ( nTempVal > mnMax )
nTempVal = mnMax;
else if ( nTempVal < mnMin )
nTempVal = mnMin;
sal_Int64 nTempVal = ClipAgainstMinMax(rValue);
if ( GetErrorHdl().IsSet() && (rValue != nTempVal) )
{
......@@ -487,11 +483,7 @@ void NumericFormatter::ImplLoadRes( const ResId& rResId )
if ( NUMERICFORMATTER_VALUE & nMask )
{
mnFieldValue = pMgr->ReadLong();
if ( mnFieldValue > mnMax )
mnFieldValue = mnMax;
else if ( mnFieldValue < mnMin )
mnFieldValue = mnMin;
mnFieldValue = ClipAgainstMinMax(pMgr->ReadLong());
mnLastValue = mnFieldValue;
}
......@@ -554,10 +546,7 @@ OUString NumericFormatter::CreateFieldText( sal_Int64 nValue ) const
void NumericFormatter::ImplSetUserValue( sal_Int64 nNewValue, Selection* pNewSelection )
{
if ( nNewValue > mnMax )
nNewValue = mnMax;
else if ( nNewValue < mnMin )
nNewValue = mnMin;
nNewValue = ClipAgainstMinMax(nNewValue);
mnLastValue = nNewValue;
if ( GetField() )
......@@ -579,11 +568,7 @@ sal_Int64 NumericFormatter::GetValue() const
if ( ImplNumericGetValue( GetField()->GetText(), nTempValue,
GetDecimalDigits(), ImplGetLocaleDataWrapper() ) )
{
if ( nTempValue > mnMax )
nTempValue = mnMax;
else if ( nTempValue < mnMin )
nTempValue = mnMin;
return nTempValue;
return ClipAgainstMinMax(nTempValue);
}
else
return mnLastValue;
......@@ -656,8 +641,7 @@ void NumericFormatter::FieldUp()
else
nValue = (nRemainder == 0) ? nValue + mnSpinSize : nValue - nRemainder;
if ( nValue > mnMax )
nValue = mnMax;
nValue = ClipAgainstMinMax(nValue);
ImplNewFieldValue( nValue );
}
......@@ -671,8 +655,7 @@ void NumericFormatter::FieldDown()
else
nValue = (nRemainder == 0) ? nValue - mnSpinSize : nValue - mnSpinSize - nRemainder;
if ( nValue < mnMin )
nValue = mnMin;
nValue = ClipAgainstMinMax(mnMin);
ImplNewFieldValue( nValue );
}
......@@ -720,6 +703,15 @@ void NumericFormatter::ImplNewFieldValue( sal_Int64 nNewValue )
}
}
sal_Int64 NumericFormatter::ClipAgainstMinMax(sal_Int64 nValue) const
{
if (nValue > mnMax)
nValue = mnMax;
else if (nValue < mnMin)
nValue = mnMin;
return nValue;
}
NumericField::NumericField( vcl::Window* pParent, WinBits nWinStyle ) :
SpinField( pParent, nWinStyle )
{
......@@ -1944,11 +1936,7 @@ sal_Int64 CurrencyFormatter::GetValue() const
sal_Int64 nTempValue;
if ( ImplCurrencyGetValue( GetField()->GetText(), nTempValue, GetDecimalDigits(), ImplGetLocaleDataWrapper() ) )
{
if ( nTempValue > mnMax )
nTempValue = mnMax;
else if ( nTempValue < mnMin )
nTempValue = mnMin;
return nTempValue;
return ClipAgainstMinMax(nTempValue);
}
else
return mnLastValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment