[Libreoffice-commits] core.git: Branch 'libreoffice-7-1-5' - svl/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 6 09:04:14 UTC 2021


 svl/source/numbers/zforfind.cxx |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

New commits:
commit a8ef7e49afcc41d6069743ca5c81e7f2b18f4db2
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Mon Jul 5 12:06:27 2021 +0200
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Tue Jul 6 11:03:37 2021 +0200

    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 at redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 89a3caee73c476133af804d9a0a650e72e711d95)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118422
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    Tested-by: Michael Stahl <michael.stahl at allotropia.de>

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index edf75a004244..87c64df62c2a 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);


More information about the Libreoffice-commits mailing list