summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-01-16 17:16:27 +0000
committerMiklos Vajna <vmiklos@collabora.com>2019-01-25 09:20:38 +0100
commit39bee8a2e148dae05cb65778d1b21c9ea9c97dc4 (patch)
tree1c3ff2b71dbd38f4e29b1a938a0407121e2673ad /svtools
parent564c0addb3594a2221228f616374f64d1822ab41 (diff)
Resolves: tdf#122744 pt/% values not limited to historic limits
Change-Id: I439bf27b3f57838d9d0ea19605fd1b684ad4f777 Reviewed-on: https://gerrit.libreoffice.org/66475 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrlbox.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 112ce7ea2da2..9e5e6e2640c6 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1400,6 +1400,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)
@@ -1615,6 +1617,7 @@ void SvtFontSizeBox::SetRelative( bool bNewRelative )
if (bPtRelative)
{
SetDecimalDigits( 1 );
+ SetRange(nPtRelMin, nPtRelMax);
SetUnit(FieldUnit::POINT);
short i = nPtRelMin, n = 0;
@@ -1628,6 +1631,7 @@ void SvtFontSizeBox::SetRelative( bool bNewRelative )
else
{
SetDecimalDigits(0);
+ SetRange(nRelMin, nRelMax);
SetUnit(FieldUnit::PERCENT);
sal_uInt16 i = nRelMin;
@@ -1644,6 +1648,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 );
@@ -1684,6 +1689,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());
@@ -1724,6 +1733,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;
}