convert NfEvalDateFormat to scoped enum
Change-Id: Ief6211412cd73e59b7380d0f5ca536a38354e900 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187702 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -430,11 +430,11 @@ std::shared_ptr<SvNumberFormatter> 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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ std::unique_ptr<SvNumberFormatter> 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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -290,7 +290,7 @@ SvNFLanguageData::SvNFLanguageData(const Reference<XComponentContext>& rxContext
|
||||
, IniLnge(eLang)
|
||||
, ActLnge(eLang)
|
||||
, aLanguageTag(eLang)
|
||||
, eEvalDateFormat(NF_EVALDATEFORMAT_INTL)
|
||||
, eEvalDateFormat(NfEvalDateFormat::International)
|
||||
{
|
||||
xCharClass.changeLocale(xContext, aLanguageTag);
|
||||
xLocaleData.init(aLanguageTag);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user