diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-19 11:27:29 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-19 15:02:37 +0100 |
commit | 20c08e47f7c156a4726194215b389f4d0b165904 (patch) | |
tree | b4bb4fab95107a8170e97e17174f9afa52c824b2 /vcl/source/control/fmtfield.cxx | |
parent | c530c1b3e01015f551dd6737ef2dc0e661458310 (diff) |
Resolves: tdf#130762 honour "wrap" in FormattedField
Change-Id: Iefd9a537aa358eab179cf6f0eeb6f80a9a77284a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89011
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/control/fmtfield.cxx')
-rw-r--r-- | vcl/source/control/fmtfield.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index 51c21acfa5f2..2b738f0f4c14 100644 --- a/vcl/source/control/fmtfield.cxx +++ b/vcl/source/control/fmtfield.cxx @@ -21,6 +21,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <unotools/localedatawrapper.hxx> +#include <vcl/builder.hxx> #include <vcl/event.hxx> #include <vcl/settings.hxx> #include <vcl/commandevent.hxx> @@ -291,7 +292,6 @@ FormattedField::StaticFormatter::~StaticFormatter() } } - FormattedField::FormattedField(vcl::Window* pParent, WinBits nStyle) :SpinField(pParent, nStyle) ,m_aLastSelection(0,0) @@ -299,6 +299,7 @@ FormattedField::FormattedField(vcl::Window* pParent, WinBits nStyle) ,m_dMaxValue(0) ,m_bHasMin(false) ,m_bHasMax(false) + ,m_bWrapOnLimits(false) ,m_bStrictFormat(true) ,m_bEnableEmptyField(true) ,m_bAutoColor(false) @@ -844,11 +845,16 @@ void FormattedField::EnableEmptyField(bool bEnable) void FormattedField::ImplSetValue(double dVal, bool bForce) { - if (m_bHasMin && (dVal<m_dMinValue)) - dVal = m_dMinValue; + { + dVal = m_bWrapOnLimits ? fmod(dVal + m_dMaxValue + 1 - m_dMinValue, m_dMaxValue + 1) + m_dMinValue + : m_dMinValue; + } if (m_bHasMax && (dVal>m_dMaxValue)) - dVal = m_dMaxValue; + { + dVal = m_bWrapOnLimits ? fmod(dVal - m_dMinValue, m_dMaxValue + 1) + m_dMinValue + : m_dMaxValue; + } if (!bForce && (dVal == GetValue())) return; @@ -983,6 +989,8 @@ bool FormattedField::set_property(const OString &rKey, const OUString &rValue) { if (rKey == "digits") SetDecimalDigits(rValue.toInt32()); + else if (rKey == "wrap") + m_bWrapOnLimits = toBool(rValue); else return SpinField::set_property(rKey, rValue); return true; |