[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 14 14:46:36 UTC 2018
include/vcl/field.hxx | 2 ++
include/vcl/weld.hxx | 2 ++
vcl/source/control/field.cxx | 10 +++++-----
vcl/source/window/builder.cxx | 11 +++++++++++
vcl/unx/gtk3/gtk3gtkinst.cxx | 2 +-
5 files changed, 21 insertions(+), 6 deletions(-)
New commits:
commit ba209b98f99b2b547dc94445efbc7263c47abf16
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Aug 14 13:43:51 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Aug 14 16:46:14 2018 +0200
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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx
index ff9eae27377e..1856bcefc649 100644
--- a/include/vcl/field.hxx
+++ b/include/vcl/field.hxx
@@ -241,6 +241,8 @@ public:
void SetCustomConvertHdl( const Link<MetricFormatter&,void>& rLink ) { maCustomConvertLink = rLink; }
static FieldUnit StringToMetric(const OUString &rMetricString);
+ static bool TextToValue(const OUString& rStr, double& rValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, FieldUnit eUnit);
+
protected:
sal_Int64 mnBaseValue;
FieldUnit meUnit;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 443b916b5142..0277b3cfae6f 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -581,6 +581,7 @@ protected:
DECL_LINK(spin_button_value_changed, weld::SpinButton&, void);
DECL_LINK(spin_button_output, weld::SpinButton&, void);
+ DECL_LINK(spin_button_input, int* result, bool);
void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
@@ -595,6 +596,7 @@ public:
{
update_width_chars();
m_xSpinButton->connect_output(LINK(this, MetricSpinButton, spin_button_output));
+ m_xSpinButton->connect_input(LINK(this, MetricSpinButton, spin_button_input));
m_xSpinButton->connect_value_changed(
LINK(this, MetricSpinButton, spin_button_value_changed));
}
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;
More information about the Libreoffice-commits
mailing list