From 4998370216bbea3bcaff7fac2d62cbb4ac978c5d Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Thu, 25 May 2023 02:44:21 +0100 Subject: 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 Reviewed-by: Mike Kaganski --- sw/source/core/unocore/unofield.cxx | 6 +++--- sw/source/ui/dbui/mmaddressblockpage.cxx | 8 ++++---- sw/source/ui/fldui/flddinf.cxx | 4 ++-- sw/source/ui/fldui/fldref.cxx | 6 +++--- sw/source/ui/misc/outline.cxx | 4 ++-- sw/source/uibase/dbui/mmconfigitem.cxx | 4 ++-- sw/source/uibase/sidebar/PageFormatPanel.cxx | 12 ++++++------ sw/source/uibase/utlui/initui.cxx | 4 ++-- sw/source/uibase/utlui/unotools.cxx | 17 ++++------------- 9 files changed, 28 insertions(+), 37 deletions(-) (limited to 'sw/source') 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 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& 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* 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); } -- cgit