diff options
author | Eike Rathke <erack@redhat.com> | 2017-10-02 11:44:36 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-10-02 14:53:41 +0200 |
commit | 5048eed81a497fc4e5b382ae8c1c2cd1c46bc0f8 (patch) | |
tree | ef35d82fea94f9397fe0c5cad5d36d482133fc2b /svl | |
parent | cdb9610b74d13a3b974c66e7201d782291a7f3b1 (diff) |
Number scanner: accept fractional separators in an ISO 8601 date+time string
In a strict ISO 8601 date+time string with 'T' separator the
Time100SecSep separating seconds and fractional seconds can be
either '.' period or ',' comma, so accept those in all locales.
Not accepting '.' in all locales was the cause of tdf#100822
before code was changed to use sax::Converter::parseDateTime()
instead.
Change-Id: Ica676050b52b11da64afbac6feabb43d9e985bc4
(cherry picked from commit 00bb8e4a66008098d1133f4923f6d2d65e0dd598)
Reviewed-on: https://gerrit.libreoffice.org/43038
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 14 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.hxx | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index a411d08ac06b..d161d6171ae8 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -128,6 +128,7 @@ void ImpSvNumberInputScan::Reset() nStringScanSign = 0; nMatchedAllStrings = nMatchedVirgin; nMayBeIso8601 = 0; + bIso8601Tsep = false; nMayBeMonthDate = 0; nAcceptedDatePattern = -2; nDatePatternStart = 0; @@ -814,6 +815,18 @@ inline bool ImpSvNumberInputScan::GetTime100SecSep( const OUString& rString, sal { if ( rString.getLength() > nPos ) { + if (bIso8601Tsep) + { + // ISO 8601 specifies both '.' dot and ',' comma as fractional + // separator. + if (rString[nPos] == '.' || rString[nPos] == ',') + { + ++nPos; + return true; + } + } + // Even in an otherwise ISO 8601 string be lenient and accept the + // locale defined separator. const OUString& rSep = pFormatter->GetLocaleData()->getTime100SecSep(); if ( rString.match( rSep, nPos )) { @@ -2558,6 +2571,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString, { // ISO 8601 combined date and time, yyyy-mm-ddThh:mm or -yyyy-mm-ddThh:mm ++nPos; + bIso8601Tsep = true; } else if (nStringPos == 7 && rString[0] == ':') { diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx index 819fef30d374..b0e21fb06452 100644 --- a/svl/source/numbers/zforfind.hxx +++ b/svl/source/numbers/zforfind.hxx @@ -136,6 +136,9 @@ private: */ sal_uInt8 nMayBeIso8601; + /** Whether the 'T' time separator was detected in an ISO 8601 string. */ + bool bIso8601Tsep; + /** State of dd-month-yy or yy-month-dd detection, with month name. 0:= don't know yet |