summaryrefslogtreecommitdiff
path: root/sw/source/core/text/txtfrm.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/core/text/txtfrm.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/core/text/txtfrm.cxx')
-rw-r--r--sw/source/core/text/txtfrm.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index d640737b773d..9d7aa1efdec1 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3330,11 +3330,11 @@ sal_uInt32 SwTextFrame::GetParHeight() const
if( !HasPara() )
{ // For non-empty paragraphs this is a special case
// For UnderSized we can simply just ask 1 Twip more
- sal_uInt16 nRet = static_cast<sal_uInt16>(getFramePrintArea().SSize().Height());
+ sal_uInt16 nRet = o3tl::narrowing<sal_uInt16>(getFramePrintArea().SSize().Height());
if( IsUndersized() )
{
if( IsEmpty() || GetText().isEmpty() )
- nRet = static_cast<sal_uInt16>(EmptyHeight());
+ nRet = o3tl::narrowing<sal_uInt16>(EmptyHeight());
else
++nRet;
}
@@ -3485,7 +3485,7 @@ void SwTextFrame::CalcAdditionalFirstLineOffset()
nListLevel = MAXLEVEL - 1;
const SwNumFormat& rNumFormat =
- pTextNode->GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) );
+ pTextNode->GetNumRule()->Get( o3tl::narrowing<sal_uInt16>(nListLevel) );
if ( rNumFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_ALIGNMENT )
return;
@@ -3732,7 +3732,7 @@ sal_uInt16 SwTextFrame::FirstLineHeight() const
if ( !HasPara() )
{
if( IsEmpty() && isFrameAreaDefinitionValid() )
- return IsVertical() ? static_cast<sal_uInt16>(getFramePrintArea().Width()) : static_cast<sal_uInt16>(getFramePrintArea().Height());
+ return IsVertical() ? o3tl::narrowing<sal_uInt16>(getFramePrintArea().Width()) : o3tl::narrowing<sal_uInt16>(getFramePrintArea().Height());
return USHRT_MAX;
}
const SwParaPortion *pPara = GetPara();