editeng/source/items/borderline.cxx |   24 +++++++++++-------------
 editeng/source/items/itemtype.cxx   |    6 +++---
 editeng/source/items/paraitem.cxx   |    2 +-
 3 files changed, 15 insertions(+), 17 deletions(-)

New commits:
commit f0a79b4dc1e96eb5dda35097d0975aae9f3e0c98
Author:     Tuukka Orava <tuukka.or...@outlook.com>
AuthorDate: Sat May 4 20:00:25 2024 +0300
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Wed Jul 24 10:32:08 2024 +0200

    tdf#147021 Use std::size instead of SAL_N_ELEMENTS in editeng
    
    Change-Id: I6cf0557b1e44dff08fa1efa4aefa14dec276458e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167134
    Reviewed-by: Hossein <hoss...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/editeng/source/items/borderline.cxx 
b/editeng/source/items/borderline.cxx
index 05742eb95131..e258d876c398 100644
--- a/editeng/source/items/borderline.cxx
+++ b/editeng/source/items/borderline.cxx
@@ -455,24 +455,22 @@ void SvxBorderLine::GuessLinesWidths( SvxBorderLineStyle 
nStyle, sal_uInt16 nOut
             SvxBorderLineStyle::THICKTHIN_LARGEGAP
         };
 
-        static size_t const len = SAL_N_ELEMENTS(aDoubleStyles);
         tools::Long nWidth = 0;
-        SvxBorderLineStyle nTestStyle(SvxBorderLineStyle::NONE);
-        for (size_t i = 0; i < len && nWidth == 0; ++i)
+        for (auto nTestStyle : aDoubleStyles)
         {
-            nTestStyle = aDoubleStyles[i];
             BorderWidthImpl aWidthImpl = getWidthImpl( nTestStyle );
             nWidth = aWidthImpl.GuessWidth( nOut, nIn, nDist );
+            if (nWidth != 0)
+            {
+                // If anything matched, then set it
+                nStyle = nTestStyle;
+                SetBorderLineStyle(nStyle);
+                m_nWidth = nWidth;
+                break;
+            }
         }
 
-        // If anything matched, then set it
-        if ( nWidth > 0 )
-        {
-            nStyle = nTestStyle;
-            SetBorderLineStyle(nStyle);
-            m_nWidth = nWidth;
-        }
-        else
+        if (nWidth == 0)
         {
             // fdo#38542: not a known double, default to something custom...
             SetBorderLineStyle(nStyle);
@@ -664,7 +662,7 @@ OUString SvxBorderLine::GetValueString(MapUnit eSrcUnit,
     };
     OUString aStr = "(" + ::GetColorString(m_aColor) + cpDelim;
 
-    if ( static_cast<int>(m_nStyle) < int(SAL_N_ELEMENTS(aStyleIds)) )
+    if ( static_cast<size_t>(m_nStyle) < std::size(aStyleIds) )
     {
         TranslateId pResId = aStyleIds[static_cast<int>(m_nStyle)];
         aStr += EditResId(pResId);
diff --git a/editeng/source/items/itemtype.cxx 
b/editeng/source/items/itemtype.cxx
index cbb83c83be35..b95c62c1a386 100644
--- a/editeng/source/items/itemtype.cxx
+++ b/editeng/source/items/itemtype.cxx
@@ -146,7 +146,7 @@ OUString GetColorString( const Color& rCol )
         COL_LIGHTRED, COL_LIGHTMAGENTA, COL_YELLOW, COL_WHITE };
 
     sal_uInt16 nColor = 0;
-    while ( nColor < SAL_N_ELEMENTS(aColAry) &&
+    while ( nColor < std::size(aColAry) &&
             aColAry[nColor] != rCol.GetRGBColor() )
     {
         nColor += 1;
@@ -172,10 +172,10 @@ OUString GetColorString( const Color& rCol )
         RID_SVXITEMS_COLOR_WHITE
     };
 
-    static_assert(SAL_N_ELEMENTS(aColAry) == 
SAL_N_ELEMENTS(RID_SVXITEMS_COLORS), "must match");
+    static_assert(std::size(aColAry) == std::size(RID_SVXITEMS_COLORS), "must 
match");
 
     OUString sStr;
-    if ( nColor < SAL_N_ELEMENTS(aColAry) )
+    if ( nColor < std::size(aColAry) )
         sStr = EditResId(RID_SVXITEMS_COLORS[nColor]);
 
     if ( sStr.isEmpty() )
diff --git a/editeng/source/items/paraitem.cxx 
b/editeng/source/items/paraitem.cxx
index 87d892dc3409..f70ff274e787 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -451,7 +451,7 @@ OUString SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos )
         RID_SVXITEMS_ADJUST_CENTER,
         RID_SVXITEMS_ADJUST_BLOCKLINE
     };
-    static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_ADJUST) - 1 == 
size_t(SvxAdjust::BlockLine), "unexpected size");
+    static_assert(std::size(RID_SVXITEMS_ADJUST) - 1 == 
static_cast<size_t>(SvxAdjust::BlockLine), "unexpected size");
     assert(nPos <= sal_uInt16(SvxAdjust::BlockLine) && "enum overflow!");
     return EditResId(RID_SVXITEMS_ADJUST[nPos]);
 }

Reply via email to