sw/inc/fldbas.hxx | 3 - sw/inc/strings.hrc | 2 sw/source/core/fields/fldbas.cxx | 4 - sw/source/uibase/fldui/fldmgr.cxx | 113 ++++++++++++++++---------------------- 4 files changed, 54 insertions(+), 68 deletions(-)
New commits: commit 15e975d4591f28bfa654af08e980a38b53a727bb Author: Noel Grandin <[email protected]> AuthorDate: Thu Oct 9 10:54:53 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Oct 9 13:27:16 2025 +0200 remove some remapping in SwFieldMgr::GetTypeStr this is unnecessary, because STR_DATEFLD and FLD_DATE_STD are the same resource string Change-Id: Ied8a75264538993d7759014deff5ffdc9619abcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192094 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 70a339639f9e..63bfd5e8363a 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -951,8 +951,6 @@ Description: strings for the types --------------------------------------------------------------------*/ // range document -#define STR_DATEFLD NC_("STR_DATEFLD", "Date") -#define STR_TIMEFLD NC_("STR_TIMEFLD", "Time") #define STR_FILENAMEFLD NC_("STR_FILENAMEFLD", "File name") #define STR_DBNAMEFLD NC_("STR_DBNAMEFLD", "Database Name") #define STR_CHAPTERFLD NC_("STR_CHAPTERFLD", "~Heading") diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 1f0a230814c6..0ad355618552 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -528,18 +528,6 @@ const OUString & SwFieldMgr::GetTypeStr(sal_uInt16 nPos) SwFieldTypesEnum nFieldWh = aSwFields[ nPos ].nTypeId; - // special treatment for date/time fields (without var/fix) - if( SwFieldTypesEnum::Date == nFieldWh ) - { - static OUString g_aDate( SwResId( STR_DATEFLD ) ); - return g_aDate; - } - if( SwFieldTypesEnum::Time == nFieldWh ) - { - static OUString g_aTime( SwResId( STR_TIMEFLD ) ); - return g_aTime; - } - return SwFieldType::GetTypeStr( nFieldWh ); } commit dde91c6f6ec9baa71aae79bb4d8fddb567ad777f Author: Noel Grandin <[email protected]> AuthorDate: Thu Oct 9 10:46:15 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Oct 9 13:27:07 2025 +0200 use o3tl::enumarray for s_pFieldNames Change-Id: I3a83d33c8aedc99040cb1715078e75d83b789085 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192092 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 425cf1bc2b94..f91ccf30f99f 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -29,6 +29,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <cppuhelper/weakref.hxx> #include <editeng/svxenum.hxx> +#include <o3tl/enumarray.hxx> #include <unotools/weakref.hxx> #include <rtl/ref.hxx> #include <vector> @@ -237,7 +238,7 @@ class SW_DLLPUBLIC SwFieldType : public sw::BroadcastingModify SwFieldIds m_nWhich; friend void FinitUI(); ///< In order to delete pointer! - static std::vector<OUString>* s_pFieldNames; + static o3tl::enumarray<SwFieldTypesEnum, OUString>* s_pFieldNames; static void GetFieldName_(); ///< Sets up FieldNames; fldmgr.cxx! diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index a24d9647e51b..60292ce717f6 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -72,7 +72,7 @@ static LanguageType lcl_GetLanguageOfFormat(LanguageType nLng, sal_uLong nFormat // Globals /// field names -std::vector<OUString>* SwFieldType::s_pFieldNames = nullptr; +o3tl::enumarray<SwFieldTypesEnum, OUString>* SwFieldType::s_pFieldNames = nullptr; namespace { @@ -128,7 +128,7 @@ const OUString & SwFieldType::GetTypeStr(SwFieldTypesEnum nTypeId) if (!s_pFieldNames) GetFieldName_(); - return (*SwFieldType::s_pFieldNames)[static_cast<int>(nTypeId)]; + return (*SwFieldType::s_pFieldNames)[nTypeId]; } // each field references a field type that is unique for each document diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index a3fd5092447e..1f0a230814c6 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1846,62 +1846,61 @@ LanguageType SwFieldMgr::GetCurrLanguage() const void SwFieldType::GetFieldName_() { - static const TranslateId coFieldNms[] = + static constexpr o3tl::enumarray<SwFieldTypesEnum, TranslateId> coFieldNms { - FLD_DATE_STD, - FLD_TIME_STD, - STR_FILENAMEFLD, - STR_DBNAMEFLD, - STR_CHAPTERFLD, - STR_PAGENUMBERFLD, - STR_DOCSTATFLD, - STR_AUTHORFLD, - STR_SETFLD, - STR_GETFLD, - STR_FORMELFLD, - STR_HIDDENTXTFLD, - STR_SETREFFLD, - STR_GETREFFLD, - STR_DDEFLD, - STR_MACROFLD, - STR_INPUTFLD, - STR_HIDDENPARAFLD, - STR_DOCINFOFLD, - STR_DBFLD, - STR_USERFLD, - STR_POSTITFLD, - STR_TEMPLNAMEFLD, - STR_SEQFLD, - STR_DBNEXTSETFLD, - STR_DBNUMSETFLD, - STR_DBSETNUMBERFLD, - STR_CONDTXTFLD, - STR_NEXTPAGEFLD, - STR_PREVPAGEFLD, - STR_EXTUSERFLD, - FLD_DATE_FIX, - FLD_TIME_FIX, - STR_SETINPUTFLD, - STR_USRINPUTFLD, - STR_SETREFPAGEFLD, - STR_GETREFPAGEFLD, - STR_INTERNETFLD, - STR_JUMPEDITFLD, - STR_SCRIPTFLD, - STR_AUTHORITY, - STR_COMBINED_CHARS, - STR_DROPDOWN, - STR_CUSTOM_FIELD, - STR_PARAGRAPH_SIGNATURE + FLD_DATE_STD, /*Date*/ + FLD_TIME_STD, /*Time*/ + STR_FILENAMEFLD, /*Filename*/ + STR_DBNAMEFLD, /*DatabaseName*/ + STR_CHAPTERFLD, /*Chapter*/ + STR_PAGENUMBERFLD, /*PageNumber*/ + STR_DOCSTATFLD, /*DocumentStatistics*/ + STR_AUTHORFLD, /*Author*/ + STR_SETFLD, /*Set*/ + STR_GETFLD, /*Get*/ + STR_FORMELFLD, /*Formel*/ + STR_HIDDENTXTFLD, /*HiddenText*/ + STR_SETREFFLD, /*SetRef*/ + STR_GETREFFLD, /*GetRef*/ + STR_DDEFLD, /*DDE*/ + STR_MACROFLD, /*Macro*/ + STR_INPUTFLD, /*Input*/ + STR_HIDDENPARAFLD, /*HiddenParagraph*/ + STR_DOCINFOFLD, /*DocumentInfo*/ + STR_DBFLD, /*Database*/ + STR_USERFLD, /*User*/ + STR_POSTITFLD, /*Postit*/ + STR_TEMPLNAMEFLD, /*TemplateName*/ + STR_SEQFLD, /*Sequence*/ + STR_DBNEXTSETFLD, /*DatabaseNextSet*/ + STR_DBNUMSETFLD, /*DatabaseNumberSet*/ + STR_DBSETNUMBERFLD, /*DatabaseSetNumber*/ + STR_CONDTXTFLD, /*ConditionalText*/ + STR_NEXTPAGEFLD, /*NextPage*/ + STR_PREVPAGEFLD, /*PreviousPage*/ + STR_EXTUSERFLD, /*ExtendedUser*/ + FLD_DATE_FIX, /*FixedDate*/ + FLD_TIME_FIX, /*FixedTime*/ + STR_SETINPUTFLD, /*SetInput*/ + STR_USRINPUTFLD, /*UserInput*/ + STR_SETREFPAGEFLD, /*SetRefPage*/ + STR_GETREFPAGEFLD, /*GetRefPage*/ + STR_INTERNETFLD, /*Internet*/ + STR_JUMPEDITFLD, /*JumpEdit*/ + STR_SCRIPTFLD, /*Script*/ + STR_AUTHORITY, /*Authority*/ + STR_COMBINED_CHARS, /*CombinedChars*/ + STR_DROPDOWN, /*Dropdown*/ + STR_CUSTOM_FIELD, /*Custom*/ + STR_PARAGRAPH_SIGNATURE /*ParagraphSignature*/ }; // insert infos for fields - SwFieldType::s_pFieldNames = new std::vector<OUString>; - SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms)); - for (const TranslateId & id : coFieldNms) + SwFieldType::s_pFieldNames = new o3tl::enumarray<SwFieldTypesEnum, OUString>; + for( SwFieldTypesEnum i : o3tl::enumrange<SwFieldTypesEnum>() ) { - const OUString aTmp(SwResId(id)); - SwFieldType::s_pFieldNames->push_back(MnemonicGenerator::EraseAllMnemonicChars( aTmp )); + const OUString aTmp(SwResId(coFieldNms[i])); + (*SwFieldType::s_pFieldNames)[i] = MnemonicGenerator::EraseAllMnemonicChars( aTmp ); } }
