filter/qa/cppunit/msfilter-test.cxx | 2 +- filter/source/msfilter/rtfutil.cxx | 4 ++-- filter/source/msfilter/util.cxx | 4 ++-- filter/source/svg/svgfilter.cxx | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-)
New commits: commit 6817c668cd3a61e4129a414e35f4044c306d290e Author: RMZeroFour <ritobrot...@gmail.com> AuthorDate: Sun Mar 31 18:38:25 2024 +0530 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Apr 2 10:38:58 2024 +0200 tdf#147021 Replace SAL_N_ELEMENTS with std::size As part of the efforts in #145538 to replace the SAL_N_ELEMENTS() macro with std::size() and std::ssize(), this commit performs the necessary changes for a few files in the filter/ module. PS-2: Replace an std::size call with sizeof, and one with std::ssize Change-Id: Icac6470cdff762f828651153d0abc5f40b8e5d7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165592 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/filter/qa/cppunit/msfilter-test.cxx b/filter/qa/cppunit/msfilter-test.cxx index 439aad88b674..0969e272803b 100644 --- a/filter/qa/cppunit/msfilter-test.cxx +++ b/filter/qa/cppunit/msfilter-test.cxx @@ -52,7 +52,7 @@ void MSFilterTest::testTransColToIco() 15, 14, 13, 13, 12, 12, 9, 9, 9, 10, 10, 11, 11, 1, 14, 13, 13, 1, 12, 1, 9, 1, 10, 1, 11, 1 }; - for( size_t i = 0; i < SAL_N_ELEMENTS(aStdCol); ++i) + for( size_t i = 0; i < std::size(aStdCol); ++i) { const OString sMessage = "Index of unmatched color: " + OString::number(i); CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpected[i], diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx index a46bf99b730b..b5a06c929e7d 100644 --- a/filter/source/msfilter/rtfutil.cxx +++ b/filter/source/msfilter/rtfutil.cxx @@ -355,12 +355,12 @@ bool ExtractOLE2FromObjdata(const OString& rObjdata, SvStream& rOle2) sal_uInt64 nPos = aStream.Tell(); sal_uInt8 aSignature[8]; - aStream.ReadBytes(aSignature, SAL_N_ELEMENTS(aSignature)); + aStream.ReadBytes(aSignature, std::size(aSignature)); aStream.Seek(nPos); const sal_uInt8 aOle2Signature[8] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }; // Don't use Storage::IsStorageFile() here, that would seek to the start of the stream, // where the magic will always mismatch. - if (std::memcmp(aSignature, aOle2Signature, SAL_N_ELEMENTS(aSignature)) == 0) + if (std::memcmp(aSignature, aOle2Signature, sizeof(aSignature)) == 0) { // NativeData rOle2.WriteStream(aStream, nData); diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 4c9a065841b8..2ac3536af9b1 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -279,7 +279,7 @@ sal_Int32 PaperSizeConv::getMSPaperSizeIndex( const css::awt::Size& rSize ) sal_Int32 nPaperSizeIndex = 0; // Undefined const ApiPaperSize* pItem = spPaperSizeTable; - const ApiPaperSize* pEnd = spPaperSizeTable + SAL_N_ELEMENTS( spPaperSizeTable ); + const ApiPaperSize* pEnd = spPaperSizeTable + std::size( spPaperSizeTable ); for ( ; pItem != pEnd; ++pItem ) { sal_Int32 nCurDeltaHeight = std::abs( pItem->mnHeight - rSize.Height ); @@ -307,7 +307,7 @@ sal_Int32 PaperSizeConv::getMSPaperSizeIndex( const css::awt::Size& rSize ) const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSOPaperIndex ) { - if ( nMSOPaperIndex < 0 || nMSOPaperIndex > sal_Int32(SAL_N_ELEMENTS( spPaperSizeTable )) - 1 ) + if ( nMSOPaperIndex < 0 || nMSOPaperIndex > std::ssize( spPaperSizeTable ) - 1 ) return spPaperSizeTable[ 0 ]; return spPaperSizeTable[ nMSOPaperIndex ]; } diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index f33f65525a74..271d1b4397be 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -721,7 +721,7 @@ private: if(!mbIsSVG) { const sal_Int8 aMagic[] = {'<', 's', 'v', 'g'}; - const sal_Int32 nMagicSize(SAL_N_ELEMENTS(aMagic)); + const sal_Int32 nMagicSize(std::size(aMagic)); mbIsSVG = impCheckForMagic(aMagic, nMagicSize); } @@ -729,7 +729,7 @@ private: if(!mbIsSVG) { const sal_Int8 aMagic[] = {'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ', 's', 'v', 'g'}; - const sal_Int32 nMagicSize(SAL_N_ELEMENTS(aMagic)); + const sal_Int32 nMagicSize(std::size(aMagic)); mbIsSVG = impCheckForMagic(aMagic, nMagicSize); } @@ -773,7 +773,7 @@ public: { // xmlns:ooo const sal_Int8 aMagic[] = {'x', 'm', 'l', 'n', 's', ':', 'o', 'o', 'o'}; - const sal_Int32 nMagicSize(SAL_N_ELEMENTS(aMagic)); + const sal_Int32 nMagicSize(std::size(aMagic)); return impCheckForMagic(aMagic, nMagicSize); } @@ -789,7 +789,7 @@ public: { // ooo:meta_slides const sal_Int8 aMagic[] = {'o', 'o', 'o', ':', 'm', 'e', 't', 'a', '_', 's', 'l', 'i', 'd', 'e', 's'}; - const sal_Int32 nMagicSize(SAL_N_ELEMENTS(aMagic)); + const sal_Int32 nMagicSize(std::size(aMagic)); return impCheckForMagic(aMagic, nMagicSize); }