[Libreoffice-commits] core.git: include/svtools svtools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 17 11:59:16 UTC 2019
include/svtools/ctrlbox.hxx | 3 +++
svtools/source/control/ctrlbox.cxx | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
New commits:
commit edf8e2b6630ca9cf7117d9c7a25ef9d7231c5a9b
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jan 16 17:16:27 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jan 17 12:58:53 2019 +0100
Resolves: tdf#122744 pt/% values not limited to historic limits
Change-Id: I439bf27b3f57838d9d0ea19605fd1b684ad4f777
Reviewed-on: https://gerrit.libreoffice.org/66474
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/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx
index ef2687cc24b0..5b2583e5ce13 100644
--- a/include/svtools/ctrlbox.hxx
+++ b/include/svtools/ctrlbox.hxx
@@ -421,6 +421,8 @@ class SVT_DLLPUBLIC SvtFontSizeBox
FontMetric aFontMetric;
const FontList* pFontList;
int nSavedValue;
+ int nMin;
+ int nMax;
FieldUnit eUnit;
sal_uInt16 nDecimalDigits;
sal_uInt16 nRelMin;
@@ -440,6 +442,7 @@ class SVT_DLLPUBLIC SvtFontSizeBox
void SetDecimalDigits(sal_uInt16 nDigits) { nDecimalDigits = nDigits; }
FieldUnit GetUnit() const { return eUnit; }
void SetUnit(FieldUnit _eUnit) { eUnit = _eUnit; }
+ void SetRange(int nNewMin, int nNewMax) { nMin = nNewMin; nMax = nNewMax; }
void SetValue(int nNewValue, FieldUnit eInUnit);
void InsertValue(int i);
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index dea1fd973289..d11e5c6b15c1 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1401,6 +1401,8 @@ sal_Int64 FontSizeBox::GetValueFromStringUnit(const OUString& rStr, FieldUnit eO
SvtFontSizeBox::SvtFontSizeBox(std::unique_ptr<weld::ComboBox> p)
: pFontList(nullptr)
, nSavedValue(0)
+ , nMin(20)
+ , nMax(9999)
, eUnit(FieldUnit::POINT)
, nDecimalDigits(1)
, nRelMin(0)
@@ -1616,6 +1618,7 @@ void SvtFontSizeBox::SetRelative( bool bNewRelative )
if (bPtRelative)
{
SetDecimalDigits( 1 );
+ SetRange(nPtRelMin, nPtRelMax);
SetUnit(FieldUnit::POINT);
short i = nPtRelMin, n = 0;
@@ -1629,6 +1632,7 @@ void SvtFontSizeBox::SetRelative( bool bNewRelative )
else
{
SetDecimalDigits(0);
+ SetRange(nRelMin, nRelMax);
SetUnit(FieldUnit::PERCENT);
sal_uInt16 i = nRelMin;
@@ -1645,6 +1649,7 @@ void SvtFontSizeBox::SetRelative( bool bNewRelative )
m_xComboBox->clear();
bRelative = bPtRelative = false;
SetDecimalDigits(1);
+ SetRange(20, 9999);
SetUnit(FieldUnit::POINT);
if ( pFontList)
Fill( &aFontMetric, pFontList );
@@ -1685,6 +1690,10 @@ OUString SvtFontSizeBox::format_number(int nValue) const
void SvtFontSizeBox::SetValue(int nNewValue, FieldUnit eInUnit)
{
auto nTempValue = MetricField::ConvertValue(nNewValue, 0, GetDecimalDigits(), eInUnit, GetUnit());
+ if (nTempValue < nMin)
+ nTempValue = nMin;
+ else if (nTempValue > nMax)
+ nTempValue = nMax;
if (!bRelative)
{
FontSizeNames aFontSizeNames(Application::GetSettings().GetUILanguageTag().getLanguageType());
@@ -1725,6 +1734,13 @@ int SvtFontSizeBox::get_value() const
const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
double fResult(0.0);
MetricFormatter::TextToValue(aStr, fResult, 0, GetDecimalDigits(), rLocaleData, GetUnit());
+ if (!aStr.isEmpty())
+ {
+ if (fResult < nMin)
+ fResult = nMin;
+ else if (fResult > nMax)
+ fResult = nMax;
+ }
return fResult;
}
More information about the Libreoffice-commits
mailing list