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-25 10:40:18 +0100 |
commit | 1d50bf3839b37295dac7e3f91cdc21595285cecb (patch) | |
tree | 19dd80784a30af62bb5c723bc12c0a2d2304667a | |
parent | 91e8ee86d499b759aa6639368a40528482e49fb6 (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>
(cherry picked from commit 20c08e47f7c156a4726194215b389f4d0b165904)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88953
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
(cherry picked from commit 1c75d4df766098b51221ad20f9f569aff87d1b1b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89280
-rw-r--r-- | include/vcl/fmtfield.hxx | 1 | ||||
-rw-r--r-- | vcl/source/control/fmtfield.cxx | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/include/vcl/fmtfield.hxx b/include/vcl/fmtfield.hxx index 287146a62e6f..d181ebf6efe9 100644 --- a/include/vcl/fmtfield.hxx +++ b/include/vcl/fmtfield.hxx @@ -65,6 +65,7 @@ protected: bool m_bHasMin : 1; bool m_bHasMax : 1; + bool m_bWrapOnLimits : 1; bool m_bStrictFormat : 1; bool m_bEnableEmptyField : 1; diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index dc584833cc07..96d5293a79be 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/svapp.hxx> #include <vcl/builderfactory.hxx> @@ -296,7 +297,6 @@ FormattedField::StaticFormatter::~StaticFormatter() } } - FormattedField::FormattedField(vcl::Window* pParent, WinBits nStyle) :SpinField(pParent, nStyle) ,m_aLastSelection(0,0) @@ -304,6 +304,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) @@ -849,11 +850,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; @@ -988,6 +994,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; |