tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro
Change associated for by std::find_if in sqlbison.y
Also change some integer by std::size_t
Change-Id: I0d2100fbd7c22729da6ce0462c6cc093e0767fb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136263
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
diff --git a/chart2/source/controller/dialogs/res_BarGeometry.cxx b/chart2/source/controller/dialogs/res_BarGeometry.cxx
index 97befbe..81d933b 100644
--- a/chart2/source/controller/dialogs/res_BarGeometry.cxx
+++ b/chart2/source/controller/dialogs/res_BarGeometry.cxx
@@ -29,8 +29,7 @@ BarGeometryResources::BarGeometryResources(weld::Builder* pBuilder)
{
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)));
m_xLB_Geometry->set_size_request(-1, m_xLB_Geometry->get_height_rows(std::size(CHART_TYPE)));
}
void BarGeometryResources::connect_changed(const Link<weld::TreeView&, void>& rLink)
diff --git a/compilerplugins/clang/test/constvars.cxx b/compilerplugins/clang/test/constvars.cxx
index 88df50f..80acdb6 100644
--- a/compilerplugins/clang/test/constvars.cxx
+++ b/compilerplugins/clang/test/constvars.cxx
@@ -22,8 +22,8 @@ namespace test1
{
int const aFormalArgs[] = { 1, 2 };
// expected-error@+1 {{var can be const [loplugin:constvars]}}
static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
sal_uInt16 foo()
static std::size_t const nMediaArgsCount = std::size(aFormalArgs);
std::size_t foo()
{
(void)aFormalArgs;
return nMediaArgsCount;
diff --git a/compilerplugins/clang/test/stringliteralvar.cxx b/compilerplugins/clang/test/stringliteralvar.cxx
index f04e547..a73f1c5 100644
--- a/compilerplugins/clang/test/stringliteralvar.cxx
+++ b/compilerplugins/clang/test/stringliteralvar.cxx
@@ -84,7 +84,7 @@ void f9()
// expected-error-re@+1 {{change type of variable 'literal' from constant character array ('const sal_Unicode{{ ?}}[3]'{{( \(aka 'const char16_t\[3\]'\))?}}) to OUStringLiteral [loplugin:stringliteralvar]}}
static sal_Unicode const literal[] = { 'f', 'o', 'o' };
// expected-note-re@+1 {{first passed into a '{{(rtl::)?}}OUString' constructor here [loplugin:stringliteralvar]}}
f(OUString(literal, SAL_N_ELEMENTS(literal)));
f(OUString(literal, std::size(literal)));
}
void f10()
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index dd500ce..59d8b25 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -44,7 +44,6 @@
#include <osl/diagnose.h>
#include "connectivity/dbconversion.hxx"
#include <rtl/ustrbuf.hxx>
#include <sal/macros.h>
#include <sal/log.hxx>
#if defined _MSC_VER
@@ -4382,7 +4381,7 @@ OString OParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const
IParseContext::InternationalKeyCode OParseContext::getIntlKeyCode(const OString& rToken) const
{
static IParseContext::InternationalKeyCode Intl_TokenID[] =
static IParseContext::InternationalKeyCode const Intl_TokenID[] =
{
InternationalKeyCode::Like, InternationalKeyCode::Not, InternationalKeyCode::Null, InternationalKeyCode::True,
InternationalKeyCode::False, InternationalKeyCode::Is, InternationalKeyCode::Between, InternationalKeyCode::Or,
@@ -4392,15 +4391,14 @@ IParseContext::InternationalKeyCode OParseContext::getIntlKeyCode(const OString&
InternationalKeyCode::VarPop,InternationalKeyCode::Collect,InternationalKeyCode::Fusion,InternationalKeyCode::Intersection
};
sal_uInt32 nCount = SAL_N_ELEMENTS( Intl_TokenID );
for (sal_uInt32 i = 0; i < nCount; i++)
{
OString aKey = getIntlKeywordAscii(Intl_TokenID[i]);
if (rToken.equalsIgnoreAsciiCase(aKey))
return Intl_TokenID[i];
}
auto const token = std::find_if(std::cbegin(Intl_TokenID), std::cend(Intl_TokenID)
, [&rToken, this](IParseContext::InternationalKeyCode const & tokenID)
{ return rToken.equalsIgnoreAsciiCase(getIntlKeywordAscii(tokenID)); });
return InternationalKeyCode::None;
if (std::cend(Intl_TokenID) != token)
return *token;
return InternationalKeyCode::None;
}
@@ -4671,7 +4669,7 @@ OString OSQLParser::TokenIDToStr(sal_uInt32 nTokenID, const IParseContext* pCont
#if OSL_DEBUG_LEVEL > 0
OUString OSQLParser::RuleIDToStr(sal_uInt32 nRuleID)
{
OSL_ENSURE(nRuleID < SAL_N_ELEMENTS(yytname), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
OSL_ENSURE(nRuleID < std::size(yytname), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
return OUString::createFromAscii(yytname[nRuleID]);
}
#endif
@@ -4681,8 +4679,8 @@ sal_uInt32 OSQLParser::StrToRuleID(const OString & rValue)
{
// Search for the given name in yytname and return the index
// (or UNKNOWN_RULE, if not found)
static sal_uInt32 nLen = SAL_N_ELEMENTS(yytname);
for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++)
static sal_uInt32 const nLen = std::size(yytname)-1;
for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < nLen; ++i)
{
if (rValue == yytname[i])
return i;
diff --git a/cui/source/dialogs/tipofthedaydlg.cxx b/cui/source/dialogs/tipofthedaydlg.cxx
index 8e60912..4fb8c81 100644
--- a/cui/source/dialogs/tipofthedaydlg.cxx
+++ b/cui/source/dialogs/tipofthedaydlg.cxx
@@ -122,7 +122,7 @@ static bool file_exists(const OUString& fileName)
void TipOfTheDayDialog::UpdateTip()
{
constexpr sal_Int32 nNumberOfTips = SAL_N_ELEMENTS(TIPOFTHEDAY_STRINGARRAY);
constexpr sal_Int32 nNumberOfTips = std::size(TIPOFTHEDAY_STRINGARRAY);
if ((m_nCurrentTip >= nNumberOfTips) || (m_nCurrentTip < 0))
m_nCurrentTip = 0;
diff --git a/cui/source/dialogs/toolbarmodedlg.cxx b/cui/source/dialogs/toolbarmodedlg.cxx
index f1dbdeb..54918e7 100644
--- a/cui/source/dialogs/toolbarmodedlg.cxx
+++ b/cui/source/dialogs/toolbarmodedlg.cxx
@@ -94,12 +94,12 @@ ToolbarmodeDialog::ToolbarmodeDialog(weld::Window* pParent)
(m_xBuilder->weld_radio_button("rbButton9")) }
, m_pInfoLabel(m_xBuilder->weld_label("lbInfo"))
{
static_assert(SAL_N_ELEMENTS(m_pRadioButtons) == SAL_N_ELEMENTS(TOOLBARMODES_ARRAY));
static_assert(SAL_N_ELEMENTS(m_pRadioButtons) == std::size(TOOLBARMODES_ARRAY));
Link<weld::Toggleable&, void> aLink = LINK(this, ToolbarmodeDialog, SelectToolbarmode);
const OUString sCurrentMode = GetCurrentMode();
for (tools::ULong i = 0; i < std::size(m_pRadioButtons); i++)
for (std::size_t i = 0; i < std::size(m_pRadioButtons); ++i)
{
m_pRadioButtons[i]->connect_toggled(aLink);
if (sCurrentMode == std::get<1>(TOOLBARMODES_ARRAY[i]))
@@ -131,7 +131,7 @@ static bool file_exists(const OUString& fileName)
int ToolbarmodeDialog::GetActiveRadioButton()
{
for (tools::ULong i = 0; i < std::size(m_pRadioButtons); i++)
for (std::size_t i = 0; i < std::size(m_pRadioButtons); ++i)
{
if (m_pRadioButtons[i]->get_active())
return i;