tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro

Also change some integer by std::size_t

Change-Id: I6a0fda3ba44815aac3312d523be04f4f973ce84f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137142
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
index 3a59cd9..90b80871 100644
--- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx
+++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
@@ -756,7 +756,7 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(bool _bHasCategor
        {
            aRowLabels.push_back(OUString::number(h+1));
            std::vector< double > aRow;
            const sal_Int32 nSize = SAL_N_ELEMENTS(fDefaultData);
            const sal_Int32 nSize = std::size(fDefaultData);
            for (size_t j = 0; j < (aColumns.size()-1); ++j,++k)
            {
                if ( k >= nSize )
diff --git a/dbaccess/source/sdbtools/connection/tablename.cxx b/dbaccess/source/sdbtools/connection/tablename.cxx
index 8698cef..2b275c0 100644
--- a/dbaccess/source/sdbtools/connection/tablename.cxx
+++ b/dbaccess/source/sdbtools/connection/tablename.cxx
@@ -190,19 +190,16 @@ namespace sdbtools
                { CompositionType::Complete,                 EComposeRule::Complete }
            };

            bool found = false;
            size_t i = 0;
            for ( ; i < SAL_N_ELEMENTS( TypeTable ) && !found; ++i )
                if ( TypeTable[i].nCompositionType == _nType )
                    found = true;
            if ( !found )
            auto const found = std::find_if(std::begin(TypeTable), std::end(TypeTable)
                                            , [_nType](auto const & type){ return type.nCompositionType == _nType; });
            if (found == std::end(TypeTable))
                throw IllegalArgumentException(
                    DBA_RES( STR_INVALID_COMPOSITION_TYPE ),
                    nullptr,
                    0
                );

            return TypeTable[i].eComposeRule;
            return found->eComposeRule;
        }
    }

diff --git a/dbaccess/source/ui/app/templwin.cxx b/dbaccess/source/ui/app/templwin.cxx
index e994078..224d8be 100644
--- a/dbaccess/source/ui/app/templwin.cxx
+++ b/dbaccess/source/ui/app/templwin.cxx
@@ -17,6 +17,7 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <algorithm>
#include <core_resource.hxx>
#include <templwin.hrc>
#include "templwin.hxx"
@@ -25,13 +26,9 @@ namespace SvtDocInfoTable_Impl
{
    OUString GetString(int nId)
    {
        for (size_t i = 0; i < SAL_N_ELEMENTS(STRARY_SVT_DOCINFO); ++i)
        {
            if (STRARY_SVT_DOCINFO[i].second == nId)
                return DBA_RES(STRARY_SVT_DOCINFO[i].first);
        }

        return OUString();
        auto const found = std::find_if(std::begin(STRARY_SVT_DOCINFO), std::end(STRARY_SVT_DOCINFO)
                                        , [nId](auto const & docinfo){ return docinfo.second == nId; });
        return (found != std::end(STRARY_SVT_DOCINFO)) ? DBA_RES(found->first) : OUString();
    }
}

diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 4cea7af..ee300a8 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1240,7 +1240,7 @@ void SbaTableQueryBrowser::connectExternalDispatches()
            ID_BROWSER_INSERTCONTENT
        };

        for ( size_t i=0; i < SAL_N_ELEMENTS( pURLs ); ++i )
        for ( size_t i=0; i < std::size( pURLs ); ++i )
        {
            URL aURL;
            aURL.Complete = OUString::createFromAscii( pURLs[i] );
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
index 0b18c390..1416b43 100644
--- a/dbaccess/source/ui/control/FieldDescControl.cxx
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -164,27 +164,28 @@ void OFieldDescControl::Init()
void OFieldDescControl::SetReadOnly( bool bReadOnly )
{
    // Enable/disable Controls
    OWidgetBase* ppAggregates[]     = {   m_xRequired.get(), m_xNumType.get()
                                        , m_xAutoIncrement.get(), m_xDefault.get()
                                        , m_xTextLen.get(), m_xLength.get()
                                        , m_xScale.get(), m_xColumnName.get()
                                        , m_xType.get(), m_xAutoIncrementValue.get()
    };
    weld::Widget* ppAggregatesText[] = {  m_xRequiredText.get(), m_xNumTypeText.get()
                                        , m_xAutoIncrementText.get(), m_xDefaultText.get()
                                        , m_xTextLenText.get(), m_xLengthText.get()
                                        , m_xScaleText.get(), m_xColumnNameText.get()
                                        , m_xTypeText.get(), m_xAutoIncrementValueText.get()
    };

    OSL_ENSURE(SAL_N_ELEMENTS(ppAggregates) == SAL_N_ELEMENTS(ppAggregatesText),"Lists are not identical!");

    for (size_t i=0; i<SAL_N_ELEMENTS(ppAggregates); ++i)
    struct final
    {
        if ( ppAggregatesText[i] )
            ppAggregatesText[i]->set_sensitive( !bReadOnly );
        if ( ppAggregates[i] )
            ppAggregates[i]->set_sensitive( !bReadOnly );
        OWidgetBase * aggregate;
        weld::Widget * text;
    } const aggregates[] = {
        {m_xRequired.get(), m_xRequiredText.get()}
        , {m_xNumType.get(), m_xNumTypeText.get()}
        , {m_xAutoIncrement.get(), m_xAutoIncrementText.get()}
        , {m_xDefault.get(), m_xDefaultText.get()}
        , {m_xTextLen.get(), m_xTextLenText.get()}
        , {m_xLength.get(), m_xLengthText.get()}
        , {m_xScale.get(), m_xScaleText.get()}
        , {m_xColumnName.get(), m_xColumnNameText.get()}
        , {m_xType.get(), m_xTypeText.get()}
        , {m_xAutoIncrementValue.get(), m_xAutoIncrementValueText.get()}};

    for (auto const & aggregate: aggregates)
    {
        if (aggregate.text)
            aggregate.text->set_sensitive(!bReadOnly);
        if (aggregate.aggregate)
            aggregate.aggregate->set_sensitive(!bReadOnly);
    }

    if (m_xFormat)
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
index 15fa887..0d93dc3 100644
--- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
@@ -94,24 +94,23 @@ namespace dbaui
        {
            short   nFlag;
            weld::Widget* pFrame;
        } aSections[] = {
        } const aSections[] = {
            { TC_EXTENSION,     m_xExtensionHeader.get() },
            { TC_SEPARATORS,    m_xFormatHeader.get() },
            { TC_HEADER,        m_xRowHeader.get() },
            { TC_CHARSET,       m_xCharSetHeader.get() },
            { 0, nullptr }
            { TC_CHARSET,       m_xCharSetHeader.get() }
        };

        for ( size_t section=0; section < SAL_N_ELEMENTS( aSections ) - 1; ++section )
        for (auto const & section: aSections)
        {
            if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
            if ( ( m_nAvailableSections & section.nFlag ) != 0 )
            {
                // the section is visible, no need to do anything here
                continue;
            }

            // hide all elements from this section
            aSections[section].pFrame->hide();
            section.pFrame->hide();
        }

        m_xContainer->show();
diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx
index c6ca46f..3f8ddcf 100644
--- a/dbaccess/source/ui/dlg/dbadmin.cxx
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -401,7 +401,7 @@ void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Ref
        {0,false},
    };

    OSL_ENSURE(SAL_N_ELEMENTS(aItemInfos) == DSID_LAST_ITEM_ID,"Invalid Ids!");
    OSL_ENSURE(std::size(aItemInfos) == DSID_LAST_ITEM_ID,"Invalid Ids!");
    _rpPool = new SfxItemPool("DSAItemPool", DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID,
        aItemInfos, _rpDefaults);
    _rpPool->FreezeIdRanges();
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 02c01d9..2ab69af 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -2088,8 +2088,8 @@ sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const
{
    sal_Int32 nErg(0);
    // only the first 11 rows are interesting
    sal_Int32 const nSize = SAL_N_ELEMENTS(nVisibleRowMask);
    for(sal_Int32 i=0;i<nSize;i++)
    std::size_t const nSize = std::size(nVisibleRowMask);
    for(std::size_t i=0;i<nSize;i++)
    {
        if(!m_bVisibleRow[i])
            nErg |= nVisibleRowMask[i];
@@ -2100,8 +2100,8 @@ sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const
void OSelectionBrowseBox::SetNoneVisibleRow(sal_Int32 nRows)
{
    // only the first 11 rows are interesting
    sal_Int32 const nSize = SAL_N_ELEMENTS(nVisibleRowMask);
    for(sal_Int32 i=0;i< nSize;i++)
    std::size_t const nSize = std::size(nVisibleRowMask);
    for(std::size_t i=0;i< nSize;i++)
        m_bVisibleRow[i] = !(nRows & nVisibleRowMask[i]);
}