diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-08-14 13:43:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-08-14 16:46:14 +0200 |
commit | ba209b98f99b2b547dc94445efbc7263c47abf16 (patch) | |
tree | c3584cb03e85bf22ba46fe7bc705e8e789ab36ca /vcl | |
parent | abe48a44ce80cd215a9cc18c219daf5e58e1f4e8 (diff) |
Resolves: tdf#119251 parse non-default units in user inputted values
Change-Id: I28f8338f5c318f2228b742e2e171d53820cb0cc8
Reviewed-on: https://gerrit.libreoffice.org/58984
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/field.cxx | 10 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 2 |
3 files changed, 17 insertions, 6 deletions
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 7bd182a9e975..d47311c50bc7 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -1315,8 +1315,8 @@ double MetricField::ConvertDoubleValue( double nValue, sal_uInt16 nDigits, return nValue; } -static bool ImplMetricGetValue( const OUString& rStr, double& rValue, sal_Int64 nBaseValue, - sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, FieldUnit eUnit ) +bool MetricFormatter::TextToValue(const OUString& rStr, double& rValue, sal_Int64 nBaseValue, + sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, FieldUnit eUnit) { // Get value sal_Int64 nValue; @@ -1335,7 +1335,7 @@ static bool ImplMetricGetValue( const OUString& rStr, double& rValue, sal_Int64 void MetricFormatter::ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr ) { - if ( !ImplMetricGetValue( rStr, rValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ) ) + if ( !TextToValue( rStr, rValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ) ) return; double nTempVal = rValue; @@ -1422,7 +1422,7 @@ sal_Int64 MetricFormatter::GetValueFromStringUnit(const OUString& rStr, FieldUni { double nTempValue; // caution: precision loss in double cast - if (!ImplMetricGetValue(rStr, nTempValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit)) + if (!TextToValue(rStr, nTempValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit)) nTempValue = static_cast<double>(mnLastValue); // caution: precision loss in double cast @@ -1782,7 +1782,7 @@ void MetricBox::InsertValue( sal_Int64 nValue, FieldUnit eInUnit, sal_Int32 nPos sal_Int64 MetricBox::GetValue( sal_Int32 nPos ) const { double nValue = 0; - ImplMetricGetValue( ComboBox::GetEntry( nPos ), nValue, mnBaseValue, + TextToValue( ComboBox::GetEntry( nPos ), nValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ); // convert to previously configured units diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 9408d97e67e7..b08d84a28cc6 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -243,6 +243,17 @@ namespace weld return MetricField::ConvertValue(nValue, 0, m_xSpinButton->get_digits(), eInUnit, eOutUnit); } + IMPL_LINK(MetricSpinButton, spin_button_input, int*, result, bool) + { + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); + double fResult(0.0); + bool bRet = MetricFormatter::TextToValue(get_text(), fResult, 0, m_xSpinButton->get_digits(), rLocaleData, m_eSrcUnit); + if (bRet) + *result = fResult; + return bRet; + } + IMPL_LINK_NOARG(TimeSpinButton, spin_button_cursor_position, Entry&, void) { int nStartPos, nEndPos; diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index feafcc49a169..56f5289049b4 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -3880,7 +3880,7 @@ private: return false; if (eHandled == TRISTATE_TRUE) { - *new_value = result; + *new_value = pThis->toGtk(result); return true; } return GTK_INPUT_ERROR; |