summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2023-05-25 02:44:21 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2023-05-30 15:37:47 +0200
commit4998370216bbea3bcaff7fac2d62cbb4ac978c5d (patch)
tree55fa6645e154244550ab26de3a5cffe370206d3f /sw/source
parent8c1892cd80a5095b38e88d558f653b27d93b074c (diff)
tdf#145538,tdf#147021: sw/source: range based loops
A bunch of range based loop changes in sw/source that also take out SAL_N_ELEMENTS usages Change-Id: I28b929d2ecbe40c1b257454f21b5d2ff51d617e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152251 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/unocore/unofield.cxx6
-rw-r--r--sw/source/ui/dbui/mmaddressblockpage.cxx8
-rw-r--r--sw/source/ui/fldui/flddinf.cxx4
-rw-r--r--sw/source/ui/fldui/fldref.cxx6
-rw-r--r--sw/source/ui/misc/outline.cxx4
-rw-r--r--sw/source/uibase/dbui/mmconfigitem.cxx4
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.cxx12
-rw-r--r--sw/source/uibase/utlui/initui.cxx4
-rw-r--r--sw/source/uibase/utlui/unotools.cxx17
9 files changed, 28 insertions, 37 deletions
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 36a4f5b27bc6..78b43b3158bd 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -183,9 +183,9 @@ const ServiceIdResId aServiceToRes[] =
static SwFieldIds lcl_ServiceIdToResId(SwServiceType nServiceId)
{
- for (size_t i=0; i<SAL_N_ELEMENTS(aServiceToRes); ++i)
- if (aServiceToRes[i].nServiceId == nServiceId)
- return aServiceToRes[i].nResId;
+ for (auto const& aEntry : aServiceToRes)
+ if (aEntry.nServiceId == nServiceId)
+ return aEntry.nResId;
#if OSL_DEBUG_LEVEL > 0
OSL_FAIL("service id not found");
#endif
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index ad4a7bfc4b83..48d4e3dce117 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -494,10 +494,10 @@ SwCustomizeAddressBlockDialog::SwCustomizeAddressBlockDialog(
m_xAddressElementsLB->append(OUString::number(USER_DATA_SALUTATION), SwResId(ST_SALUTATION));
m_xAddressElementsLB->append(OUString::number(USER_DATA_PUNCTUATION), SwResId(ST_PUNCTUATION));
m_xAddressElementsLB->append(OUString::number(USER_DATA_TEXT), SwResId(ST_TEXT));
- for (size_t i = 0; i < SAL_N_ELEMENTS(RA_SALUTATION); ++i)
- m_aSalutations.push_back(SwResId(RA_SALUTATION[i]));
- for (size_t i = 0; i < SAL_N_ELEMENTS(RA_PUNCTUATION); ++i)
- m_aPunctuations.push_back(SwResId(RA_PUNCTUATION[i]));
+ for (auto const& aID : RA_SALUTATION)
+ m_aSalutations.push_back(SwResId(aID));
+ for (auto const& aID : RA_PUNCTUATION)
+ m_aPunctuations.push_back(SwResId(aID));
m_xDragED->SetText(" ");
m_xDialog->set_title(SwResId(eType == GREETING_MALE ? ST_TITLE_MALE : ST_TITLE_FEMALE));
m_xAddressElementsFT->set_label(SwResId(ST_SALUTATIONELEMENTS));
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 3fa401211b1f..7cb69c1d0e49 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -46,8 +46,8 @@ using namespace com::sun::star;
void FillFieldSelect(weld::TreeView& rListBox)
{
- for (size_t i = 0; i < SAL_N_ELEMENTS(FLD_SELECT); ++i)
- rListBox.append_text(SwResId(FLD_SELECT[i]));
+ for (auto const& aID : FLD_SELECT)
+ rListBox.append_text(SwResId(aID));
}
SwFieldDokInfPage::SwFieldDokInfPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *const pCoreSet)
diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index bd6fef539478..54f9c9fc98dc 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -70,10 +70,10 @@ SwFieldRefPage::SwFieldRefPage(weld::Container* pPage, weld::DialogController* p
{
m_xSelectionLB->make_sorted();
// #i83479#
- for (size_t i = 0; i < SAL_N_ELEMENTS(FLD_REF_PAGE_TYPES); ++i)
+ for (auto const& aID : FLD_REF_PAGE_TYPES)
{
- m_xTypeLB->append_text(SwResId(FLD_REF_PAGE_TYPES[i]));
- m_xFormatLB->append_text(SwResId(FLD_REF_PAGE_TYPES[i]));
+ m_xTypeLB->append_text(SwResId(aID));
+ m_xFormatLB->append_text(SwResId(aID));
}
m_sBookmarkText = m_xTypeLB->get_text(0);
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 429cfb71915c..6500bfdd6eca 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -118,8 +118,8 @@ SwNumNamesDlg::SwNumNamesDlg(weld::Window *pParent)
, m_xFormBox(m_xBuilder->weld_tree_view("form"))
, m_xOKBtn(m_xBuilder->weld_button("ok"))
{
- for (size_t i = 0; i < SAL_N_ELEMENTS(OUTLINE_STYLE); ++i)
- m_xFormBox->append_text(SwResId(OUTLINE_STYLE[i]));
+ for (auto const& aID : OUTLINE_STYLE)
+ m_xFormBox->append_text(SwResId(aID));
m_xFormEdit->connect_changed(LINK(this, SwNumNamesDlg, ModifyHdl));
m_xFormBox->connect_changed(LINK(this, SwNumNamesDlg, SelectHdl));
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index 17623c0a6068..40c9aac78da1 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -212,9 +212,9 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
m_bIsGreetingLineInMail_LastUserSetting(false),
m_bIsGreetingLine_LastUserSetting(false)
{
- for (size_t i = 0; i < SAL_N_ELEMENTS(SA_ADDRESS_HEADER); ++i)
+ for (auto const& [aName, aID] : SA_ADDRESS_HEADER)
{
- m_AddressHeaderSA.emplace_back(SwResId(SA_ADDRESS_HEADER[i].first), SA_ADDRESS_HEADER[i].second);
+ m_AddressHeaderSA.emplace_back(SwResId(aName), aID);
}
const Sequence<OUString>& rNames = GetPropertyNames();
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx
index 189b43bfbe57..fdfa9ce6616d 100644
--- a/sw/source/uibase/sidebar/PageFormatPanel.cxx
+++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx
@@ -62,19 +62,19 @@ void PageFormatPanel::SetMarginFieldUnit()
if (IsInch(meFUnit))
{
OUString sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
- for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i)
+ for (auto const& [aName, nSize] : RID_PAGEFORMATPANEL_MARGINS_INCH)
{
- OUString sStr = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_INCH[i].second, 2, true, false) + sSuffix;
- mxMarginSelectBox->append_text(SwResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i].first).replaceFirst("%1", sStr));
+ OUString sStr = rLocaleData.getNum(nSize, 2, true, false) + sSuffix;
+ mxMarginSelectBox->append_text(SwResId(aName).replaceFirst("%1", sStr));
}
}
else
{
OUString sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::CM);
- for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i)
+ for (auto const& [aName, nSize] : RID_PAGEFORMATPANEL_MARGINS_CM)
{
- OUString sStr = rLocaleData.getNum(RID_PAGEFORMATPANEL_MARGINS_CM[i].second, 2, true, false) + " " + sSuffix;
- mxMarginSelectBox->append_text(SwResId(RID_PAGEFORMATPANEL_MARGINS_CM[i].first).replaceFirst("%1", sStr));
+ OUString sStr = rLocaleData.getNum(nSize, 2, true, false) + " " + sSuffix;
+ mxMarginSelectBox->append_text(SwResId(aName).replaceFirst("%1", sStr));
}
}
mxMarginSelectBox->set_active(nSelected);
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index 2444d652ea73..f24cded867f5 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -135,8 +135,8 @@ ShellResource::ShellResource()
sPageDescFollowName( SwResId(STR_PAGEDESC_FOLLOWNAME)),
sPageDescName( SwResId(STR_PAGEDESC_NAME))
{
- for (size_t i = 0; i < SAL_N_ELEMENTS(FLD_DOCINFO_ARY); ++i)
- aDocInfoLst.push_back(SwResId(FLD_DOCINFO_ARY[i]));
+ for (auto const& aID : FLD_DOCINFO_ARY)
+ aDocInfoLst.push_back(SwResId(aID));
}
OUString ShellResource::GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx
index b2d08f058567..7e72566685e2 100644
--- a/sw/source/uibase/utlui/unotools.cxx
+++ b/sw/source/uibase/utlui/unotools.cxx
@@ -87,15 +87,6 @@ static void disableScrollBars(uno::Reference< beans::XPropertySet > const & xVie
}
}
-const sal_Int16 nZoomValues[] =
-{
- 20,
- 40,
- 50,
- 75,
- 100
-};
-
SwOneExampleFrame::SwOneExampleFrame(sal_uInt32 nFlags,
const Link<SwOneExampleFrame&,void>* pInitializedLink,
const OUString* pURL)
@@ -479,13 +470,13 @@ bool SwOneExampleFrame::CreatePopup(const Point& rPt)
sal_Int16 nZoom = 0;
aZoom >>= nZoom;
- for (size_t i = 0; i < SAL_N_ELEMENTS(nZoomValues); ++i)
+ for (auto const nZoomPreset : { 20, 40, 50, 75, 100 })
{
- OUString sTemp = unicode::formatPercent(nZoomValues[i],
+ OUString sTemp = unicode::formatPercent(nZoomPreset,
Application::GetSettings().GetUILanguageTag());
- OUString sIdent = "zoom" + OUString::number(nZoomValues[i]);
+ OUString sIdent = "zoom" + OUString::number(nZoomPreset);
xPop->set_label(sIdent, sTemp);
- if (nZoom == nZoomValues[i])
+ if (nZoom == nZoomPreset)
xPop->set_active(sIdent, true);
}