diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-05-21 17:44:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-05-21 21:09:57 +0200 |
commit | 2634bc59092b24217d984a5845365d703bdb08d2 (patch) | |
tree | a3b7324d54aefb57d5f012c7aeb1b80d07fce75b /sw/source/ui/table | |
parent | c912c4b02b2dc4cd5aa62d77e92e1731c6cbde65 (diff) |
sw: replace most static_cast<sal_uInt16>() calls with o3tl::narrowing()
o3tl::narrowing() is a better way to handle this, as that way the
integer conversion is still implicit, which allows detecting integer
truncation at runtime (with suitable compiler flags).
Change-Id: I499abda3be6943e8c111c56df390e72939586221
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115948
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source/ui/table')
-rw-r--r-- | sw/source/ui/table/colwd.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/table/tabledlg.cxx | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/sw/source/ui/table/colwd.cxx b/sw/source/ui/table/colwd.cxx index 435b4ee10dc2..2440d8696fac 100644 --- a/sw/source/ui/table/colwd.cxx +++ b/sw/source/ui/table/colwd.cxx @@ -28,7 +28,7 @@ IMPL_LINK_NOARG(SwTableWidthDlg, LoseFocusHdl, weld::SpinButton&, void) { - sal_uInt16 nId = static_cast<sal_uInt16>(m_xColNF->get_value()) - 1; + sal_uInt16 nId = o3tl::narrowing<sal_uInt16>(m_xColNF->get_value()) - 1; const SwTwips lWidth = m_rFnc.GetColWidth(nId); m_xWidthMF->set_max(m_xWidthMF->normalize(m_rFnc.GetMaxColWidth(nId)), FieldUnit::TWIP); m_xWidthMF->set_value(m_xWidthMF->normalize(lWidth), FieldUnit::TWIP); @@ -60,8 +60,8 @@ SwTableWidthDlg::SwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rTableFnc) void SwTableWidthDlg::Apply() { m_rFnc.InitTabCols(); - m_rFnc.SetColWidth(static_cast<sal_uInt16>(m_xColNF->get_value() - 1), - static_cast<sal_uInt16>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP)))); + m_rFnc.SetColWidth(o3tl::narrowing<sal_uInt16>(m_xColNF->get_value() - 1), + o3tl::narrowing<sal_uInt16>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP)))); } short SwTableWidthDlg::run() diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx index 836a3499f50e..36964d4f10fe 100644 --- a/sw/source/ui/table/tabledlg.cxx +++ b/sw/source/ui/table/tabledlg.cxx @@ -1349,7 +1349,7 @@ bool SwTextFlowPage::FillItemSet( SfxItemSet* rSet ) { sPage = m_xPageCollLB->get_active_text(); } - sal_uInt16 nPgNum = static_cast<sal_uInt16>(m_xPageNoNF->get_value()); + sal_uInt16 nPgNum = o3tl::narrowing<sal_uInt16>(m_xPageNoNF->get_value()); bool const usePageNo(bState && m_xPageNoCB->get_active()); std::optional<sal_uInt16> const oPageNum( usePageNo ? nPgNum : std::optional<sal_Int16>()); |