summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-04-08 21:46:47 +0200
committerAndras Timar <andras.timar@collabora.com>2022-05-27 20:34:47 +0200
commita6e366c09caee046e54f160ebff836b77b2985de (patch)
tree1910a8ffb472638a246d280197d6ee8053fc150b /svl
parent4dd18b9dd4e73a2cc57b11e479024a3e9ce6244e (diff)
Resolves: tdf#148052 accept a ". Month " name for matching DMY format
... even if the locale doesn't define such DM order or LongDateDaySeparator. Change-Id: I4bef720dff3582de9b60313824a84b570c153e98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132741 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 7a16002ede5fd31ae8f3358136ad49de40465ac1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132703 Reviewed-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 29f7b81afcf2e21c88c38fbae31fb463b26040c1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132859 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 9d3c3baec899..ffe31e9be8b0 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -2605,6 +2605,29 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString, sal_uInt16 nS
SkipBlanks(rString, nPos);
bDate = SkipString( rDate, rString, nPos); // 10. 10- 10/
}
+ if (!bDate && nStringPos == 1 && mpFormat && (mpFormat->GetType() & SvNumFormatType::DATE))
+ {
+ // If a DMY format was given and a mid string starts with a literal
+ // ". " dot+space and could contain a following month name and ends
+ // with a space or LongDateMonthSeparator, like it's scanned in
+ // `14". AUG "18`, then it may be a date as well. Regardless whether
+ // defined such by the locale or not.
+ // This *could* check for presence of ". "MMM or ". "MMMM in the actual
+ // format code for further restriction to match only if present, but..
+
+ const sal_uInt32 nExactDateOrder = mpFormat->GetExactDateOrder();
+ // Exactly DMY.
+ if (((nExactDateOrder & 0xff) == 'Y') && (((nExactDateOrder >> 8) & 0xff) == 'M')
+ && (((nExactDateOrder >> 16) & 0xff) == 'D'))
+ {
+ const sal_Int32 nTmpPos = nPos;
+ if (SkipChar('.', rString, nPos) && SkipBlanks(rString, nPos) && nPos + 2 < rString.getLength()
+ && (rString.endsWith(" ") || rString.endsWith( pLoc->getLongDateMonthSep())))
+ bDate = true;
+ else
+ nPos = nTmpPos;
+ }
+ }
if (bDate || ((MayBeIso8601() || MayBeMonthDate()) && // 1999-12-31 31-Dec-1999
SkipChar( '-', rString, nPos)))
{