[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - svl/source
Eike Rathke
erack at redhat.com
Mon Oct 2 12:54:05 UTC 2017
svl/source/numbers/zforfind.cxx | 14 ++++++++++++++
svl/source/numbers/zforfind.hxx | 3 +++
2 files changed, 17 insertions(+)
New commits:
commit 5048eed81a497fc4e5b382ae8c1c2cd1c46bc0f8
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
(cherry picked from commit 00bb8e4a66008098d1133f4923f6d2d65e0dd598)
Reviewed-on: https://gerrit.libreoffice.org/43038
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
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
More information about the Libreoffice-commits
mailing list