sw/source/core/text/txtfrm.cxx |   28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

New commits:
commit 8d528d72303141a2a00a94b8755b90cf26d61ccf
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue May 20 06:32:28 2025 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue May 20 08:24:41 2025 +0200

    Avoid some unneeded casting
    
    Change-Id: I6df49f9cf200b659dfe8a86e991d98b8a1ffa012
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185547
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 9e0c662aa3c1..9fc7a6605b61 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3596,11 +3596,11 @@ SwTwips 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 = 
o3tl::narrowing<sal_uInt16>(getFramePrintArea().SSize().Height());
+        SwTwips nRet = getFramePrintArea().SSize().Height();
         if( IsUndersized() )
         {
             if( IsEmpty() || GetText().isEmpty() )
-                nRet = o3tl::narrowing<sal_uInt16>(EmptyHeight());
+                nRet = EmptyHeight();
             else
                 ++nRet;
         }
@@ -3724,16 +3724,8 @@ SwTwips SwTextFrame::CalcFitToContent()
     if ( pTextNode->IsNumbered(getRootFrame()) &&
         pTextNode->IsCountedInList() && pTextNode->GetNumRule() )
     {
-        int nListLevel = pTextNode->GetActualListLevel();
-
-        if (nListLevel < 0)
-            nListLevel = 0;
-
-        if (nListLevel >= MAXLEVEL)
-            nListLevel = MAXLEVEL - 1;
-
-        const SwNumFormat& rNumFormat =
-                pTextNode->GetNumRule()->Get( 
o3tl::narrowing<sal_uInt16>(nListLevel) );
+        sal_uInt16 nListLevel = std::clamp(pTextNode->GetActualListLevel(), 0, 
MAXLEVEL - 1);
+        const SwNumFormat& rNumFormat = 
pTextNode->GetNumRule()->Get(nListLevel);
         if ( rNumFormat.GetPositionAndSpaceMode() == 
SvxNumberFormat::LABEL_ALIGNMENT )
         {
             const SwAttrSet& rSet = pTextNode->GetSwAttrSet();
@@ -3769,16 +3761,8 @@ void SwTextFrame::CalcAdditionalFirstLineOffset()
         pTextNode->IsCountedInList() && pTextNode->GetNumRule()))
         return;
 
-    int nListLevel = pTextNode->GetActualListLevel();
-
-    if (nListLevel < 0)
-        nListLevel = 0;
-
-    if (nListLevel >= MAXLEVEL)
-        nListLevel = MAXLEVEL - 1;
-
-    const SwNumFormat& rNumFormat =
-            pTextNode->GetNumRule()->Get( 
o3tl::narrowing<sal_uInt16>(nListLevel) );
+    sal_uInt16 nListLevel = std::clamp(pTextNode->GetActualListLevel(), 0, 
MAXLEVEL - 1);
+    const SwNumFormat& rNumFormat = pTextNode->GetNumRule()->Get(nListLevel);
     if ( rNumFormat.GetPositionAndSpaceMode() != 
SvxNumberFormat::LABEL_ALIGNMENT )
         return;
 

Reply via email to