summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-07-05 12:06:27 +0200
committerEike Rathke <erack@redhat.com>2021-07-05 13:57:51 +0200
commit89a3caee73c476133af804d9a0a650e72e711d95 (patch)
treed6800e4b8f6d832f412ee0e6071bbe9d8e8468ec /svl
parent580b5f6a3bf671f6590f40795d7cb9e46d52cf9f (diff)
Resolves: tdf#143165 Date input must match separator, D,M,Y not part of
Change-Id: Iae464fd0fc6c480b9a16ccb2f8eb635812c6eeff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118408 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx19
1 files changed, 17 insertions, 2 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 068fc73abdf4..4f5fd03ce6be 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1263,6 +1263,17 @@ static bool lcl_IsSignedYearSep( const OUString& rStr, const OUString& rPat, sal
}
+/** Length of separator usually is 1 but theoretically could be anything. */
+static sal_Int32 lcl_getPatternSeparatorLength( const OUString& rPat, sal_Int32 nPat )
+{
+ sal_Int32 nSep = nPat;
+ sal_Unicode c;
+ while (nSep < rPat.getLength() && (c = rPat[nSep]) != 'D' && c != 'M' && c != 'Y')
+ ++nSep;
+ return nSep - nPat;
+}
+
+
bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt )
{
if (nAcceptedDatePattern >= -1)
@@ -1383,8 +1394,11 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt )
bOk = !IsNum[nNext];
if (bOk)
{
+ const sal_Int32 nSepLen = lcl_getPatternSeparatorLength( rPat, nPat);
+ // Non-numeric input must match separator exactly to be
+ // accepted as such.
const sal_Int32 nLen = sStrArray[nNext].getLength();
- bOk = (rPat.indexOf( sStrArray[nNext], nPat) == nPat);
+ bOk = (nLen == nSepLen && rPat.indexOf( sStrArray[nNext], nPat) == nPat);
if (bOk)
{
nPat += nLen - 1;
@@ -1503,8 +1517,9 @@ bool ImpSvNumberInputScan::SkipDatePatternSeparator( sal_uInt16 nParticle, sal_I
default:
if (nNext == nParticle)
{
+ const sal_Int32 nSepLen = lcl_getPatternSeparatorLength( rPat, nPat);
const sal_Int32 nLen = sStrArray[nNext].getLength();
- bool bOk = (rPat.indexOf( sStrArray[nNext], nPat) == nPat);
+ bool bOk = (nLen == nSepLen && rPat.indexOf( sStrArray[nNext], nPat) == nPat);
if (!bOk)
{
bOk = lcl_IsSignedYearSep( sStrArray[nNext], rPat, nPat);