Resolves: tdf#91758 more stringent check for ISO date like looking input

Already check at the end of input analysis whether it could be an ISO date to
not apply x-y-z onto MDY or DMY later. For an acceptable ISO input, apart from
M and D restrictions, Y-M-D year numbers must be greater than 12 in MDY order
or greater than 31 in DMY order, or have at least 3 digits (possibly leading 0).

Change-Id: I8d3eb7e2403421469050850e45d1db5c0be018f5
This commit is contained in:
Eike Rathke
2017-08-30 11:02:59 +02:00
parent 6254fbf8a7
commit 1cfe6a904d
2 changed files with 24 additions and 1 deletions

View File

@@ -1074,6 +1074,24 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
}
bool ImpSvNumberInputScan::IsAcceptableIso8601( const SvNumberformat* pFormat )
{
if (pFormat && (pFormat->GetType() & css::util::NumberFormat::DATE))
{
switch (pFormatter->GetEvalDateFormat())
{
case NF_EVALDATEFORMAT_INTL:
return CanForceToIso8601( GetDateOrder());
case NF_EVALDATEFORMAT_FORMAT:
return CanForceToIso8601( pFormat->GetDateOrder());
default:
return CanForceToIso8601( GetDateOrder()) || CanForceToIso8601( pFormat->GetDateOrder());
}
}
return CanForceToIso8601( GetDateOrder());
}
bool ImpSvNumberInputScan::MayBeMonthDate()
{
if (nMayBeMonthDate == 0)
@@ -3631,7 +3649,7 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString, // s
// not. The count of numbers in pattern must match the
// count of numbers in input.
res = (GetDatePatternNumbers() == nNumericsCnt)
|| MayBeIso8601() || nMatchedAllStrings;
|| IsAcceptableIso8601( pFormat) || nMatchedAllStrings;
}
}
break;

View File

@@ -412,6 +412,11 @@ private:
@see nMayBeMonthDate
*/
bool MayBeMonthDate();
/** Whether input is acceptable as ISO 8601 date format in the current
NfEvalDateFormat setting.
*/
bool IsAcceptableIso8601( const SvNumberformat* pFormat );
};
#endif // INCLUDED_SVL_SOURCE_NUMBERS_ZFORFIND_HXX