diff options
author | Eike Rathke <erack@redhat.com> | 2017-08-30 11:02:59 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-08-30 11:06:36 +0200 |
commit | 1cfe6a904d3349413173f5d412c280936f938a9e (patch) | |
tree | 2e1a541bfed5f51560dbdd967ac7f8f3732cdb4d /svl | |
parent | 6254fbf8a76a0d8edb290b03e0632ef6513a8d98 (diff) |
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
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 20 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.hxx | 5 |
2 files changed, 24 insertions, 1 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 4c4d70e64d39..61af0c9c3c6a 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -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; diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx index 6a4ebf7ee9f2..a6fc36a12cb2 100644 --- a/svl/source/numbers/zforfind.hxx +++ b/svl/source/numbers/zforfind.hxx @@ -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 |