From 7f7b37c33ed956ba9d889ac2d8725a2f24e7fa1b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 11 Jul 2025 13:49:17 +0200 Subject: [PATCH] convert NfEvalDateFormat to scoped enum Change-Id: Ief6211412cd73e59b7380d0f5ca536a38354e900 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187702 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basic/source/runtime/runtime.cxx | 6 ++--- dbaccess/source/ui/misc/UITools.cxx | 2 +- include/svl/zforlist.hxx | 10 ++++----- sc/source/core/data/column3.cxx | 4 ++-- sc/source/core/data/global.cxx | 2 +- sc/source/core/data/poolhelp.cxx | 2 +- svl/source/numbers/supservs.cxx | 2 +- svl/source/numbers/zforfind.cxx | 34 ++++++++++++++--------------- svl/source/numbers/zforlist.cxx | 2 +- sw/source/core/doc/docfmt.cxx | 2 +- vcl/source/control/fmtfield.cxx | 2 +- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 92ebafec70da..669ba20d3544 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -430,11 +430,11 @@ std::shared_ptr SbiInstance::PrepareNumberFormatter( sal_uInt // Several parser methods pass SvNumberFormatter::IsNumberFormat() a number // format index to parse against. Tell the formatter the proper date // evaluation order, which also determines the date acceptance patterns to - // use if a format was passed. NF_EVALDATEFORMAT_FORMAT restricts to the + // use if a format was passed. NfEvalDateFormat::Format restricts to the // format's locale's date patterns/order (no init/system locale match - // tried) and falls back to NF_EVALDATEFORMAT_INTL if no specific (i.e. 0) + // tried) and falls back to NfEvalDateFormat::International if no specific (i.e. 0) // (or an unknown) format index was passed. - pNumberFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT); + pNumberFormatter->SetEvalDateFormat( NfEvalDateFormat::Format); sal_Int32 nCheckPos = 0; SvNumFormatType nType; diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 831116797646..e727cd9a3a5e 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -1047,7 +1047,7 @@ void setEvalDateFormatForFormatter(Reference< css::util::XNumberFormatter > cons if ( pSupplierImpl ) { SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); - pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT); + pFormatter->SetEvalDateFormat(NfEvalDateFormat::Format); } } diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index f9edfdf783ef..f94a4aa7c99d 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -261,22 +261,22 @@ enum NfIndexTableOffset DateFormat order (YMD,DMY,MDY) into account, if called from IsNumberFormat with a date format to match against. */ -enum NfEvalDateFormat +enum class NfEvalDateFormat { /** DateFormat only from International, default. */ - NF_EVALDATEFORMAT_INTL, + International, /** DateFormat only from date format passed to function (if any). If no date format is passed then the DateFormat is taken from International. */ - NF_EVALDATEFORMAT_FORMAT, + Format, /** First try the DateFormat from International. If it doesn't match a valid date try the DateFormat from the date format passed. */ - NF_EVALDATEFORMAT_INTL_FORMAT, + InternationalThenFormat, /** First try the DateFormat from the date format passed. If it doesn't match a valid date try the DateFormat from International. */ - NF_EVALDATEFORMAT_FORMAT_INTL + FormatThenInternational }; diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 05a97dd02930..b97f877f0abb 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2198,7 +2198,7 @@ bool ScColumn::ParseString( bool bForceFormatDate = (eNumFormatType == SvNumFormatType::DATE || eNumFormatType == SvNumFormatType::DATETIME); const SvNumberformat* pOldFormat = nullptr; - NfEvalDateFormat eEvalDateFormat = NF_EVALDATEFORMAT_INTL_FORMAT; + NfEvalDateFormat eEvalDateFormat = NfEvalDateFormat::InternationalThenFormat; if (bForceFormatDate) { ScRefCellValue aCell = GetCellValue(nRow); @@ -2216,7 +2216,7 @@ bool ScColumn::ParseString( nIndex = aParam.mpNumFormatter->GetEditFormat( aCell.getValue(), nOldIndex, eNumFormatType, pOldFormat); eEvalDateFormat = aParam.mpNumFormatter->GetEvalDateFormat(); - aParam.mpNumFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL); + aParam.mpNumFormatter->SetEvalDateFormat( NfEvalDateFormat::FormatThenInternational); } } else diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index bc00dff5b131..1ef9ba071c18 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -176,7 +176,7 @@ SvNumberFormatter* ScGlobal::GetEnglishFormatter() { xEnglishFormatter.reset( new SvNumberFormatter( ::comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US ) ); - xEnglishFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT ); + xEnglishFormatter->SetEvalDateFormat( NfEvalDateFormat::InternationalThenFormat ); } return xEnglishFormatter.get(); } diff --git a/sc/source/core/data/poolhelp.cxx b/sc/source/core/data/poolhelp.cxx index 6eb5e1232da0..f66cd4b0212c 100644 --- a/sc/source/core/data/poolhelp.cxx +++ b/sc/source/core/data/poolhelp.cxx @@ -92,7 +92,7 @@ std::unique_ptr ScPoolHelper::CreateNumberFormatter() const } assert(mxStylePool->GetDocument()); p->SetColorLink( LINK(mxStylePool->GetDocument(), ScDocument, GetUserDefinedColor)); - p->SetEvalDateFormat(NF_EVALDATEFORMAT_INTL_FORMAT); + p->SetEvalDateFormat(NfEvalDateFormat::InternationalThenFormat); sal_uInt16 d,m; sal_Int16 y; diff --git a/svl/source/numbers/supservs.cxx b/svl/source/numbers/supservs.cxx index b8f396ffb578..15593099472b 100644 --- a/svl/source/numbers/supservs.cxx +++ b/svl/source/numbers/supservs.cxx @@ -93,7 +93,7 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence< } m_pOwnFormatter.reset( new SvNumberFormatter( m_xORB, eNewFormatterLanguage) ); - m_pOwnFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL ); + m_pOwnFormatter->SetEvalDateFormat( NfEvalDateFormat::FormatThenInternational ); SetNumberFormatter(m_pOwnFormatter.get()); } diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index cb9c238f51f1..715146b821d9 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -1211,9 +1211,9 @@ bool ImpSvNumberInputScan::IsAcceptableIso8601() { switch (mrCurrentLanguageData.GetEvalDateFormat()) { - case NF_EVALDATEFORMAT_INTL: + case NfEvalDateFormat::International: return CanForceToIso8601( GetDateOrder()); - case NF_EVALDATEFORMAT_FORMAT: + case NfEvalDateFormat::Format: return CanForceToIso8601( mpFormat->GetDateOrder()); default: return CanForceToIso8601( GetDateOrder()) || CanForceToIso8601( mpFormat->GetDateOrder()); @@ -1319,7 +1319,7 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) { // The current locale is the format's locale, if a format is present. const NfEvalDateFormat eEDF = mrCurrentLanguageData.GetEvalDateFormat(); - if (!mpFormat || eEDF == NF_EVALDATEFORMAT_FORMAT || mpFormat->GetLanguage() == mrCurrentLanguageData.GetIniLanguage()) + if (!mpFormat || eEDF == NfEvalDateFormat::Format || mpFormat->GetLanguage() == mrCurrentLanguageData.GetIniLanguage()) { sDateAcceptancePatterns = mrCurrentLanguageData.GetLocaleData()->getDateAcceptancePatterns(); } @@ -1339,18 +1339,18 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) // take less time than looping over two additional patterns below... switch (eEDF) { - case NF_EVALDATEFORMAT_FORMAT: + case NfEvalDateFormat::Format: assert(!"shouldn't reach here"); break; - case NF_EVALDATEFORMAT_INTL: + case NfEvalDateFormat::International: sDateAcceptancePatterns = aLocalePatterns; break; - case NF_EVALDATEFORMAT_INTL_FORMAT: + case NfEvalDateFormat::InternationalThenFormat: sDateAcceptancePatterns = comphelper::concatSequences( aLocalePatterns, xLocaleData->getDateAcceptancePatterns()); break; - case NF_EVALDATEFORMAT_FORMAT_INTL: + case NfEvalDateFormat::FormatThenInternational: sDateAcceptancePatterns = comphelper::concatSequences( xLocaleData->getDateAcceptancePatterns(), aLocalePatterns); @@ -1787,22 +1787,22 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter ) eEDF = mrCurrentLanguageData.GetEvalDateFormat(); switch ( eEDF ) { - case NF_EVALDATEFORMAT_INTL : - case NF_EVALDATEFORMAT_FORMAT : + case NfEvalDateFormat::International : + case NfEvalDateFormat::Format : nFormatOrder = 1; // only one loop break; default: nFormatOrder = 2; if ( nMatchedAllStrings ) { - eEDF = NF_EVALDATEFORMAT_FORMAT_INTL; + eEDF = NfEvalDateFormat::FormatThenInternational; // we have a complete match, use it } } } else { - eEDF = NF_EVALDATEFORMAT_INTL; + eEDF = NfEvalDateFormat::International; nFormatOrder = 1; } bool res = true; @@ -1818,15 +1818,15 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter ) bool bFormatTurn; switch ( eEDF ) { - case NF_EVALDATEFORMAT_INTL : + case NfEvalDateFormat::International : bFormatTurn = false; DateFmt = GetDateOrder(); break; - case NF_EVALDATEFORMAT_FORMAT : + case NfEvalDateFormat::Format : bFormatTurn = true; DateFmt = mpFormat->GetDateOrder(); break; - case NF_EVALDATEFORMAT_INTL_FORMAT : + case NfEvalDateFormat::InternationalThenFormat : if ( nTryOrder == 1 ) { bFormatTurn = false; @@ -1838,7 +1838,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter ) DateFmt = mpFormat->GetDateOrder(); } break; - case NF_EVALDATEFORMAT_FORMAT_INTL : + case NfEvalDateFormat::FormatThenInternational : if ( nTryOrder == 2 ) { bFormatTurn = false; @@ -1875,7 +1875,7 @@ input for the following reasons: define the same YMD order and use the same date separator, there is no way to distinguish between them if the input results in valid calendar input for both calendars. How to solve? Would NfEvalDateFormat be sufficient? Should - it always be set to NF_EVALDATEFORMAT_FORMAT_INTL and thus the format's + it always be set to NfEvalDateFormat::FormatThenInternational and thus the format's calendar be preferred? This could be confusing if a Calc cell was formatted different to the locale's default and has no content yet, then the user has no clue about the format or calendar being set. @@ -2009,7 +2009,7 @@ input for the following reasons: if (!bIsExact && bFormatTurn && IsAcceptedDatePattern( nNums[0])) { // If input does not match format but pattern, use pattern - // instead, even if eEDF==NF_EVALDATEFORMAT_FORMAT_INTL. + // instead, even if eEDF==NfEvalDateFormat::FormatThenInternational. // For example, format has "Y-M-D" and pattern is "D.M.", // input with 2 numbers can't match format and 31.12. would // lead to 1931-12-01 (fdo#54344) diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 83f678e4aebe..ce8bfb8c9391 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -290,7 +290,7 @@ SvNFLanguageData::SvNFLanguageData(const Reference& rxContext , IniLnge(eLang) , ActLnge(eLang) , aLanguageTag(eLang) - , eEvalDateFormat(NF_EVALDATEFORMAT_INTL) + , eEvalDateFormat(NfEvalDateFormat::International) { xCharClass.changeLocale(xContext, aLanguageTag); xLocaleData.init(aLanguageTag); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 959c2bf901b9..5cf75cdf5613 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1772,7 +1772,7 @@ void SwDoc::EnsureNumberFormatter() { LanguageType eLang = LANGUAGE_SYSTEM; mpNumberFormatter = new SvNumberFormatter(comphelper::getProcessComponentContext(), eLang); - mpNumberFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL ); + mpNumberFormatter->SetEvalDateFormat( NfEvalDateFormat::FormatThenInternational ); if (!comphelper::IsFuzzing()) mpNumberFormatter->SetYear2000( officecfg::Office::Common::DateFormat::TwoDigitYear::get()); diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index 3cf9ad81ae35..36304743a4fb 100644 --- a/vcl/source/control/fmtfield.cxx +++ b/vcl/source/control/fmtfield.cxx @@ -656,7 +656,7 @@ void Formatter::FormatChanged(FORMAT_CHANGE_TYPE _nWhat) m_pLastOutputColor = nullptr; if ( (_nWhat == FORMAT_CHANGE_TYPE::FORMATTER) && m_pFormatter ) - m_pFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL ); + m_pFormatter->SetEvalDateFormat( NfEvalDateFormat::FormatThenInternational ); ReFormat(); }