basctl/source/basicide/baside2.cxx                   |    2 +-
 basegfx/source/polygon/b2dpolypolygontools.cxx       |    2 +-
 basic/qa/cppunit/test_vba.cxx                        |    4 ++--
 basic/source/runtime/methods.cxx                     |    2 +-
 basic/source/runtime/methods1.cxx                    |   14 +++++++-------
 binaryurp/qa/test-cache.cxx                          |    2 +-
 chart2/qa/extras/chart2export.cxx                    |    2 +-
 chart2/source/controller/dialogs/res_BarGeometry.cxx |    2 +-
 chart2/source/controller/dialogs/res_DataLabel.cxx   |    2 +-
 codemaker/source/cppumaker/cpputype.cxx              |   10 ++++------
 10 files changed, 20 insertions(+), 22 deletions(-)

New commits:
commit 8b327cd86d71d71d2f5f883321e5d53e3b42ed4e
Author:     VaibhavMalik4187 <vaibhavmalik2...@gmail.com>
AuthorDate: Fri Feb 4 17:36:52 2022 +0530
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Sun Feb 6 21:38:32 2022 +0100

    tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro
    
    Change-Id: I4f5258ca5b37e9b1b4237c5d29e4a9e5362fa855
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129116
    Reviewed-by: Arkadiy Illarionov <qar...@gmail.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/basctl/source/basicide/baside2.cxx 
b/basctl/source/basicide/baside2.cxx
index 52769276bacb..eecf917d6035 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -1584,7 +1584,7 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool 
bFirst)
     }
 
     bool bChanged = false;
-    for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i)
+    for (unsigned i = 0; i != std::size(vIds); ++i)
     {
         Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor;
         Color& rMyColor = aColors[vIds[i].eTokenType];
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx 
b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 74cdf23241d3..b49de907d45c 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -514,7 +514,7 @@ namespace basegfx::utils
             }
 
             B2DPolygon aCurrSegment;
-            const size_t sliceSize=SAL_N_ELEMENTS(numbers)/12;
+            const size_t sliceSize=std::size(numbers)/12;
             const int* pCurrSegment=numbers + nNumber*sliceSize;
             for( size_t i=0; i<sliceSize; i++, pCurrSegment++)
             {
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 818ba1c5f4c0..868dc15891e3 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -157,7 +157,7 @@ void VBATest::testMiscVBAFunctions()
     SvtSysLocaleOptions aLocalOptions;
     aLocalOptions.SetLocaleConfigString( aLocale.getBcp47() );
 
-    for ( size_t  i=0; i<SAL_N_ELEMENTS( macroSource ); ++i )
+    for ( size_t  i=0; i<std::size( macroSource ); ++i )
     {
         OUString sMacroURL = sMacroPathURL
                            + OUString::createFromAscii( macroSource[ i ] );
@@ -238,7 +238,7 @@ void VBATest::testMiscOLEStuff()
         uno::makeAny(OUString(o3tl::toU(pODBCDriverName)))
     };
 
-    for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( macroSource ); ++i )
+    for ( sal_uInt32  i=0; i<std::size( macroSource ); ++i )
     {
         OUString sMacroURL = sMacroPathURL
                            + OUString::createFromAscii( macroSource[ i ] );
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 7113e6e34f4c..3839d84852ea 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -3734,7 +3734,7 @@ OUString getBasicTypeName( SbxDataType eType )
     };
 
     size_t nPos = static_cast<size_t>(eType) & 0x0FFF;
-    const size_t nTypeNameCount = SAL_N_ELEMENTS( pTypeNames );
+    const size_t nTypeNameCount = std::size( pTypeNames );
     if ( nPos >= nTypeNameCount )
     {
         nPos = nTypeNameCount - 1;
diff --git a/basic/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 16104540ba96..31943cde2b80 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -1807,13 +1807,13 @@ static IntervalInfo const * getIntervalInfo( const 
OUString& rStringCode )
         { INTERVAL_N,    "n",    1.0 /  1440.0, true  }, // Minute
         { INTERVAL_S,    "s",    1.0 / 86400.0, true  }  // Second
     };
