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/core/text/porlin.cxx | |
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/core/text/porlin.cxx')
-rw-r--r-- | sw/source/core/text/porlin.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index 035f670d464b..e0a157d9d579 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -88,7 +88,7 @@ void SwLinePortion::PrePaint( const SwTextPaintInfo& rInf, sal_uInt16 nLastWidth = pLast->Width(); if ( pLast->InSpaceGrp() && rInf.GetSpaceAdd() ) - nLastWidth = nLastWidth + static_cast<sal_uInt16>(pLast->CalcSpacing( rInf.GetSpaceAdd(), rInf )); + nLastWidth = nLastWidth + o3tl::narrowing<sal_uInt16>(pLast->CalcSpacing( rInf.GetSpaceAdd(), rInf )); sal_uInt16 nPos; SwTextPaintInfo aInf( rInf ); @@ -246,7 +246,7 @@ bool SwLinePortion::Format( SwTextFormatInfo &rInf ) const SwLinePortion *pLast = rInf.GetLast(); Height( pLast->Height() ); SetAscent( pLast->GetAscent() ); - const sal_uInt16 nNewWidth = static_cast<sal_uInt16>(rInf.X() + PrtWidth()); + const sal_uInt16 nNewWidth = o3tl::narrowing<sal_uInt16>(rInf.X() + PrtWidth()); // Only portions with true width can return true // Notes for example never set bFull==true if( rInf.Width() <= nNewWidth && PrtWidth() && ! IsKernPortion() ) |