sw/source/ui/config/optload.cxx | 19 ------------------- sw/source/ui/config/optpage.cxx | 12 +++++------- sw/source/uibase/inc/optload.hxx | 8 -------- 3 files changed, 5 insertions(+), 34 deletions(-)
New commits: commit 16a85396273a9cb9f5b8f7acc375a22eafe93b8f Author: Simon Chenery <simon_chen...@yahoo.com> AuthorDate: Sat Jul 19 12:25:52 2025 +0200 Commit: David Gilbert <freedesk...@treblig.org> CommitDate: Sat Aug 9 15:17:00 2025 +0200 tdf#145538 Use range based for loop in optpage.cxx Removed helper class SwFieldUnitTable, that is no longer used. Change-Id: I376dcff611ad62e5957f1c04a9b4811e879a9f6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188062 Reviewed-by: David Gilbert <freedesk...@treblig.org> Tested-by: David Gilbert <freedesk...@treblig.org> diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx index 4098d1d07b8e..8ad861f5340f 100644 --- a/sw/source/ui/config/optload.cxx +++ b/sw/source/ui/config/optload.cxx @@ -486,25 +486,6 @@ static bool lcl_isPropertyReadOnly(const SwCapObjType eType, const CapConfigProp return bReadOnly; } -sal_uInt32 SwFieldUnitTable::Count() -{ - return std::size(STR_ARR_METRIC); -} - -OUString SwFieldUnitTable::GetString(sal_uInt32 nPos) -{ - if (RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count()) - return SwResId(STR_ARR_METRIC[nPos].first); - return OUString(); -} - -FieldUnit SwFieldUnitTable::GetValue(sal_uInt32 nPos) -{ - if (RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count()) - return STR_ARR_METRIC[nPos].second; - return FieldUnit::NONE; -} - SwLoadOptPage::SwLoadOptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, u"modules/swriter/ui/optgeneralpage.ui"_ustr, u"OptGeneralPage"_ustr, &rSet) , m_pWrtShell(nullptr) diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 59045ed18763..214a0852c70e 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -44,6 +44,7 @@ #include <viewopt.hxx> #include <globals.hrc> #include <strings.hrc> +#include <optload.hrc> #include <swwrtshitem.hxx> #include <editeng/fhgtitem.hxx> @@ -171,11 +172,8 @@ SwContentOptPage::SwContentOptPage(weld::Container* pPage, weld::DialogControlle m_xVRulerRightCBox->hide(); m_xVRulerCBox->connect_toggled(LINK(this, SwContentOptPage, VertRulerHdl )); - for (size_t i = 0; i < SwFieldUnitTable::Count(); ++i) + for (const auto& [pId, eFUnit] : STR_ARR_METRIC) { - const OUString sMetric = SwFieldUnitTable::GetString(i); - FieldUnit eFUnit = SwFieldUnitTable::GetValue(i); - switch ( eFUnit ) { case FieldUnit::MM: @@ -191,13 +189,13 @@ SwContentOptPage::SwContentOptPage(weld::Container* pPage, weld::DialogControlle // there isn't 'line' unit in HTML format if (eFUnit != FieldUnit::LINE) { - m_xMetricLB->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric); - m_xHMetric->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric); + m_xMetricLB->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), SwResId(pId)); + m_xHMetric->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), SwResId(pId)); } // a vertical ruler has not the 'character' unit if (eFUnit != FieldUnit::CHAR) { - m_xVMetric->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric); + m_xVMetric->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), SwResId(pId)); } break; } diff --git a/sw/source/uibase/inc/optload.hxx b/sw/source/uibase/inc/optload.hxx index 65de23238c33..ed5c8f17301d 100644 --- a/sw/source/uibase/inc/optload.hxx +++ b/sw/source/uibase/inc/optload.hxx @@ -35,14 +35,6 @@ class SwFieldMgr; class SwWrtShell; -class SwFieldUnitTable -{ -public: - static OUString GetString(sal_uInt32 i); - static sal_uInt32 Count(); - static FieldUnit GetValue(sal_uInt32 i); -}; - class TextFilterAutoConvert final : public TextFilter { private: