sc/source/core/data/dpobject.cxx | 8 ++--- sc/source/core/data/dptabres.cxx | 2 - sc/source/core/data/dputil.cxx | 2 - sc/source/core/data/funcdesc.cxx | 6 ++-- sc/source/filter/excel/xiescher.cxx | 2 - sc/source/filter/excel/xlchart.cxx | 10 +++---- sc/source/filter/oox/defnamesbuffer.cxx | 8 ++--- sd/source/ui/view/DocumentRenderer.cxx | 27 ++++++------------- sd/source/ui/view/viewoverlaymanager.cxx | 8 ++--- sw/source/filter/ww8/ww8par2.cxx | 6 ++-- sw/source/filter/ww8/ww8scan.cxx | 8 ++--- sw/source/ui/frmdlg/frmpage.cxx | 6 ++-- sw/source/uibase/config/usrpref.cxx | 6 ++-- sw/source/uibase/fldui/fldmgr.cxx | 8 ++--- sw/source/uibase/sidebar/PageStylesPanel.cxx | 4 +- sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 12 ++++---- 16 files changed, 57 insertions(+), 66 deletions(-)
New commits: commit f25e3598fa2e121ef9be9fa97030e33b3e47c24d Author: Swarnadeep Paul <[email protected]> AuthorDate: Wed Feb 4 19:00:34 2026 +0530 Commit: Ilmari Lauhakangas <[email protected]> CommitDate: Thu Feb 19 08:43:09 2026 +0100 tdf#147021 Reduce use of SAL_N_ELEMENTS() by using std::size() and range-based for loops Change-Id: I299508e2d4040605f2f9d218beeb2834b6c9e9e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198682 Reviewed-by: Ilmari Lauhakangas <[email protected]> Tested-by: Jenkins diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index c9f69fe1848e..4b23db8b5ba3 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1564,17 +1564,17 @@ bool parseFunction( std::u16string_view rList, sal_Int32 nStartPos, sal_Int32& r { aFuncStr = comphelper::string::strip(aFuncStr, ' '); - const sal_Int32 nFuncCount = SAL_N_ELEMENTS(aFunctions); - for ( sal_Int32 nFunc=0; nFunc<nFuncCount && !bFound; nFunc++ ) + for ( const auto& rElement : aFunctions ) { - if (aFuncStr.equalsIgnoreAsciiCaseAscii(aFunctions[nFunc].pName)) + if (aFuncStr.equalsIgnoreAsciiCaseAscii(rElement.pName)) { - rFunc = aFunctions[nFunc].eFunc; + rFunc = rElement.eFunc; bFound = true; while (nFuncEnd < nListLen && rList[nFuncEnd] == ' ') ++nFuncEnd; rEndPos = nFuncEnd; + break; } } } diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index b32d419919eb..4a0945d10c2d 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -844,7 +844,7 @@ OUString ScDPResultData::GetMeasureString(tools::Long nMeasure, bool bForce, ScS { // for user-specified subtotal function with all measures, // display only function name - assert(unsigned(eForceFunc) < SAL_N_ELEMENTS(aFuncStrIds)); + assert(unsigned(eForceFunc) < std::size(aFuncStrIds)); if ( eForceFunc != SUBTOTAL_FUNC_NONE ) return ScResId(aFuncStrIds[eForceFunc]); diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx index 30abc1760385..1b5f4118dc41 100644 --- a/sc/source/core/data/dputil.cxx +++ b/sc/source/core/data/dputil.cxx @@ -379,7 +379,7 @@ const TranslateId aFuncStrIds[] = { OUString ScDPUtil::getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc) { - assert(unsigned(eFunc) < SAL_N_ELEMENTS(aFuncStrIds)); + assert(unsigned(eFunc) < std::size(aFuncStrIds)); TranslateId pId = aFuncStrIds[eFunc]; if (!pId) return rName; diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index 556c6ba72c6f..e9e02c78f01c 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -378,7 +378,7 @@ bool ScFuncDesc::compareByName(const ScFuncDesc* a, const ScFuncDesc* b) return (ScGlobal::GetCaseCollator().compareString(*a->mxFuncName, *b->mxFuncName ) < 0); } -#define ENTRY(CODE) CODE, SAL_N_ELEMENTS(CODE) +#define ENTRY(CODE) CODE, std::size(CODE) ScFunctionList::ScFunctionList( bool bEnglishFunctionNames ) : mbEnglishFunctionNames( bEnglishFunctionNames ) @@ -818,7 +818,7 @@ ScFunctionList::ScFunctionList( bool bEnglishFunctionNames ) // otherwise the sub resources within the resource blocks and the // resource blocks themselves would had to be ordered according to // OpCodes, which is utopian... - ScFuncDescCore const * pDescsEnd = aDescs + SAL_N_ELEMENTS(aDescs); + ScFuncDescCore const * pDescsEnd = aDescs + std::size(aDescs); for (sal_uInt16 i = 0; i <= SC_OPCODE_LAST_OPCODE_ID; ++i) { const ScFuncDescCore *pEntry = std::lower_bound(aDescs, pDescsEnd, i, @@ -1236,7 +1236,7 @@ static void ScFuncRes(const ScFuncDescCore &rEntry, ScFuncDesc* pDesc, bool& rbS nVarArgsSet = 1; nArgs -= VAR_ARGS - nVarArgsSet; } - assert(nArgs <= SAL_N_ELEMENTS(rEntry.aOptionalArgs)); + assert(nArgs <= std::size(rEntry.aOptionalArgs)); if (nArgs) { pDesc->nVarArgsStart = nArgs - nVarArgsSet; diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 4e74b4f3a4d9..4e41746d233d 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -739,7 +739,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }, { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 } }; - const sal_uInt8* const pnPattern = sppnPatterns[std::min<size_t>(rFillData.mnPattern - 2, SAL_N_ELEMENTS(sppnPatterns) - 1)]; + const sal_uInt8* const pnPattern = sppnPatterns[std::min<size_t>(rFillData.mnPattern - 2, std::size(sppnPatterns) - 1)]; // create 2-colored 8x8 DIB SvMemoryStream aMemStrm; aMemStrm.WriteUInt32( 12 ).WriteInt16( 8 ).WriteInt16( 8 ).WriteUInt16( 1 ).WriteUInt16( 1 ); diff --git a/sc/source/filter/excel/xlchart.cxx b/sc/source/filter/excel/xlchart.cxx index 5c92859a672b..2f78c3c93566 100644 --- a/sc/source/filter/excel/xlchart.cxx +++ b/sc/source/filter/excel/xlchart.cxx @@ -359,7 +359,7 @@ sal_uInt16 XclChartHelper::GetSeriesLineAutoColorIdx( sal_uInt16 nFormatIdx ) 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 63 }; - return spnLineColors[ nFormatIdx % SAL_N_ELEMENTS( spnLineColors ) ]; + return spnLineColors[ nFormatIdx % std::size( spnLineColors ) ]; } sal_uInt16 XclChartHelper::GetSeriesFillAutoColorIdx( sal_uInt16 nFormatIdx ) @@ -374,13 +374,13 @@ sal_uInt16 XclChartHelper::GetSeriesFillAutoColorIdx( sal_uInt16 nFormatIdx ) 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; - return spnFillColors[ nFormatIdx % SAL_N_ELEMENTS( spnFillColors ) ]; + return spnFillColors[ nFormatIdx % std::size( spnFillColors ) ]; } sal_uInt8 XclChartHelper::GetSeriesFillAutoTransp( sal_uInt16 nFormatIdx ) { static const sal_uInt8 spnTrans[] = { 0x00, 0x40, 0x20, 0x60, 0x70 }; - return spnTrans[ (nFormatIdx / 56) % SAL_N_ELEMENTS( spnTrans ) ]; + return spnTrans[ (nFormatIdx / 56) % std::size( spnTrans ) ]; } sal_uInt16 XclChartHelper::GetAutoMarkerType( sal_uInt16 nFormatIdx ) @@ -389,14 +389,14 @@ sal_uInt16 XclChartHelper::GetAutoMarkerType( sal_uInt16 nFormatIdx ) EXC_CHMARKERFORMAT_DIAMOND, EXC_CHMARKERFORMAT_SQUARE, EXC_CHMARKERFORMAT_TRIANGLE, EXC_CHMARKERFORMAT_CROSS, EXC_CHMARKERFORMAT_STAR, EXC_CHMARKERFORMAT_CIRCLE, EXC_CHMARKERFORMAT_PLUS, EXC_CHMARKERFORMAT_DOWJ, EXC_CHMARKERFORMAT_STDDEV }; - return spnSymbols[ nFormatIdx % SAL_N_ELEMENTS( spnSymbols ) ]; + return spnSymbols[ nFormatIdx % std::size( spnSymbols ) ]; } bool XclChartHelper::HasMarkerFillColor( sal_uInt16 nMarkerType ) { static const bool spbFilled[] = { false, true, true, true, false, false, false, false, true, false }; - return (nMarkerType < SAL_N_ELEMENTS( spbFilled )) && spbFilled[ nMarkerType ]; + return (nMarkerType < std::size( spbFilled )) && spbFilled[ nMarkerType ]; } const OUString & XclChartHelper::GetErrorBarValuesRole( sal_uInt8 nBarType ) diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index 7b2ebe3edd93..5d4e113601d7 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -77,9 +77,9 @@ const char* const sppcBaseNames[] = OUString lclGetBaseName( sal_Unicode cBuiltinId ) { - OSL_ENSURE( cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ), "lclGetBaseName - unsupported built-in identifier" ); + OSL_ENSURE( cBuiltinId < std::size( sppcBaseNames ), "lclGetBaseName - unsupported built-in identifier" ); OUStringBuffer aBuffer; - if( cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ) ) + if( cBuiltinId < std::size( sppcBaseNames ) ) aBuffer.appendAscii( sppcBaseNames[ cBuiltinId ] ); else aBuffer.append( static_cast< sal_Int32 >( cBuiltinId ) ); @@ -96,7 +96,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( std::u16string_view aModelName ) { if( o3tl::matchIgnoreAsciiCase( aModelName, spcOoxPrefix ) ) { - for( sal_Unicode cBuiltinId = 0; cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ); ++cBuiltinId ) + for( sal_Unicode cBuiltinId = 0; cBuiltinId < std::size( sppcBaseNames ); ++cBuiltinId ) { OUString aBaseName = lclGetBaseName( cBuiltinId ); sal_Int32 nBaseNameLen = aBaseName.getLength(); @@ -110,7 +110,7 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( std::u16string_view aModelName ) /** returns the built-in name identifier from a built-in base name, e.g. 'Print_Area'. */ sal_Unicode lclGetBuiltinIdFromBaseName( std::u16string_view rModelName ) { - for( sal_Unicode cBuiltinId = 0; cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ); ++cBuiltinId ) + for( sal_Unicode cBuiltinId = 0; cBuiltinId < std::size( sppcBaseNames ); ++cBuiltinId ) if( o3tl::equalsIgnoreAsciiCase( rModelName, sppcBaseNames[ cBuiltinId ] ) ) return cBuiltinId; return BIFF_DEFNAME_UNKNOWN; diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index 075b4221ee9b..5a1504bce693 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -423,7 +423,7 @@ namespace { SdResId(STR_IMPRESS_PRINT_UI_CONTENT), aHelpIds, u"PageContentType"_ustr , - CreateChoice(STR_IMPRESS_PRINT_UI_CONTENT_CHOICES, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_CONTENT_CHOICES)), + CreateChoice(STR_IMPRESS_PRINT_UI_CONTENT_CHOICES, std::size(STR_IMPRESS_PRINT_UI_CONTENT_CHOICES)), 0) ); @@ -448,7 +448,7 @@ namespace { SdResId(STR_IMPRESS_PRINT_UI_ORDER), aHelpIds, u"SlidesPerPageOrder"_ustr , - CreateChoice(STR_IMPRESS_PRINT_UI_ORDER_CHOICES, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_ORDER_CHOICES)), + CreateChoice(STR_IMPRESS_PRINT_UI_ORDER_CHOICES, std::size(STR_IMPRESS_PRINT_UI_ORDER_CHOICES)), 0, Sequence< sal_Bool >(), aSlidesPerPageOpt ) @@ -515,7 +515,7 @@ namespace { u""_ustr, aHelpIds, u"Quality"_ustr , - CreateChoice(STR_IMPRESS_PRINT_UI_QUALITY_CHOICES, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_QUALITY_CHOICES)), + CreateChoice(STR_IMPRESS_PRINT_UI_QUALITY_CHOICES, std::size(STR_IMPRESS_PRINT_UI_QUALITY_CHOICES)), mbImpress ? officecfg::Office::Impress::Print::Other::Quality::get() : officecfg::Office::Draw::Print::Other::Quality::get() ) @@ -549,8 +549,8 @@ namespace { u""_ustr, aHelpIds, u"PageOptions"_ustr , - mbImpress ? CreateChoice(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES)) : - CreateChoice(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW)), + mbImpress ? CreateChoice(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES, std::size(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES)) : + CreateChoice(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW, std::size(STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW)), nDefaultChoice, Sequence< sal_Bool >(), aPageOptionsOpt @@ -644,16 +644,7 @@ namespace { nPrintRange = 1; } } -/* - OUString aPrintRangeName( "PrintContent" ); - aHelpIds.realloc( 1 ); - aHelpIds[0] = ".HelpID:vcl:PrintDialog:PageContentType:ListBox"; - AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt( "printpagesbox", OUString(), - aHelpIds, aPrintRangeName, - mbImpress ? CreateChoice( STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE ) ) : - CreateChoice( STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE, SAL_N_ELEMENTS(STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE ) ), - nPrintRange ) ); -*/ + OUString aPrintRangeName( u"PrintContent"_ustr ); aHelpIds = { u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0"_ustr, u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1"_ustr, @@ -662,8 +653,8 @@ namespace { AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(aWidgetIds, OUString(), aHelpIds, aPrintRangeName, - mbImpress ? CreateChoice(STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE)) : - CreateChoice(STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE, SAL_N_ELEMENTS(STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE)), + mbImpress ? CreateChoice(STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE, std::size(STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE)) : + CreateChoice(STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE, std::size(STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE)), nPrintRange ) ); // create an Edit dependent on "Pages" selected @@ -695,7 +686,7 @@ namespace { Sequence<OUString> GetSlidesPerPageSequence() { const Sequence<OUString> aChoice ( - CreateChoice(STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES))); + CreateChoice(STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES, std::size(STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES))); maSlidesPerPage.clear(); maSlidesPerPage.push_back(0); // first is using the default std::transform(std::next(aChoice.begin()), aChoice.end(), std::back_inserter(maSlidesPerPage), diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx index dcdf3cf65390..bca63979253a 100644 --- a/sd/source/ui/view/viewoverlaymanager.cxx +++ b/sd/source/ui/view/viewoverlaymanager.cxx @@ -88,22 +88,22 @@ constexpr OUString aBigPlaceHolders[] = static Bitmap& getButtonImage( int index, bool large ) { - static ::tools::DeleteOnDeinit< Bitmap > gSmallButtonImages[SAL_N_ELEMENTS(aSmallPlaceHolders)] = { + static ::tools::DeleteOnDeinit< Bitmap > gSmallButtonImages[std::size(aSmallPlaceHolders)] = { ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty }; - static ::tools::DeleteOnDeinit< Bitmap > gLargeButtonImages[SAL_N_ELEMENTS(aBigPlaceHolders)] = { + static ::tools::DeleteOnDeinit< Bitmap > gLargeButtonImages[std::size(aBigPlaceHolders)] = { ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty, ::tools::DeleteOnDeinitFlag::Empty }; - assert(SAL_N_ELEMENTS(aSmallPlaceHolders) == SAL_N_ELEMENTS(aBigPlaceHolders)); + assert(std::size(aSmallPlaceHolders) == std::size(aBigPlaceHolders)); if( !gSmallButtonImages[0].get() ) { - for (size_t i = 0; i < SAL_N_ELEMENTS(aSmallPlaceHolders); i++ ) + for (size_t i = 0; i < std::size(aSmallPlaceHolders); i++ ) { gSmallButtonImages[i].set(Bitmap(aSmallPlaceHolders[i])); gLargeButtonImages[i].set(Bitmap(aBigPlaceHolders[i])); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index cdbc7d28e2c6..251e9dcf13f5 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -695,7 +695,7 @@ void SwWW8ImplReader::SetAnld(SwNumRule* pNumR, WW8_ANLD const * pAD, sal_uInt8 m_bCurrentAND_fNumberAcross = 0 != pAD->fNumberAcross; WW8_ANLV const &rAV = pAD->eAnlv; SetBaseAnlv(aNF, rAV, nSwLevel); // set the base format - SetAnlvStrings(aNF, nSwLevel, rAV, pAD->rgchAnld, 0, SAL_N_ELEMENTS(pAD->rgchAnld), bOutLine); // set the rest + SetAnlvStrings(aNF, nSwLevel, rAV, pAD->rgchAnld, 0, std::size(pAD->rgchAnld), bOutLine); // set the rest } pNumR->Set(nSwLevel, aNF); } @@ -833,7 +833,7 @@ void SwWW8ImplReader::SetNumOlst(SwNumRule* pNumR, WW8_OLST* pO, sal_uInt8 nSwLe if (!m_bVer67) nTextOfs *= 2; - SetAnlvStrings(aNF, nSwLevel, rAV, pO->rgch, nTextOfs, SAL_N_ELEMENTS(pO->rgch), true); // and apply + SetAnlvStrings(aNF, nSwLevel, rAV, pO->rgch, nTextOfs, std::size(pO->rgch), true); // and apply pNumR->Set(nSwLevel, aNF); } @@ -2861,7 +2861,7 @@ WW8SelBoxInfo* WW8TabDesc::FindMergeGroup(short nX1, short nWidth, bool bExact) bool WW8TabDesc::IsValidCell(short nCol) const { - return (o3tl::make_unsigned(nCol) < SAL_N_ELEMENTS(m_pActBand->bExist)) && + return (o3tl::make_unsigned(nCol) < std::size(m_pActBand->bExist)) && m_pActBand->bExist[nCol] && o3tl::make_unsigned(m_nCurrentRow) < m_pTabLines->size(); } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 0c74d3ecc7aa..a305f51b6701 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -226,7 +226,7 @@ const wwSprmSearcher *wwSprmParser::GetWW2SprmSearcher() {164, { 4, L_FIX} }, // "sprmTSetShd", tap.rgshd complex 4 bytes }; - static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); + static wwSprmSearcher aSprmSrch(aSprms, std::size(aSprms)); return &aSprmSrch; }; @@ -412,11 +412,11 @@ const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher(const WW8Fib& rFib) if (rFib.m_wIdent >= 0xa697 && rFib.m_wIdent <= 0xa699) { //see Read_AmbiguousSPRM for this oddity - static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms), true); + static wwSprmSearcher aSprmSrch(aSprms, std::size(aSprms), true); return &aSprmSrch; } - static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); + static wwSprmSearcher aSprmSrch(aSprms, std::size(aSprms)); return &aSprmSrch; }; @@ -771,7 +771,7 @@ const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher() InfoRow<NS_sprm::PFContextualSpacing>(), }; - static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); + static wwSprmSearcher aSprmSrch(aSprms, std::size(aSprms)); return &aSprmSrch; }; diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 66390b5c66e4..062274046b91 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -545,7 +545,7 @@ static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(SvxSwFramePo return eStringId; } } - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex) + for(size_t nIndex = 0; nIndex < std::size(aVertIds); ++nIndex) { // --> OD 2009-08-31 #mongolianlayout# if ( !bVerticalL2R ) @@ -874,8 +874,8 @@ bool InTextBox(const SwFrameFormat& rFlyFormat) void SwFramePage::setOptimalRelWidth() { static const RelationMaps aMaps[] = { - { aRelationMap, SAL_N_ELEMENTS(aRelationMap) }, - { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) } + { aRelationMap, std::size(aRelationMap) }, + { aAsCharRelationMap, std::size(aAsCharRelationMap) } }; std::vector<SvxSwFramePosString::StringId> aRels; diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx index 8c0584857014..6cc4f8d77cca 100644 --- a/sw/source/uibase/config/usrpref.cxx +++ b/sw/source/uibase/config/usrpref.cxx @@ -140,7 +140,7 @@ Sequence<OUString> SwContentViewConfig::GetPropertyNames() const static_assert(std::strcmp("Zoom/ZoomType", aPropNames[g_ZoomType]) == 0); static_assert(std::strcmp("Zoom/ZoomValue", aPropNames[g_ZoomValue]) == 0); #endif - const int nCount = m_bWeb ? 12 : SAL_N_ELEMENTS(aPropNames); + const int nCount = m_bWeb ? 12 : std::size(aPropNames); Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -561,7 +561,7 @@ Sequence<OUString> SwCursorConfig::GetPropertyNames() "DirectCursor/Insert", // 1 "Option/ProtectedArea", // 2 }; - const int nCount = SAL_N_ELEMENTS(aPropNames); + const int nCount = std::size(aPropNames); Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -640,7 +640,7 @@ Sequence<OUString> SwFmtAidsAutoComplConfig::GetPropertyNames() static const char* const aPropNames[] = { "EncloseWithCharacters", // 0 }; - const int nCount = SAL_N_ELEMENTS(aPropNames); + const int nCount = std::size(aPropNames); Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for (int i = 0; i < nCount; i++) diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index c4601be97783..16088bb4e8ff 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -371,7 +371,7 @@ static SwWrtShell* lcl_GetShell() return nullptr; } -static sal_uInt16 GetPackCount() { return SAL_N_ELEMENTS(aSwFields); } +static sal_uInt16 GetPackCount() { return std::size(aSwFields); } // FieldManager controls inserting and updating of fields SwFieldMgr::SwFieldMgr(SwWrtShell* pSh ) : @@ -1138,17 +1138,17 @@ bool SwFieldMgr::InsertField( OUString sReferenceLanguage; // handle language-variant formats - if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY)) + if (nFormatId >= std::size(FMT_REF_ARY)) { LanguageType nLang = GetCurrLanguage(); if (nLang == LANGUAGE_HUNGARIAN) { - if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY) * 2) + if (nFormatId >= std::size(FMT_REF_ARY) * 2) sReferenceLanguage = "Hu"; else sReferenceLanguage = "hu"; } - nFormatId %= SAL_N_ELEMENTS(FMT_REF_ARY); + nFormatId %= std::size(FMT_REF_ARY); } pField.reset(new SwGetRefField(pTyp, SwMarkName(rData.m_sPar1), sReferenceLanguage, nSubType, nSeqNo, nFlags, static_cast<RefFieldFormat>(nFormatId))); diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx b/sw/source/uibase/sidebar/PageStylesPanel.cxx index d1f8744d2b07..06fa504f44d9 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.cxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx @@ -65,7 +65,7 @@ const SvxPageUsage aArr[] = static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) { - for ( size_t i = 0; i < SAL_N_ELEMENTS(aArr); ++i ) + for ( size_t i = 0; i < std::size(aArr); ++i ) if ( aArr[i] == nUsage ) return i; return 3; @@ -73,7 +73,7 @@ static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) static SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos ) { - if ( nPos >= SAL_N_ELEMENTS(aArr) ) + if ( nPos >= std::size(aArr) ) return SvxPageUsage::NONE; return aArr[nPos]; } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 614d1145dd06..e5467ce7fe6a 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -1803,7 +1803,7 @@ static void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r if (nIndexOfWidthProperty > -1 && nType == text::SizeType::FIX) rFrameProperties[nIndexOfWidthProperty].Value >>= nWidth; - for( size_t nProperty = 0; nProperty < SAL_N_ELEMENTS( aBorderProperties ); ++nProperty) + for( size_t nProperty = 0; nProperty < std::size( aBorderProperties ); ++nProperty) { const OUString sPropertyName = getPropertyName(aBorderProperties[nProperty]); beans::PropertyValue aValue; @@ -6965,7 +6965,7 @@ void DomainMapper_Impl::handleRubyEQField( const FieldContextPtr& pContext) NS_ooxml::LN_Value_ST_RubyAlign_right, NS_ooxml::LN_Value_ST_RubyAlign_rightVertical, }; - aInfo.nRubyAlign = aRubyAlignValues[(nJc<SAL_N_ELEMENTS(aRubyAlignValues))?nJc:0]; + aInfo.nRubyAlign = aRubyAlignValues[(nJc<std::size(aRubyAlignValues))?nJc:0]; } // we don't parse or use the font field in rCommand @@ -7114,11 +7114,11 @@ void DomainMapper_Impl::handleDocProperty size_t nMap = 0; if (!xPropertySetInfo->hasPropertyByName(rFirstParam)) { - for( ; nMap < SAL_N_ELEMENTS(aDocProperties); ++nMap ) + for( const auto& rElement : aDocProperties ) { - if (rFirstParam.equalsAscii(aDocProperties[nMap].pDocPropertyName)) + if (rFirstParam.equalsAscii(rElement.pDocPropertyName)) { - sFieldServiceName = OUString::createFromAscii(aDocProperties[nMap].pServiceName); + sFieldServiceName = OUString::createFromAscii(rElement.pServiceName); break; } } @@ -7263,7 +7263,7 @@ OUString DomainMapper_Impl::extractTocTitle() // the paragraph after this new section might have been already inserted OUString sResult = xCursor->getString(); if (sResult.endsWith(SAL_NEWLINE_STRING)) - sResult = sResult.copy(0, sResult.getLength() - SAL_N_ELEMENTS(SAL_NEWLINE_STRING) + 1); + sResult = sResult.copy(0, sResult.getLength() - std::size(SAL_NEWLINE_STRING) + 1); return sResult; }
