[Libreoffice-commits] core.git: ure/source

2022-11-05 Thread jsala (via logerrit)
 ure/source/uretest/cppmain.cc |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 64469bb1a7383da6e7ff1150d693b3e08f54bc91
Author: jsala 
AuthorDate: Sat Jun 25 13:34:32 2022 +0200
Commit: Hossein 
CommitDate: Sun Nov 6 01:25:32 2022 +0100

tdf#145538 Use range based for loops

Change-Id: Ic27ef946b8b878770446bd975b836d7c6c29dd4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141668
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/ure/source/uretest/cppmain.cc b/ure/source/uretest/cppmain.cc
index fb957d9f221a..1acdad0a7811 100644
--- a/ure/source/uretest/cppmain.cc
+++ b/ure/source/uretest/cppmain.cc
@@ -17,7 +17,6 @@
  */
 
 #include "sal/config.h"
-#include "sal/macros.h"
 
 #include 
 #include 
@@ -120,8 +119,9 @@ private:
 "com.sun.star.script.InvocationAdapterFactory",
 "com.sun.star.uri.UriSchemeParser_vndDOTsunDOTstarDOTscript"
 };
-for (::std::size_t i = 0; i < SAL_N_ELEMENTS(services); ++i) {
-::rtl::OUString name(::rtl::OUString::createFromAscii(services[i]));
+for (auto const & service : services)
+{
+::rtl::OUString name(::rtl::OUString::createFromAscii(service));
 css::uno::Reference< css::uno::XInterface > instance;
 try {
 instance = 
context_->getServiceManager()->createInstanceWithContext(
@@ -165,10 +165,11 @@ private:
 static char const * const singletons[] = {
 "com.sun.star.reflection.theTypeDescriptionManager"
 };
-for (std::size_t i = 0; i != SAL_N_ELEMENTS(singletons); ++i) {
+for (auto const & singleton : singletons)
+{
 css::uno::Reference< css::uno::XInterface > instance(
 context_->getValueByName(
-"/singletons/" + 
rtl::OUString::createFromAscii(singletons[i])),
+"/singletons/" + rtl::OUString::createFromAscii(singleton)),
 css::uno::UNO_QUERY_THROW);
 }
 css::util::theMacroExpander::get(context_);


[Libreoffice-commits] core.git: unoidl/source unotest/source unotools/source unoxml/qa

2022-11-05 Thread jsala (via logerrit)
 unoidl/source/unoidl-write.cxx   |   12 ++--
 unotest/source/cpp/filters-test.cxx  |2 +-
 unotest/source/cpp/officeconnection.cxx  |3 +--
 unotools/source/config/compatibility.cxx |2 +-
 unotools/source/config/fontcfg.cxx   |5 ++---
 unotools/source/config/lingucfg.cxx  |   10 +++---
 unotools/source/config/searchopt.cxx |6 ++
 unotools/source/misc/fontcvt.cxx |   19 +--
 unoxml/qa/unit/domtest.cxx   |8 
 9 files changed, 25 insertions(+), 42 deletions(-)

New commits:
commit 04a58d7eae2b26559efd48ff7cdd23cec1c2187c
Author: jsala 
AuthorDate: Sat Jun 25 13:35:01 2022 +0200
Commit: Hossein 
CommitDate: Sun Nov 6 01:22:27 2022 +0100

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

Also change some range based for.

Change-Id: I32c5cbe0033c40cde3f1fc86ec8af90e558f2652
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141666
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx
index 84cad5bdda69..042b72c0471e 100644
--- a/unoidl/source/unoidl-write.cxx
+++ b/unoidl/source/unoidl-write.cxx
@@ -130,7 +130,7 @@ void write8(osl::File & file, sal_uInt64 value) {
 }
 unsigned char buf[1];
 buf[0] = value & 0xFF;
-write(file, buf, SAL_N_ELEMENTS(buf));
+write(file, buf, std::size(buf));
 }
 
 void write16(osl::File & file, sal_uInt64 value) {
@@ -142,7 +142,7 @@ void write16(osl::File & file, sal_uInt64 value) {
 unsigned char buf[2];
 buf[0] = value & 0xFF;
 buf[1] = (value >> 8) & 0xFF;
-write(file, buf, SAL_N_ELEMENTS(buf));
+write(file, buf, std::size(buf));
 }
 
 void write32(osl::File & file, sal_uInt64 value) {
@@ -156,7 +156,7 @@ void write32(osl::File & file, sal_uInt64 value) {
 buf[1] = (value >> 8) & 0xFF;
 buf[2] = (value >> 16) & 0xFF;
 buf[3] = (value >> 24) & 0xFF;
-write(file, buf, SAL_N_ELEMENTS(buf));
+write(file, buf, std::size(buf));
 }
 
 void write64(osl::File & file, sal_uInt64 value) {
@@ -169,7 +169,7 @@ void write64(osl::File & file, sal_uInt64 value) {
 buf[5] = (value >> 40) & 0xFF;
 buf[6] = (value >> 48) & 0xFF;
 buf[7] = (value >> 56) & 0xFF;
-write(file, buf, SAL_N_ELEMENTS(buf));
+write(file, buf, std::size(buf));
 }
 
 void writeIso60599Binary32(osl::File & file, float value) {
@@ -182,7 +182,7 @@ void writeIso60599Binary32(osl::File & file, float value) {
 std::swap(sa.buf[0], sa.buf[3]);
 std::swap(sa.buf[1], sa.buf[2]);
 #endif
-write(file, sa.buf, SAL_N_ELEMENTS(sa.buf));
+write(file, sa.buf, std::size(sa.buf));
 }
 
 void writeIso60599Binary64(osl::File & file, double value) {
@@ -197,7 +197,7 @@ void writeIso60599Binary64(osl::File & file, double value) {
 std::swap(sa.buf[2], sa.buf[5]);
 std::swap(sa.buf[3], sa.buf[4]);
 #endif
-write(file, sa.buf, SAL_N_ELEMENTS(sa.buf));
+write(file, sa.buf, std::size(sa.buf));
 }
 
 OString toAscii(OUString const & name) {
diff --git a/unotest/source/cpp/filters-test.cxx 
b/unotest/source/cpp/filters-test.cxx
index 7adbd9ca4d4d..1eaaa6219783 100644
--- a/unotest/source/cpp/filters-test.cxx
+++ b/unotest/source/cpp/filters-test.cxx
@@ -29,7 +29,7 @@ static void decode(const OUString& rIn, const OUString &rOut)
 //mcrypt --bare -a arcfour -o hex -k 435645 -s 3
 const sal_uInt8 aKey[3] = {'C', 'V', 'E'};
 
-rtlCipherError result = rtl_cipher_init(cipher, 
rtl_Cipher_DirectionDecode, aKey, SAL_N_ELEMENTS(aKey), nullptr, 0);
+rtlCipherError result = rtl_cipher_init(cipher, 
rtl_Cipher_DirectionDecode, aKey, std::size(aKey), nullptr, 0);
 
 CPPUNIT_ASSERT_EQUAL_MESSAGE("cipher init failed", rtl_Cipher_E_None, 
result);
 
diff --git a/unotest/source/cpp/officeconnection.cxx 
b/unotest/source/cpp/officeconnection.cxx
index 649d636d0fa6..850b19440d00 100644
--- a/unotest/source/cpp/officeconnection.cxx
+++ b/unotest/source/cpp/officeconnection.cxx
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -81,7 +80,7 @@ void OfficeConnection::setUp() {
 osl_executeProcess(
 toAbsoluteFileUrl(
 argSoffice.copy(RTL_CONSTASCII_LENGTH("path:"))).pData,
-args, SAL_N_ELEMENTS(args), 0, nullptr, nullptr, envs, envs == 
nullptr ? 0 : 1,
+args, std::size(args), 0, nullptr, nullptr, envs, envs == 
nullptr ? 0 : 1,
 &process_));
 } else if (argSoffice.match("connect:")) {
 desc = argSoffice.copy(RTL_CONSTASCII_LENGTH("connect:"));
diff --git a/unotools/source/config/compatibility.cxx 
b/unotools/source/config/compatibility.cxx
index a5ac6ea895b4..4f0e1d2ac20c 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -96,7 +96,7 @@ OUString SvtCompatibilityEntry::getName( const Index rIdx )
 };
 
 /* Size

[Libreoffice-commits] core.git: compilerplugins/clang

2022-10-12 Thread jsala (via logerrit)
 compilerplugins/clang/test/constvars.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b26793b907ce823e5cce38f6fe93b420ebe38579
Author: jsala 
AuthorDate: Wed Oct 12 16:17:22 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Oct 12 19:43:08 2022 +0200

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

Reverting this changes made by error.
See 
https://gerrit.libreoffice.org/c/core/+/136263/6/compilerplugins/clang/test/constvars.cxx#25

Change-Id: Ica49759682adf55a1f0cef2a842acab603c62dac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141259
Reviewed-by: Stephan Bergmann 
Tested-by: Jenkins

diff --git a/compilerplugins/clang/test/constvars.cxx 
b/compilerplugins/clang/test/constvars.cxx
index 80acdb67528d..88df50f8e199 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 std::size_t const nMediaArgsCount = std::size(aFormalArgs);
-std::size_t foo()
+static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
+sal_uInt16 foo()
 {
 (void)aFormalArgs;
 return nMediaArgsCount;


[Libreoffice-commits] core.git: desktop/qa desktop/source

2022-09-05 Thread jsala (via logerrit)
 desktop/qa/deployment_misc/test_dp_version.cxx|2 +-
 desktop/source/app/officeipcthread.cxx|   12 ++--
 desktop/source/deployment/manager/dp_extensionmanager.cxx |2 +-
 desktop/source/deployment/misc/dp_misc.cxx|2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 8dc57426c3bd3385c30b9007991af8496b315f9a
Author: jsala 
AuthorDate: Fri Jun 24 18:46:25 2022 +0200
Commit: Hossein 
CommitDate: Mon Sep 5 18:57:53 2022 +0200

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

Also change some integer by std::size_t

Change-Id: Ia51b27bb99b8adda576394f9331345cb11149d6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137274
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/desktop/qa/deployment_misc/test_dp_version.cxx 
b/desktop/qa/deployment_misc/test_dp_version.cxx
index e896686865be..1b8fb9086769 100644
--- a/desktop/qa/deployment_misc/test_dp_version.cxx
+++ b/desktop/qa/deployment_misc/test_dp_version.cxx
@@ -60,7 +60,7 @@ void Test::test() {
   OUString("9223372036854775807"),
   ::dp_misc::GREATER }
 };
-for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
+for (std::size_t i = 0; i < std::size(data); ++i) {
 CPPUNIT_ASSERT_EQUAL(
 data[i].order,
 ::dp_misc::compareVersions(data[i].version1, data[i].version2));
diff --git a/desktop/source/app/officeipcthread.cxx 
b/desktop/source/app/officeipcthread.cxx
index e559f7253e53..6e3e97b06d19 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -72,7 +72,7 @@ char const PROCESSING_DONE[] = "InternalIPC::ProcessingDone";
 OString readStringFromPipe(osl::StreamPipe const & pipe) {
 for (OStringBuffer str;;) {
 char buf[1024];
-sal_Int32 n = pipe.recv(buf, SAL_N_ELEMENTS(buf));
+sal_Int32 n = pipe.recv(buf, std::size(buf));
 if (n <= 0) {
 SAL_INFO("desktop.app", "read empty string");
 return "";
@@ -1154,10 +1154,10 @@ void PipeIpcThread::execute()
 
 // notify client we're ready to process its args:
 SAL_INFO("desktop.app", "writing <" << SEND_ARGUMENTS << ">");
-sal_Int32 n = aStreamPipe.write(
-SEND_ARGUMENTS, SAL_N_ELEMENTS(SEND_ARGUMENTS));
+std::size_t n = aStreamPipe.write(
+SEND_ARGUMENTS, std::size(SEND_ARGUMENTS));
 // incl. terminating NUL
-if (n != SAL_N_ELEMENTS(SEND_ARGUMENTS)) {
+if (n != std::size(SEND_ARGUMENTS)) {
 SAL_WARN("desktop.app", "short write: " << n);
 continue;
 }
@@ -1186,9 +1186,9 @@ void PipeIpcThread::execute()
 {
 // processing finished, inform the requesting end:
 SAL_INFO("desktop.app", "writing <" << PROCESSING_DONE << ">");
-n = aStreamPipe.write(PROCESSING_DONE, 
SAL_N_ELEMENTS(PROCESSING_DONE));
+n = aStreamPipe.write(PROCESSING_DONE, 
std::size(PROCESSING_DONE));
 // incl. terminating NUL
-if (n != SAL_N_ELEMENTS(PROCESSING_DONE))
+if (n != std::size(PROCESSING_DONE))
 {
 SAL_WARN("desktop.app", "short write: " << n);
 continue;
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx 
b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index fc7816f6a4c6..44bd4648eff0 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -296,7 +296,7 @@ std::vector >
 std::vector > extensionList;
 Reference lRepos[] = {
   getUserRepository(), getSharedRepository(), getBundledRepository() };
-for (int i(0); i != SAL_N_ELEMENTS(lRepos); ++i)
+for (std::size_t i(0); i != std::size(lRepos); ++i)
 {
 Reference xPackage;
 try
diff --git a/desktop/source/deployment/misc/dp_misc.cxx 
b/desktop/source/deployment/misc/dp_misc.cxx
index f4437711dab5..df94e958292b 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -416,7 +416,7 @@ OUString generateRandomPipeId()
 throw RuntimeException( "cannot create random pool!?", nullptr );
 sal_uInt8 bytes[ 32 ];
 if (rtl_random_getBytes(
-s_hPool, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
+s_hPool, bytes, std::size(bytes) ) != rtl_Random_E_None) {
 throw RuntimeException( "random pool error!?", nullptr );
 }
 OUStringBuffer buf;


[Libreoffice-commits] core.git: dbaccess/source

2022-09-05 Thread jsala (via logerrit)
 dbaccess/source/core/misc/DatabaseDataProvider.cxx|2 
 dbaccess/source/sdbtools/connection/tablename.cxx |   11 +---
 dbaccess/source/ui/app/templwin.cxx   |   11 +---
 dbaccess/source/ui/browser/unodatbr.cxx   |2 
 dbaccess/source/ui/control/FieldDescControl.cxx   |   41 +-
 dbaccess/source/ui/dlg/TextConnectionHelper.cxx   |   11 ++--
 dbaccess/source/ui/dlg/dbadmin.cxx|2 
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx |8 +--
 8 files changed, 41 insertions(+), 47 deletions(-)

New commits:
commit 35a7e40d372d3211061465346825cf543a095f6d
Author: jsala 
AuthorDate: Fri Jun 24 18:44:20 2022 +0200
Commit: Hossein 
CommitDate: Mon Sep 5 17:16:42 2022 +0200

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 

diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx 
b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
index 3a59cd9b821a..90b808712042 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 8698cef6d75b..2b275c0f31eb 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 e9940782d630..224d8be0aed9 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 
 #include 
 #include 
 #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 4cea7af77f36..ee300a8862ed 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 0b18c3907e7a..1416b43fc2ed 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/disab

[Libreoffice-commits] core.git: chart2/source compilerplugins/clang connectivity/source cui/source

2022-09-04 Thread jsala (via logerrit)
 chart2/source/controller/dialogs/res_BarGeometry.cxx |3 --
 compilerplugins/clang/test/constvars.cxx |4 +--
 compilerplugins/clang/test/stringliteralvar.cxx  |2 -
 connectivity/source/parse/sqlbison.y |   24 ---
 cui/source/dialogs/tipofthedaydlg.cxx|2 -
 cui/source/dialogs/toolbarmodedlg.cxx|6 ++--
 6 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit 9e7e95a57b7c16941d9fdc59f806c1f9e4263379
Author: jsala 
AuthorDate: Tue Jun 21 21:25:50 2022 +0200
Commit: Hossein 
CommitDate: Sun Sep 4 20:04:23 2022 +0200

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 

diff --git a/chart2/source/controller/dialogs/res_BarGeometry.cxx 
b/chart2/source/controller/dialogs/res_BarGeometry.cxx
index 97befbe1f8f5..81d933b208bc 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& 
rLink)
diff --git a/compilerplugins/clang/test/constvars.cxx 
b/compilerplugins/clang/test/constvars.cxx
index 88df50f8e199..80acdb67528d 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 f04e54756284..a73f1c51dbd9 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 dd500ce2548b..59d8b2532430 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -44,7 +44,6 @@
 #include 
 #include "connectivity/dbconversion.hxx"
 #include 
-#include 
 #include 
 
 #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)); }

[Libreoffice-commits] core.git: extensions/source

2022-06-20 Thread jsala (via logerrit)
 extensions/source/propctrlr/formmetadata.cxx |   69 +--
 extensions/source/propctrlr/formmetadata.hxx |2 
 2 files changed, 35 insertions(+), 36 deletions(-)

New commits:
commit 2c68c419c1fce6de1a81e1f13a84b7069125a204
Author: jsala 
AuthorDate: Sun Jun 19 16:46:44 2022 +0200
Commit: Hossein 
CommitDate: Mon Jun 20 12:25:56 2022 +0200

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

Also change some integer by std::size_t

Change-Id: I999b4dddba6ef1feb0a65aad24e97f507b577b59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136104
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/extensions/source/propctrlr/formmetadata.cxx 
b/extensions/source/propctrlr/formmetadata.cxx
index 13a7b32e706b..eff907f49b47 100644
--- a/extensions/source/propctrlr/formmetadata.cxx
+++ b/extensions/source/propctrlr/formmetadata.cxx
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace pcr
@@ -98,7 +97,7 @@ namespace pcr
 #define DEF_INFO_4( ident, uinameres, pos, helpid, flag1, flag2, flag3, flag4 
) \
 DEF_INFO( ident, uinameres, pos, helpid, PROP_FLAG_##flag1 | 
PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 )
 
-sal_uInt16  OPropertyInfoService::s_nCount = 0;
+std::size_t OPropertyInfoService::s_nCount = 0;
 OPropertyInfoImpl*  OPropertyInfoService::s_pPropertyInfos = nullptr;
 
 const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
@@ -359,7 +358,7 @@ namespace pcr
 };
 
 s_pPropertyInfos = aPropertyInfos;
-s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
+s_nCount = std::size(aPropertyInfos);
 
 // sort
 std::sort( s_pPropertyInfos, s_pPropertyInfos + s_nCount, 
PropertyInfoLessByName() );
@@ -416,126 +415,126 @@ namespace pcr
 return { "Get", "Post" };
 }
 const TranslateId* pStringItemsResId = nullptr;
-int nElements = 0;
+std::size_t nElements = 0;
 switch ( _nId )
 {
 case PROPERTY_ID_IMAGEPOSITION:
 pStringItemsResId = RID_RSC_ENUM_IMAGE_POSITION;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_IMAGE_POSITION);
+nElements = std::size(RID_RSC_ENUM_IMAGE_POSITION);
 break;
 case PROPERTY_ID_BORDER:
 pStringItemsResId = RID_RSC_ENUM_BORDER_TYPE;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_BORDER_TYPE);
+nElements = std::size(RID_RSC_ENUM_BORDER_TYPE);
 break;
 case PROPERTY_ID_ICONSIZE:
 pStringItemsResId = RID_RSC_ENUM_ICONSIZE_TYPE;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_ICONSIZE_TYPE);
+nElements = std::size(RID_RSC_ENUM_ICONSIZE_TYPE);
 break;
 case PROPERTY_ID_COMMANDTYPE:
 pStringItemsResId = RID_RSC_ENUM_COMMAND_TYPE;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_COMMAND_TYPE);
+nElements = std::size(RID_RSC_ENUM_COMMAND_TYPE);
 break;
 case PROPERTY_ID_LISTSOURCETYPE:
 pStringItemsResId = RID_RSC_ENUM_LISTSOURCE_TYPE;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_LISTSOURCE_TYPE);
+nElements = std::size(RID_RSC_ENUM_LISTSOURCE_TYPE);
 break;
 case PROPERTY_ID_ALIGN:
 pStringItemsResId = RID_RSC_ENUM_ALIGNMENT;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_ALIGNMENT);
+nElements = std::size(RID_RSC_ENUM_ALIGNMENT);
 break;
 case PROPERTY_ID_VERTICAL_ALIGN:
 pStringItemsResId = RID_RSC_ENUM_VERTICAL_ALIGN;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_VERTICAL_ALIGN);
+nElements = std::size(RID_RSC_ENUM_VERTICAL_ALIGN);
 break;
 case PROPERTY_ID_BUTTONTYPE:
 pStringItemsResId = RID_RSC_ENUM_BUTTONTYPE;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_BUTTONTYPE);
+nElements = std::size(RID_RSC_ENUM_BUTTONTYPE);
 break;
 case PROPERTY_ID_PUSHBUTTONTYPE:
 pStringItemsResId = RID_RSC_ENUM_PUSHBUTTONTYPE;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_PUSHBUTTONTYPE);
+nElements = std::size(RID_RSC_ENUM_PUSHBUTTONTYPE);
 break;
 case PROPERTY_ID_SUBMIT_ENCODING:
 pStringItemsResId = RID_RSC_ENUM_SUBMIT_ENCODING;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_SUBMIT_ENCODING);
+nElements = std::size(RID_RSC_ENUM_SUBMIT_ENCODING);
 break;
 case PROPERTY_ID_DATEFORMAT:
 pStringItemsResId = RID_RSC_ENUM_DATEFORMAT_LIST;
-nElements = SAL_N_ELEMENTS(RID_RSC_ENUM_DATEFORMAT_LIST);
+