summaryrefslogtreecommitdiff
path: root/sw/source/filter/writer/wrtswtbl.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-05-21 17:44:32 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-05-21 21:09:57 +0200
commit2634bc59092b24217d984a5845365d703bdb08d2 (patch)
treea3b7324d54aefb57d5f012c7aeb1b80d07fce75b /sw/source/filter/writer/wrtswtbl.cxx
parentc912c4b02b2dc4cd5aa62d77e92e1731c6cbde65 (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/filter/writer/wrtswtbl.cxx')
-rw-r--r--sw/source/filter/writer/wrtswtbl.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx
index 6c16d3c139ef..a504111c55f6 100644
--- a/sw/source/filter/writer/wrtswtbl.cxx
+++ b/sw/source/filter/writer/wrtswtbl.cxx
@@ -336,14 +336,14 @@ sal_uInt16 SwWriteTable::GetAbsWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) con
nWidth -= GetLeftSpace( nCol ) + GetRightSpace( nCol, nColSpan );
OSL_ENSURE( nWidth > 0, "Column Width <= 0. OK?" );
- return nWidth > 0 ? static_cast<sal_uInt16>(nWidth) : 0;
+ return nWidth > 0 ? o3tl::narrowing<sal_uInt16>(nWidth) : 0;
}
sal_uInt16 SwWriteTable::GetRelWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const
{
tools::Long nWidth = GetRawWidth( nCol, nColSpan );
- return static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*256 + GetBaseWidth()/2,
+ return o3tl::narrowing<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*256 + GetBaseWidth()/2,
GetBaseWidth() )));
}
@@ -353,7 +353,7 @@ sal_uInt16 SwWriteTable::GetPercentWidth( sal_uInt16 nCol, sal_uInt16 nColSpan )
// Looks funny, but is nothing more than
// [(100 * nWidth) + .5] without rounding errors
- return static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*100 + GetBaseWidth()/2,
+ return o3tl::narrowing<sal_uInt16>(static_cast<tools::Long>(Fraction( nWidth*100 + GetBaseWidth()/2,
GetBaseWidth() )));
}
@@ -659,7 +659,7 @@ void SwWriteTable::FillTableRowsCols( tools::Long nStartRPos, sal_uInt16 nStartR
// The new table model may have true row span attributes
const sal_Int32 nAttrRowSpan = pBox->getRowSpan();
if ( 1 < nAttrRowSpan )
- nRowSpan = static_cast<sal_uInt16>(nAttrRowSpan);
+ nRowSpan = o3tl::narrowing<sal_uInt16>(nAttrRowSpan);
else if ( nAttrRowSpan < 1 )
nRowSpan = 0;