sw/source/uibase/utlui/prcntfld.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
New commits: commit 04019e94680835e7acf475b2ddedb5002c4a5b94 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue May 14 11:32:47 2019 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue May 14 15:52:12 2019 +0200 Resolves: tdf#125229 divide by 0 Change-Id: Iab34aa645252aea9c306f06814d75e405a2160e8 Reviewed-on: https://gerrit.libreoffice.org/72279 Reviewed-by: Michael Stahl <michael.st...@cib.de> Tested-by: Jenkins diff --git a/sw/source/uibase/utlui/prcntfld.cxx b/sw/source/uibase/utlui/prcntfld.cxx index 6564e9be928a..0bd5199ee596 100644 --- a/sw/source/uibase/utlui/prcntfld.cxx +++ b/sw/source/uibase/utlui/prcntfld.cxx @@ -55,8 +55,6 @@ void SwPercentField::ShowPercent(bool bPercent) if (bPercent) { - int nCurrentWidth, nPercent; - nOldValue = get_value(); eOldUnit = m_pField->get_unit(); @@ -66,16 +64,16 @@ void SwPercentField::ShowPercent(bool bPercent) m_pField->set_unit(FieldUnit::PERCENT); m_pField->set_digits(0); - nCurrentWidth = MetricField::ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FieldUnit::TWIP); + int nCurrentWidth = MetricField::ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FieldUnit::TWIP); // round to 0.5 percent - nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10; + int nPercent = nRefValue ? (((nCurrentWidth * 10) / nRefValue + 5) / 10) : 0; m_pField->set_range(std::max(1, nPercent), 100, FieldUnit::NONE); m_pField->set_increments(5, 10, FieldUnit::NONE); if (nOldValue != nLastValue) { nCurrentWidth = MetricField::ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP); - nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10; + nPercent = nRefValue ? (((nCurrentWidth * 10) / nRefValue + 5) / 10) : 0; m_pField->set_value(nPercent, FieldUnit::NONE); nLastPercent = nPercent; nLastValue = nOldValue; @@ -122,7 +120,7 @@ void SwPercentField::set_value(int nNewValue, FieldUnit eInUnit) int nValue = Convert(nNewValue, eInUnit, eOldUnit); nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP); } - nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10; + nPercent = nRefValue ? (((nCurrentWidth * 10) / nRefValue + 5) / 10) : 0; m_pField->set_value(nPercent, FieldUnit::NONE); } } @@ -221,7 +219,7 @@ int SwPercentField::Convert(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit) else nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, FieldUnit::TWIP); // Round to 0.5 percent - return ((nCurrentWidth * 1000) / nRefValue + 5) / 10; + return nRefValue ? (((nCurrentWidth * 1000) / nRefValue + 5) / 10) : 0; } return MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits