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 <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Swarnadeep Paul
2026-02-19 08:43:09 +01:00
committed by Ilmari Lauhakangas
parent 4d5a536685
commit f25e3598fa
16 changed files with 57 additions and 66 deletions
+4 -4
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -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]);
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -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;
+1 -1
View File
@@ -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 );
+5 -5
View File
@@ -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 )
+4 -4
View File
@@ -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;
+9 -18
View File
@@ -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),
+4 -4
View File
@@ -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]));
+3 -3
View File
@@ -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();
}
+4 -4
View File
@@ -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;
};
+3 -3
View File
@@ -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;
+3 -3
View File
@@ -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++)
+4 -4
View File
@@ -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)));
+2 -2
View File
@@ -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];
}
@@ -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;
}