[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - include/vcl sd/source vcl/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 22 09:00:13 UTC 2019
include/vcl/field.hxx | 6 +++++-
sd/source/ui/animations/CustomAnimationPane.cxx | 1 +
vcl/source/control/field.cxx | 21 +++++++++++----------
3 files changed, 17 insertions(+), 11 deletions(-)
New commits:
commit 6d595217f59957e1fc6ff69bd77dce1c9a1c6036
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Jul 21 23:47:40 2019 -0400
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Mon Jul 22 10:59:39 2019 +0200
vcl: Numeric/MetricBox formatting of decimals is controlled via a flag
Currently only the Animation Pane duration control uses the
always-visible decimals. By making it controlled via a flag
it is now flexible and avoids regressions in other controls.
Change-Id: I324fa6944daaab311725ae6593e763b140315ae7
Reviewed-on: https://gerrit.libreoffice.org/76082
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Tested-by: Tor Lillqvist <tml at collabora.com>
diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx
index de00346a2e51..b29a29b37f56 100644
--- a/include/vcl/field.hxx
+++ b/include/vcl/field.hxx
@@ -142,7 +142,10 @@ public:
sal_Int64 GetSpinSize() const { return mnSpinSize; }
void SetDecimalDigits( sal_uInt16 nDigits );
- sal_uInt16 GetDecimalDigits() const { return mnDecimalDigits;}
+ sal_uInt16 GetDecimalDigits() const { return mnDecimalDigits; }
+
+ void SetShowDecimals(bool bShowDecimals) { mbShowDecimals = bShowDecimals; }
+ bool IsShowDecimals() const { return mbShowDecimals; }
void SetUseThousandSep( bool b );
bool IsUseThousandSep() const { return mbThousandSep; }
@@ -191,6 +194,7 @@ private:
SAL_DLLPRIVATE void ImplInit();
sal_uInt16 mnDecimalDigits;
+ bool mbShowDecimals; //< When true, formatting appends .0s (as may as mnDecimalDigits).
bool mbThousandSep;
bool mbShowTrailingZeros;
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index d98c2952986f..3e1fc90a2850 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -204,6 +204,7 @@ void CustomAnimationPane::initialize()
mpCBXDuration->InsertValue(300, FUNIT_CUSTOM);
mpCBXDuration->InsertValue(500, FUNIT_CUSTOM);
mpCBXDuration->AdaptDropDownLineCountToMaximum();
+ mpCBXDuration->SetShowDecimals(true);
mpPBAddEffect->SetClickHdl( LINK( this, CustomAnimationPane, implClickHdl ) );
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 8740c9749922..9daa2ab8e944 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -79,7 +79,7 @@ bool ImplNumericProcessKeyInput( const KeyEvent& rKEvt,
bool ImplNumericGetValue( const OUString& rStr, sal_Int64& rValue,
sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrappper,
- bool bCurrency = false )
+ bool bCurrency = false, bool bShowDecimals = false )
{
OUString aStr = rStr;
OUStringBuffer aStr1, aStr2, aStrFrac, aStrNum, aStrDenom;
@@ -130,7 +130,7 @@ bool ImplNumericGetValue( const OUString& rStr, sal_Int64& rValue,
aStr1.append(aStr.getStr(), nDecPos);
aStr2.append(aStr.getStr()+nDecPos+1);
}
- else if (nDecDigits > 0 && aStr.getLength() > nDecDigits)
+ else if (bShowDecimals && nDecDigits > 0 && aStr.getLength() > nDecDigits)
{
// We expect a decimal point and a certain number of decimal digits,
// but seems the user has deleted the decimal point, so we restore it.
@@ -496,7 +496,7 @@ bool FormatterBase::IsEmptyFieldValue() const
bool NumericFormatter::ImplNumericReformat( const OUString& rStr, sal_Int64& rValue,
OUString& rOutStr )
{
- if ( !ImplNumericGetValue( rStr, rValue, GetDecimalDigits(), ImplGetLocaleDataWrapper() ) )
+ if ( !ImplNumericGetValue( rStr, rValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), false, IsShowDecimals()) )
return true;
else
{
@@ -512,10 +512,11 @@ void NumericFormatter::ImplInit()
mnFieldValue = 0;
mnLastValue = 0;
mnMin = 0;
- mnMax = 100000000; // A user-friendly round number.
+ mnMax = 1000000; // A user-friendly round number.
// a "large" value substantially smaller than SAL_MAX_INT64, to avoid
// overflow in computations using this "dummy" value
mnDecimalDigits = 2;
+ mbShowDecimals = false;
mbThousandSep = true;
mbShowTrailingZeros = true;
mbWrapOnLimits = false;
@@ -604,7 +605,7 @@ sal_Int64 NumericFormatter::GetValueFromString(const OUString& rStr) const
sal_Int64 nTempValue;
if (ImplNumericGetValue(rStr, nTempValue,
- GetDecimalDigits(), ImplGetLocaleDataWrapper()))
+ GetDecimalDigits(), ImplGetLocaleDataWrapper(), false, IsShowDecimals()))
{
return ClipAgainstMinMax(nTempValue);
}
@@ -1317,11 +1318,11 @@ double MetricField::ConvertDoubleValue( double nValue, sal_uInt16 nDigits,
}
static bool ImplMetricGetValue( const OUString& rStr, double& rValue, sal_Int64 nBaseValue,
- sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, FieldUnit eUnit )
+ sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, FieldUnit eUnit, bool bShowDecimals )
{
// Get value
sal_Int64 nValue;
- if ( !ImplNumericGetValue( rStr, nValue, nDecDigits, rLocaleDataWrapper ) )
+ if ( !ImplNumericGetValue( rStr, nValue, nDecDigits, rLocaleDataWrapper, false, bShowDecimals ) )
return false;
// Determine unit
@@ -1336,7 +1337,7 @@ static bool ImplMetricGetValue( const OUString& rStr, double& rValue, sal_Int64
bool MetricFormatter::ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr )
{
- if ( !ImplMetricGetValue( rStr, rValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ) )
+ if ( !ImplMetricGetValue( rStr, rValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit, IsShowDecimals() ) )
return true;
else
{
@@ -1427,7 +1428,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 (!ImplMetricGetValue(rStr, nTempValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit, IsShowDecimals()))
nTempValue = static_cast<double>(mnLastValue);
// caution: precision loss in double cast
@@ -1791,7 +1792,7 @@ sal_Int64 MetricBox::GetValue( sal_Int32 nPos ) const
{
double nValue = 0;
ImplMetricGetValue( ComboBox::GetEntry( nPos ), nValue, mnBaseValue,
- GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit );
+ GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit, IsShowDecimals() );
// convert to previously configured units
sal_Int64 nRetValue = MetricField::ConvertValue( (sal_Int64)nValue, mnBaseValue, GetDecimalDigits(),
More information about the Libreoffice-commits
mailing list