summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-10-02 11:44:36 +0200
committerEike Rathke <erack@redhat.com>2017-10-02 12:07:30 +0200
commit00bb8e4a66008098d1133f4923f6d2d65e0dd598 (patch)
tree09be1fb8a52cc3f8cf34058bff508480cce004be /svl
parent6537fac1798e1f41bb8450caeb0c2354e81fd394 (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
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx14
-rw-r--r--svl/source/numbers/zforfind.hxx3
2 files changed, 17 insertions, 0 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 796f2fe1f5df..14a027efa64a 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -120,6 +120,7 @@ void ImpSvNumberInputScan::Reset()
nStringScanSign = 0;
nMatchedAllStrings = nMatchedVirgin;
nMayBeIso8601 = 0;
+ bIso8601Tsep = false;
nMayBeMonthDate = 0;
nAcceptedDatePattern = -2;
nDatePatternStart = 0;
@@ -805,6 +806,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 ))
{
@@ -2549,6 +2562,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 a6fc36a12cb2..8dff9a68c81e 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -137,6 +137,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