[Libreoffice-commits] core.git: svl/source

Eike Rathke erack at redhat.com
Mon Oct 2 10:08:28 UTC 2017


 svl/source/numbers/zforfind.cxx |   14 ++++++++++++++
 svl/source/numbers/zforfind.hxx |    3 +++
 2 files changed, 17 insertions(+)

New commits:
commit 00bb8e4a66008098d1133f4923f6d2d65e0dd598
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Oct 2 11:44:36 2017 +0200

    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

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


More information about the Libreoffice-commits mailing list