sw/source/ui/misc/pggrid.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
New commits: commit 6665db99973bd41d07c99a4aaf81f6d145ee4d24 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Jun 27 14:28:58 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Jun 27 18:56:08 2022 +0200 sw: avoid divide by zero in SwTextGridPage::CharorLineChangedHdl See https://crashreport.libreoffice.org/stats/signature/SwTextGridPage::CharorLineChangedHdl(weld::SpinButton%20&) disable the offending widget if the value is zero. crash reproducible under gen with CJK features enabled by: format, page style, text grid, grid (lines and characters), max base text size of 1000 and then click in "characters per line" and then click in "lines per page". Change-Id: Ic0f8131955ab01412dd54bdd5d3bffe518938fb5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136489 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 6b54d3821bd6..7f9b10cd447a 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -316,10 +316,13 @@ void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet) { sal_Int32 nCharsPerLine = m_aPageSize.Width() / nTextSize; m_xCharsPerLineNF->set_max(nCharsPerLine); + m_xCharsPerLineNF->set_sensitive(nCharsPerLine != 0); m_xCharsPerLineNF->set_value(nCharsPerLine); - m_xLinesPerPageNF->set_max(m_aPageSize.Height() / + sal_Int32 nMaxLines = m_aPageSize.Height() / ( m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP)) + - m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP)))); + m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP))); + m_xLinesPerPageNF->set_max(nMaxLines); + m_xLinesPerPageNF->set_sensitive(nMaxLines != 0); SetLinesOrCharsRanges( *m_xCharsRangeFT , m_xCharsPerLineNF->get_max() ); SetLinesOrCharsRanges( *m_xLinesRangeFT , m_xLinesPerPageNF->get_max() ); } @@ -369,6 +372,7 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, weld::SpinButton&, rField, void) ( m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP)) + m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP)))); m_xLinesPerPageNF->set_max(nMaxLines); + m_xLinesPerPageNF->set_sensitive(nMaxLines != 0); } SetLinesOrCharsRanges( *m_xLinesRangeFT , m_xLinesPerPageNF->get_max() ); SetLinesOrCharsRanges( *m_xCharsRangeFT , m_xCharsPerLineNF->get_max() ); @@ -415,6 +419,7 @@ IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, weld::MetricSpinButton&, rField, v sal_Int32 nMaxChars = m_aPageSize.Width() / nTextSize; m_xCharsPerLineNF->set_value(nMaxChars); m_xCharsPerLineNF->set_max(nMaxChars); + m_xCharsPerLineNF->set_sensitive(nMaxChars != 0); SetLinesOrCharsRanges( *m_xCharsRangeFT , m_xCharsPerLineNF->get_max() ); } } @@ -424,6 +429,7 @@ IMPL_LINK(SwTextGridPage, TextSizeChangedHdl, weld::MetricSpinButton&, rField, v ( m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP)) + m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP)))); m_xLinesPerPageNF->set_max(nMaxLines); + m_xLinesPerPageNF->set_sensitive(nMaxLines != 0); SetLinesOrCharsRanges( *m_xLinesRangeFT , m_xLinesPerPageNF->get_max() ); } }