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/unocore/unoframe.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/unocore/unoframe.cxx')
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 894e4db8733b..e5c8fb7e1515 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1409,7 +1409,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& } else if(IsDescriptor()) { - m_pProps->SetProperty(static_cast<sal_uInt16>(RES_FRAMEDIR), 0, _rValue); + m_pProps->SetProperty(o3tl::narrowing<sal_uInt16>(RES_FRAMEDIR), 0, _rValue); } return; } @@ -1476,16 +1476,16 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& pNoText->SetContour(nullptr); else if(aValue >>= aParam) { - tools::PolyPolygon aPoly(static_cast<sal_uInt16>(aParam.getLength())); + tools::PolyPolygon aPoly(o3tl::narrowing<sal_uInt16>(aParam.getLength())); for(const ::drawing::PointSequence& rPointSeq : std::as_const(aParam)) { sal_Int32 nPoints = rPointSeq.getLength(); const ::awt::Point* pPoints = rPointSeq.getConstArray(); - tools::Polygon aSet( static_cast<sal_uInt16>(nPoints) ); + tools::Polygon aSet( o3tl::narrowing<sal_uInt16>(nPoints) ); for(sal_Int32 j = 0; j < nPoints; j++) { Point aPoint(pPoints[j].X, pPoints[j].Y); - aSet.SetPoint(aPoint, static_cast<sal_uInt16>(j)); + aSet.SetPoint(aPoint, o3tl::narrowing<sal_uInt16>(j)); } // Close polygon if it isn't closed already. aSet.Optimize( PolyOptimizeFlags::CLOSE ); |