sw/source/ui/fldui/flddb.cxx | 4 ++-- sw/source/ui/fldui/flddb.hxx | 2 +- sw/source/ui/fldui/flddinf.cxx | 4 ++-- sw/source/ui/fldui/flddinf.hxx | 2 +- sw/source/ui/fldui/flddok.cxx | 4 ++-- sw/source/ui/fldui/flddok.hxx | 2 +- sw/source/ui/fldui/fldedt.cxx | 18 +++++++++--------- sw/source/ui/fldui/fldfunc.cxx | 4 ++-- sw/source/ui/fldui/fldfunc.hxx | 2 +- sw/source/ui/fldui/fldpage.hxx | 2 +- sw/source/ui/fldui/fldref.cxx | 4 ++-- sw/source/ui/fldui/fldref.hxx | 2 +- sw/source/ui/fldui/fldvar.cxx | 4 ++-- sw/source/ui/fldui/fldvar.hxx | 2 +- sw/source/uibase/fldui/fldmgr.cxx | 14 ++++++++------ sw/source/uibase/inc/fldedt.hxx | 3 ++- sw/source/uibase/inc/fldmgr.hxx | 21 +++++++++++---------- 17 files changed, 49 insertions(+), 45 deletions(-)
New commits: commit aeb3215a6e5f1caaabb764a0fc0303df31ead243 Author: Noel Grandin <[email protected]> AuthorDate: Tue Oct 7 14:58:15 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Oct 7 16:11:04 2025 +0200 convert SwFieldGroup to scoped enum Change-Id: I09e7fb7bb6f6430223f918cf6eb33c50d6219b60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192044 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index bd14ffc5ab2f..051af603dba3 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -265,9 +265,9 @@ std::unique_ptr<SfxTabPage> SwFieldDBPage::Create( weld::Container* pPage, weld: return std::make_unique<SwFieldDBPage>( pPage, pController, pAttrSet ); } -sal_uInt16 SwFieldDBPage::GetGroup() +SwFieldGroup SwFieldDBPage::GetGroup() { - return GRP_DB; + return SwFieldGroup::Database; } IMPL_LINK( SwFieldDBPage, TypeListBoxHdl, weld::TreeView&, rBox, void ) diff --git a/sw/source/ui/fldui/flddb.hxx b/sw/source/ui/fldui/flddb.hxx index eefa801dab5a..b109e56d642d 100644 --- a/sw/source/ui/fldui/flddb.hxx +++ b/sw/source/ui/fldui/flddb.hxx @@ -59,7 +59,7 @@ class SwFieldDBPage : public SwFieldPage SwWrtShell* CheckAndGetWrtShell(); protected: - virtual sal_uInt16 GetGroup() override; + virtual SwFieldGroup GetGroup() override; public: SwFieldDBPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet); diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 7c8e6ab84778..45186db15c87 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -502,9 +502,9 @@ std::unique_ptr<SfxTabPage> SwFieldDokInfPage::Create( weld::Container* pPage, w return std::make_unique<SwFieldDokInfPage>(pPage, pController, pAttrSet); } -sal_uInt16 SwFieldDokInfPage::GetGroup() +SwFieldGroup SwFieldDokInfPage::GetGroup() { - return GRP_REG; + return SwFieldGroup::DocInfos; } void SwFieldDokInfPage::FillUserData() diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx index 38b5c1f80569..ffe2871a126b 100644 --- a/sw/source/ui/fldui/flddinf.hxx +++ b/sw/source/ui/fldui/flddinf.hxx @@ -50,7 +50,7 @@ class SwFieldDokInfPage : public SwFieldPage sal_Int32 FillSelectionLB(SwDocInfoSubType nSubTypeId); protected: - virtual sal_uInt16 GetGroup() override; + virtual SwFieldGroup GetGroup() override; public: SwFieldDokInfPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pSet); diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index c970824d18b7..09f80ef53b81 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -645,9 +645,9 @@ std::unique_ptr<SfxTabPage> SwFieldDokPage::Create(weld::Container* pPage, weld: return std::make_unique<SwFieldDokPage>(pPage, pController, pAttrSet); } -sal_uInt16 SwFieldDokPage::GetGroup() +SwFieldGroup SwFieldDokPage::GetGroup() { - return GRP_DOC; + return SwFieldGroup::Document; } void SwFieldDokPage::FillUserData() diff --git a/sw/source/ui/fldui/flddok.hxx b/sw/source/ui/fldui/flddok.hxx index 3192ecc0c6c2..1a889aa45aef 100644 --- a/sw/source/ui/fldui/flddok.hxx +++ b/sw/source/ui/fldui/flddok.hxx @@ -52,7 +52,7 @@ class SwFieldDokPage : public SwFieldPage sal_Int32 FillFormatLB(SwFieldTypesEnum nTypeId); protected: - virtual sal_uInt16 GetGroup() override; + virtual SwFieldGroup GetGroup() override; public: SwFieldDokPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet * pSet); diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx index ebe3c28a77c4..7a72adff08ad 100644 --- a/sw/source/ui/fldui/fldedt.cxx +++ b/sw/source/ui/fldui/fldedt.cxx @@ -116,7 +116,7 @@ SwFieldEditDlg::SwFieldEditDlg(SwView const & rVw) EnsureSelection(pCurField, aMgr); - sal_uInt16 nGroup = SwFieldMgr::GetGroup(pCurField->GetTypeId(), pCurField->GetUntypedSubType()); + SwFieldGroup nGroup = SwFieldMgr::GetGroup(pCurField->GetTypeId(), pCurField->GetUntypedSubType()); CreatePage(nGroup); @@ -174,23 +174,23 @@ void SwFieldEditDlg::Init() !m_pSh->HasReadonlySel()); } -SfxTabPage* SwFieldEditDlg::CreatePage(sal_uInt16 nGroup) +SfxTabPage* SwFieldEditDlg::CreatePage(SwFieldGroup nGroup) { // create TabPage std::unique_ptr<SfxTabPage> xTabPage; switch (nGroup) { - case GRP_DOC: + case SwFieldGroup::Document: xTabPage = SwFieldDokPage::Create(get_content_area(), this, nullptr); break; - case GRP_FKT: + case SwFieldGroup::Functions: xTabPage = SwFieldFuncPage::Create(get_content_area(), this, nullptr); break; - case GRP_REF: + case SwFieldGroup::CrossRefs: xTabPage = SwFieldRefPage::Create(get_content_area(), this, nullptr); break; - case GRP_REG: + case SwFieldGroup::DocInfos: if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { auto pSet = new SfxItemSetFixed<FN_FIELD_DIALOG_DOC_PROPS, FN_FIELD_DIALOG_DOC_PROPS>( pDocSh->GetPool() ); @@ -207,12 +207,12 @@ SfxTabPage* SwFieldEditDlg::CreatePage(sal_uInt16 nGroup) } break; #if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS - case GRP_DB: + case SwFieldGroup::Database: xTabPage = SwFieldDBPage::Create(get_content_area(), this, nullptr); static_cast<SwFieldDBPage*>(xTabPage.get())->SetWrtShell(*m_pSh); break; #endif - case GRP_VAR: + case SwFieldGroup::UserVariable: xTabPage = SwFieldVarPage::Create(get_content_area(), this, nullptr); break; @@ -284,7 +284,7 @@ IMPL_LINK(SwFieldEditDlg, NextPrevHdl, weld::Button&, rButton, void) rMgr.GoNextPrev( bNext, pOldTyp ); pCurField = rMgr.GetCurField(); - sal_uInt16 nGroup = SwFieldMgr::GetGroup(pCurField->GetTypeId(), pCurField->GetUntypedSubType()); + SwFieldGroup nGroup = SwFieldMgr::GetGroup(pCurField->GetTypeId(), pCurField->GetUntypedSubType()); if (nGroup != pTabPage->GetGroup()) pTabPage = static_cast<SwFieldPage*>(CreatePage(nGroup)); diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index 8eec2103c17c..5d96e3a45129 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -583,9 +583,9 @@ std::unique_ptr<SfxTabPage> SwFieldFuncPage::Create( weld::Container* pPage, wel return std::make_unique<SwFieldFuncPage>(pPage, pController, pAttrSet); } -sal_uInt16 SwFieldFuncPage::GetGroup() +SwFieldGroup SwFieldFuncPage::GetGroup() { - return GRP_FKT; + return SwFieldGroup::Functions; } void SwFieldFuncPage::FillUserData() diff --git a/sw/source/ui/fldui/fldfunc.hxx b/sw/source/ui/fldui/fldfunc.hxx index 3f2ebef355e4..065418bdcbbe 100644 --- a/sw/source/ui/fldui/fldfunc.hxx +++ b/sw/source/ui/fldui/fldfunc.hxx @@ -73,7 +73,7 @@ class SwFieldFuncPage : public SwFieldPage void UpdateSubType(); protected: - virtual sal_uInt16 GetGroup() override; + virtual SwFieldGroup GetGroup() override; public: SwFieldFuncPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pSet); diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx index aad057822b6b..9faffea7058c 100644 --- a/sw/source/ui/fldui/fldpage.hxx +++ b/sw/source/ui/fldui/fldpage.hxx @@ -82,7 +82,7 @@ public: SwFieldMgr& GetFieldMgr() { return m_aMgr; } void SetWrtShell( SwWrtShell* m_pWrtShell ); void EditNewField( bool bOnlyActivate = false ); - virtual sal_uInt16 GetGroup() = 0; + virtual SwFieldGroup GetGroup() = 0; }; #endif diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 10aed0092fe9..2de9c8839e39 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -1211,9 +1211,9 @@ std::unique_ptr<SfxTabPage> SwFieldRefPage::Create( weld::Container* pPage, weld return std::make_unique<SwFieldRefPage>(pPage, pController, pAttrSet); } -sal_uInt16 SwFieldRefPage::GetGroup() +SwFieldGroup SwFieldRefPage::GetGroup() { - return GRP_REF; + return SwFieldGroup::CrossRefs; } void SwFieldRefPage::FillUserData() diff --git a/sw/source/ui/fldui/fldref.hxx b/sw/source/ui/fldui/fldref.hxx index 472d26a3c4a0..12bb169292dc 100644 --- a/sw/source/ui/fldui/fldref.hxx +++ b/sw/source/ui/fldui/fldref.hxx @@ -80,7 +80,7 @@ class SwFieldRefPage : public SwFieldPage void SaveSelectedTextNode(); protected: - virtual sal_uInt16 GetGroup() override; + virtual SwFieldGroup GetGroup() override; public: SwFieldRefPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pSet); diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index d48ddf197613..73853795bc3d 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -1273,9 +1273,9 @@ std::unique_ptr<SfxTabPage> SwFieldVarPage::Create( weld::Container* pPage, weld return std::make_unique<SwFieldVarPage>( pPage, pController, pAttrSet ); } -sal_uInt16 SwFieldVarPage::GetGroup() +SwFieldGroup SwFieldVarPage::GetGroup() { - return GRP_VAR; + return SwFieldGroup::UserVariable; } void SwFieldVarPage::FillUserData() diff --git a/sw/source/ui/fldui/fldvar.hxx b/sw/source/ui/fldui/fldvar.hxx index a478224bd804..5f9e61bae2f2 100644 --- a/sw/source/ui/fldui/fldvar.hxx +++ b/sw/source/ui/fldui/fldvar.hxx @@ -67,7 +67,7 @@ class SwFieldVarPage : public SwFieldPage void FillFormatLB(SwFieldTypesEnum nTypeId); protected: - virtual sal_uInt16 GetGroup() override; + virtual SwFieldGroup GetGroup() override; public: SwFieldVarPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pSet); diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 19dbd5b5c5c1..d5773e0a5a35 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -22,6 +22,7 @@ #include <cmdid.h> #include <hintids.hxx> +#include <o3tl/enumrange.hxx> #include <svl/numformat.hxx> #include <svl/stritem.hxx> #include <com/sun/star/text/DefaultNumberingProvider.hpp> @@ -458,7 +459,7 @@ SwField* SwFieldMgr::GetCurField() } // provide group range -const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId) +const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, SwFieldGroup nGrpId) { static SwFieldGroupRgn const aRanges[] = { @@ -480,13 +481,13 @@ const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, sal_uInt16 nGrp }; if (bHtmlMode) - return aWebRanges[nGrpId]; + return aWebRanges[static_cast<int>(nGrpId)]; else - return aRanges[nGrpId]; + return aRanges[static_cast<int>(nGrpId)]; } // determine GroupId -sal_uInt16 SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType) +SwFieldGroup SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType) { if (nTypeId == SwFieldTypesEnum::SetInput) nTypeId = SwFieldTypesEnum::Set; @@ -500,7 +501,7 @@ sal_uInt16 SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType) if (nTypeId == SwFieldTypesEnum::FixedTime) nTypeId = SwFieldTypesEnum::Time; - for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++) + for( auto i : o3tl::enumrange<SwFieldGroup>() ) { const SwFieldGroupRgn& rRange = GetGroupRange(false/*bHtmlMode*/, i); for (sal_uInt16 nPos = rRange.nStart; nPos < rRange.nEnd; nPos++) @@ -509,7 +510,8 @@ sal_uInt16 SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType) return i; } } - return USHRT_MAX; + assert(false); + return SwFieldGroup::Document; // random choice } // determine names to TypeId diff --git a/sw/source/uibase/inc/fldedt.hxx b/sw/source/uibase/inc/fldedt.hxx index 2c465aefad0a..30c79df149b5 100644 --- a/sw/source/uibase/inc/fldedt.hxx +++ b/sw/source/uibase/inc/fldedt.hxx @@ -26,6 +26,7 @@ class SwView; class SwWrtShell; class SwFieldMgr; +enum class SwFieldGroup; class SwFieldEditDlg final : public SfxSingleTabDialogController { @@ -38,7 +39,7 @@ class SwFieldEditDlg final : public SfxSingleTabDialogController DECL_LINK(NextPrevHdl, weld::Button&, void); void Init(); - SfxTabPage* CreatePage(sal_uInt16 nGroup); + SfxTabPage* CreatePage(SwFieldGroup nGroup); void EnsureSelection(SwField *pCurField, SwFieldMgr &rMgr); diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx index e9c863364fb7..eb19102da017 100644 --- a/sw/source/uibase/inc/fldmgr.hxx +++ b/sw/source/uibase/inc/fldmgr.hxx @@ -43,15 +43,16 @@ class SvNumberFormatter; namespace weld { class Widget; class Window; } enum class SwFieldIds : sal_uInt16; -// the groups of fields -enum SwFieldGroups +// the groups of fields, used to decide which tab/panel to display when editing a SwField +enum class SwFieldGroup { - GRP_DOC, - GRP_FKT, - GRP_REF, - GRP_REG, - GRP_DB, - GRP_VAR + Document, + Functions, + CrossRefs, + DocInfos, + Database, + UserVariable, + LAST = UserVariable }; struct SwFieldGroupRgn @@ -166,8 +167,8 @@ public: // access via TypeId from the dialog // Ids for a range of fields - static const SwFieldGroupRgn& GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId); - static sal_uInt16 GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType); + static const SwFieldGroupRgn& GetGroupRange(bool bHtmlMode, SwFieldGroup nGrpId); + static SwFieldGroup GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType); // the current field's TypeId SwFieldTypesEnum GetCurTypeId() const;
