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

Change-Id: If35c679839b39a01e474f7b0b0abee570e85bdd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130798
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
This commit is contained in:
Gautham Krishnan
2022-03-01 12:04:38 +05:30
committed by Hossein
parent 409371801a
commit 51fb84829a
4 changed files with 15 additions and 15 deletions

View File

@@ -101,7 +101,7 @@ ToolbarmodeDialog::ToolbarmodeDialog(weld::Window* pParent)
Link<weld::Toggleable&, void> aLink = LINK(this, ToolbarmodeDialog, SelectToolbarmode); Link<weld::Toggleable&, void> aLink = LINK(this, ToolbarmodeDialog, SelectToolbarmode);
const OUString sCurrentMode = GetCurrentMode(); const OUString sCurrentMode = GetCurrentMode();
for (tools::ULong i = 0; i < SAL_N_ELEMENTS(m_pRadioButtons); i++) for (tools::ULong i = 0; i < std::size(m_pRadioButtons); i++)
{ {
m_pRadioButtons[i]->connect_toggled(aLink); m_pRadioButtons[i]->connect_toggled(aLink);
if (sCurrentMode == std::get<1>(TOOLBARMODES_ARRAY[i])) if (sCurrentMode == std::get<1>(TOOLBARMODES_ARRAY[i]))
@@ -133,7 +133,7 @@ static bool file_exists(const OUString& fileName)
int ToolbarmodeDialog::GetActiveRadioButton() int ToolbarmodeDialog::GetActiveRadioButton()
{ {
for (tools::ULong i = 0; i < SAL_N_ELEMENTS(m_pRadioButtons); i++) for (tools::ULong i = 0; i < std::size(m_pRadioButtons); i++)
{ {
if (m_pRadioButtons[i]->get_active()) if (m_pRadioButtons[i]->get_active())
return i; return i;

View File

@@ -189,7 +189,7 @@ void OAddFieldWindow::Update()
m_xListBox->clear(); m_xListBox->clear();
m_aListBoxData.clear(); m_aListBoxData.clear();
const OString aIds[] = { "up", "down" }; const OString aIds[] = { "up", "down" };
for (size_t j = 0; j< SAL_N_ELEMENTS(aIds); ++j) for (size_t j = 0; j< std::size(aIds); ++j)
m_xActions->set_item_sensitive(aIds[j], false); m_xActions->set_item_sensitive(aIds[j], false);
OUString aTitle(RptResId(RID_STR_FIELDSELECTION)); OUString aTitle(RptResId(RID_STR_FIELDSELECTION));
@@ -233,7 +233,7 @@ void OAddFieldWindow::Update()
m_xDialog->set_title(aTitle); m_xDialog->set_title(aTitle);
if ( !m_aCommandName.isEmpty() ) if ( !m_aCommandName.isEmpty() )
{ {
for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i) for (size_t i = 0; i < std::size(aIds); ++i)
m_xActions->set_item_sensitive(aIds[i], true); m_xActions->set_item_sensitive(aIds[i], true);
} }
OnSelectHdl(*m_xListBox); OnSelectHdl(*m_xListBox);
@@ -331,7 +331,7 @@ IMPL_LINK(OAddFieldWindow, OnSortAction, const OString&, rCurItem, void)
if (rCurItem == "delete") if (rCurItem == "delete")
{ {
for (size_t j = 0; j< SAL_N_ELEMENTS(aIds); ++j) for (size_t j = 0; j< std::size(aIds); ++j)
m_xActions->set_item_active(aIds[j], false); m_xActions->set_item_active(aIds[j], false);
m_xListBox->make_unsorted(); m_xListBox->make_unsorted();
@@ -339,7 +339,7 @@ IMPL_LINK(OAddFieldWindow, OnSortAction, const OString&, rCurItem, void)
return; return;
} }
for (size_t j = 0; j< SAL_N_ELEMENTS(aIds); ++j) for (size_t j = 0; j< std::size(aIds); ++j)
m_xActions->set_item_active(aIds[j], rCurItem == aIds[j]); m_xActions->set_item_active(aIds[j], rCurItem == aIds[j]);
m_xListBox->make_sorted(); m_xListBox->make_sorted();

View File

@@ -288,13 +288,13 @@ Sequence< sal_Int8 > DummyTokenHandler::getUTF8Identifier( sal_Int32 nToken )
if ( ( nToken & 0xffff0000 ) != 0 ) //namespace if ( ( nToken & 0xffff0000 ) != 0 ) //namespace
{ {
sal_uInt32 nNamespaceToken = ( nToken >> 16 ) - 1; sal_uInt32 nNamespaceToken = ( nToken >> 16 ) - 1;
if ( nNamespaceToken < SAL_N_ELEMENTS(namespacePrefixes) ) if ( nNamespaceToken < std::size(namespacePrefixes) )
aUtf8Token = namespacePrefixes[ nNamespaceToken ]; aUtf8Token = namespacePrefixes[ nNamespaceToken ];
} }
else //element or attribute else //element or attribute
{ {
size_t nElementToken = nToken & 0xffff; size_t nElementToken = nToken & 0xffff;
if ( nElementToken < SAL_N_ELEMENTS(tokens) ) if ( nElementToken < std::size(tokens) )
aUtf8Token = tokens[ nElementToken ]; aUtf8Token = tokens[ nElementToken ];
} }
Sequence< sal_Int8 > aSeq( reinterpret_cast< const sal_Int8* >( Sequence< sal_Int8 > aSeq( reinterpret_cast< const sal_Int8* >(
@@ -311,7 +311,7 @@ sal_Int32 DummyTokenHandler::getTokenFromUTF8( const uno::Sequence< sal_Int8 >&
sal_Int32 DummyTokenHandler::getTokenDirect( const char* pToken, sal_Int32 nLength ) const sal_Int32 DummyTokenHandler::getTokenDirect( const char* pToken, sal_Int32 nLength ) const
{ {
std::string_view sToken( pToken, nLength ); std::string_view sToken( pToken, nLength );
for( size_t i = 0; i < SAL_N_ELEMENTS(tokens); i++ ) for( size_t i = 0; i < std::size(tokens); i++ )
{ {
if ( tokens[i] == sToken ) if ( tokens[i] == sToken )
return static_cast<sal_Int32>(i); return static_cast<sal_Int32>(i);
@@ -380,7 +380,7 @@ void XMLImportTest::parse()
"multiplens.xml", "multiplepfx.xml", "multiplens.xml", "multiplepfx.xml",
"nstoattributes.xml", "nestedns.xml", "testthreading.xml"}; "nstoattributes.xml", "nestedns.xml", "testthreading.xml"};
for (size_t i = 0; i < SAL_N_ELEMENTS( fileNames ); i++) for (size_t i = 0; i < std::size( fileNames ); i++)
{ {
InputSource source; InputSource source;
source.sSystemId = "internal"; source.sSystemId = "internal";
@@ -407,7 +407,7 @@ void XMLImportTest::testMissingNamespaceDeclaration()
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
xInit->initialize({ uno::Any(OUString("IgnoreMissingNSDecl")) }); xInit->initialize({ uno::Any(OUString("IgnoreMissingNSDecl")) });
for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS( fileNames ); i++) for (sal_uInt16 i = 0; i < std::size( fileNames ); i++)
{ {
try try
{ {

View File

@@ -55,7 +55,7 @@ void testDataBar_Impl(const ScDocument& rDoc)
ScConditionalFormatList* pList = rDoc.GetCondFormList(0); ScConditionalFormatList* pList = rDoc.GetCondFormList(0);
CPPUNIT_ASSERT(pList); CPPUNIT_ASSERT(pList);
for(size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) for(size_t i = 0; i < std::size(aData); ++i)
{ {
ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(),
pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange)); pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange));
@@ -92,7 +92,7 @@ void testColorScale2Entry_Impl(const ScDocument& rDoc)
const ScConditionalFormatList* pList = rDoc.GetCondFormList(0); const ScConditionalFormatList* pList = rDoc.GetCondFormList(0);
CPPUNIT_ASSERT(pList); CPPUNIT_ASSERT(pList);
for(size_t i = 0; i < SAL_N_ELEMENTS(aData2Entry); ++i) for(size_t i = 0; i < std::size(aData2Entry); ++i)
{ {
ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(),
pList->end(), FindCondFormatByEnclosingRange(aData2Entry[i].aRange)); pList->end(), FindCondFormatByEnclosingRange(aData2Entry[i].aRange));
@@ -131,7 +131,7 @@ void testColorScale3Entry_Impl(const ScDocument& rDoc)
ScConditionalFormatList* pList = rDoc.GetCondFormList(1); ScConditionalFormatList* pList = rDoc.GetCondFormList(1);
CPPUNIT_ASSERT(pList); CPPUNIT_ASSERT(pList);
for(size_t i = 0; i < SAL_N_ELEMENTS(aData3Entry); ++i) for(size_t i = 0; i < std::size(aData3Entry); ++i)
{ {
ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(),
pList->end(), FindCondFormatByEnclosingRange(aData3Entry[i].aRange)); pList->end(), FindCondFormatByEnclosingRange(aData3Entry[i].aRange));
@@ -244,7 +244,7 @@ void testFunctionsExcel2010_Impl( ScDocument& rDoc )
{ 80, true } { 80, true }
}; };
for (size_t i=0; i < SAL_N_ELEMENTS(aTests); ++i) for (size_t i=0; i < std::size(aTests); ++i)
{ {
if (aTests[i].bEvaluate) if (aTests[i].bEvaluate)
{ {