diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-15 15:34:05 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-16 09:54:33 +0200 |
commit | 414226273aa4dc0e2d06cbd482ffac37ea9338c3 (patch) | |
tree | 57be1d6aa286c16a010ac642b8a3a4d264fefda5 /sw | |
parent | 873dbd2c3a1a2fa3c27f4ecb8fe4e219f25f5751 (diff) |
coverity#1430102 Division or modulo by zero
Change-Id: I2db581b3f30713edaca4ec11f85343c436c54fae
Reviewed-on: https://gerrit.libreoffice.org/54380
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/misc/pggrid.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 24b8c06aaef6..d143f35d123f 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -386,7 +386,9 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField&, rField, void) { if(m_pCharsPerLineNF == &rField) { - long nWidth = static_cast<long>(m_aPageSize.Width() / m_pCharsPerLineNF->GetValue()); + auto nValue = m_pCharsPerLineNF->GetValue(); + assert(nValue && "div-by-zero"); + auto nWidth = m_aPageSize.Width() / nValue; m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(nWidth), FUNIT_TWIP); //prevent rounding errors in the MetricField by saving the used value m_nRubyUserValue = nWidth; @@ -409,7 +411,7 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField&, rField, void) { auto nValue = m_pLinesPerPageNF->GetValue(); assert(nValue && "div-by-zero"); - long nHeight = static_cast< sal_Int32 >(m_aPageSize.Height() / nValue); + auto nHeight = m_aPageSize.Height() / nValue; m_pTextSizeMF->SetValue(m_pTextSizeMF->Normalize(nHeight), FUNIT_TWIP); m_pRubySizeMF->SetValue(0, FUNIT_TWIP); SetLinesOrCharsRanges( *m_pLinesRangeFT , m_pLinesPerPageNF->GetMax() ); @@ -421,7 +423,7 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField&, rField, void) { auto nValue = m_pCharsPerLineNF->GetValue(); assert(nValue && "div-by-zero"); - long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / nValue); + auto nWidth = m_aPageSize.Width() / nValue; m_pCharWidthMF->SetValue(m_pCharWidthMF->Normalize(nWidth), FUNIT_TWIP); SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() ); } |