-    for( std::size_t i = 0; i != SAL_N_ELEMENTS(aIntervalTable); ++i )
-    {
-        if( rStringCode.equalsIgnoreAsciiCaseAscii(
-                aIntervalTable[i].mStringCode ) )
-        {
-            return &aIntervalTable[i];
-        }
+    auto const pred = [&rStringCode](const IntervalInfo &aInterval) {
+            return 
rStringCode.equalsIgnoreAsciiCaseAscii(aInterval.mStringCode);
+    };
+
+    auto intervalIter = std::find_if(std::begin(aIntervalTable), 
std::end(aIntervalTable), pred);
+    if(intervalIter != std::end(aIntervalTable)) {
+            return intervalIter;
     }
     return nullptr;
 }
diff --git a/binaryurp/qa/test-cache.cxx b/binaryurp/qa/test-cache.cxx
index 989b103e2e90..c024f1f711d6 100644
--- a/binaryurp/qa/test-cache.cxx
+++ b/binaryurp/qa/test-cache.cxx
@@ -39,7 +39,7 @@ private:
 // cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java:
 void Test::testNothingLostFromLruList() {
     int a[8];
-    for (int i = 0; i != int(SAL_N_ELEMENTS(a)); ++i) {
+    for (int i = 0; i != int(std::size(a)); ++i) {
         for (int j = 0; j != i; ++j) {
             a[j] = 0;
         }
diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index a5c2e20cc58c..bca7897025a0 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -932,7 +932,7 @@ void Chart2ExportTest::testDataLabelBordersDOCX()
                 { 2, css::drawing::LineStyle_SOLID, 0x00FF0000 }  // solid red
             };
 
-            for (size_t i = 0; i < SAL_N_ELEMENTS(aDataPoints); ++i)
+            for (size_t i = 0; i < std::size(aDataPoints); ++i)
             {
                 xPropSet = 
xDataSeries->getDataPointByIndex(aDataPoints[i].mnIndex);
                 CPPUNIT_ASSERT(xPropSet.is());
diff --git a/chart2/source/controller/dialogs/res_BarGeometry.cxx 
b/chart2/source/controller/dialogs/res_BarGeometry.cxx
index 182d391aac33..97befbe1f8f5 100644
--- a/chart2/source/controller/dialogs/res_BarGeometry.cxx
+++ b/chart2/source/controller/dialogs/res_BarGeometry.cxx
@@ -27,7 +27,7 @@ BarGeometryResources::BarGeometryResources(weld::Builder* 
pBuilder)
     : m_xFT_Geometry(pBuilder->weld_label("shapeft"))
     , m_xLB_Geometry(pBuilder->weld_tree_view("shape"))
 {
-    for (size_t i = 0; i < SAL_N_ELEMENTS(CHART_TYPE); ++i)
+    for (size_t i = 0; i < std::size(CHART_TYPE); ++i)
         m_xLB_Geometry->append_text(SchResId(CHART_TYPE[i]));
     m_xLB_Geometry->set_size_request(-1,
                                      
m_xLB_Geometry->get_height_rows(SAL_N_ELEMENTS(CHART_TYPE)));
diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx 
b/chart2/source/controller/dialogs/res_DataLabel.cxx
index a51e9d79a860..5630e94baba2 100644
--- a/chart2/source/controller/dialogs/res_DataLabel.cxx
+++ b/chart2/source/controller/dialogs/res_DataLabel.cxx
@@ -333,7 +333,7 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs)
 
     const SfxPoolItem *pPoolItem = nullptr;
     if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, true, &pPoolItem) 
== SfxItemState::SET )
-       for(size_t i=0; i < SAL_N_ELEMENTS(our_aLBEntryMap); ++i )
+       for(size_t i=0; i < std::size(our_aLBEntryMap); ++i )
        {
           if( our_aLBEntryMap[i] == static_cast<const 
SfxStringItem*>(pPoolItem)->GetValue())
               m_xLB_Separator->set_active( i );
diff --git a/codemaker/source/cppumaker/cpputype.cxx 
b/codemaker/source/cppumaker/cpputype.cxx
index d64c79a36c2c..e5436c9049f5 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -143,12 +143,10 @@ bool isBootstrapType(OUString const & name)
         "com.sun.star.uno.XWeak",
         "com.sun.star.util.XMacroExpander" };
         // cf. cppuhelper/unotypes/Makefile UNOTYPES (plus missing 
dependencies)
-    for (std::size_t i = 0; i < SAL_N_ELEMENTS(names); ++i) {
-        if (name.equalsAscii(names[i])) {
-            return true;
-        }
-    }
-    return false;
+    auto const pred = [&name](const char* aName) {
+            return name.equalsAscii(aName);
+    };
+    return std::any_of(std::begin(names), std::end(names), pred);
 }
 
 class CppuType

Reply via email to