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

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Wed May 12 15:24:15 UTC 2021


 svl/source/numbers/zforfind.cxx |   28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

New commits:
commit 88772bcf331152f24dde343ffe694c85fea8b6d3
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Mon May 10 16:51:21 2021 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed May 12 17:23:40 2021 +0200

    Resolves: tdf#142186 Accept 123.45 fractional input on weird formats like 0"."
    
    ... or 0"."0 where the literal "." is also the decimal separator
    but can only occur in the integer part.
    
    Change-Id: I95093fdddf7759346f2869ee322222de3d130e55
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115338
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 3561978410579c5222889eb7dce68f917b550334)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115277
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index eff5d48d9755..edf75a004244 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -3510,7 +3510,12 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString,        /
         }
         else if ( bDidMatch )
         {
-            return false;
+            // Accept a plain fractional number like 123.45 as there may be a
+            // decimal separator also present as literal like in a 0"."0 weirdo
+            // format.
+            if (nDecPos != 2 || nNumericsCnt != 2)
+                return false;
+            eScannedType = SvNumFormatType::NUMBER;
         }
         else
         {
@@ -3756,10 +3761,12 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString,         // s
             case SvNumFormatType::NUMBER:
                 if (nDecPos == 1)               // .05
                 {
-                    // matched MidStrings function like group separators
+                    // Matched MidStrings function like group separators, but
+                    // there can't be an integer part numeric input, so
+                    // effectively 0 thousands groups.
                     if ( nMatchedAllStrings )
                     {
-                        nThousand = nNumericsCnt - 1;
+                        nThousand = 0;
                     }
                     else if ( nNumericsCnt != 1 )
                     {
@@ -3768,10 +3775,21 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString,         // s
                 }
                 else if (nDecPos == 2)          // 1.05
                 {
-                    // matched MidStrings function like group separators
+                    // Matched MidStrings function like group separators, but
+                    // let a decimal separator override a literal separator
+                    // string; like 0"." with input 123.45
                     if ( nMatchedAllStrings )
                     {
-                        nThousand = nNumericsCnt - 1;
+                        if (nNumericsCnt == 2)
+                            nThousand = 0;
+                        else
+                        {
+                            // Assume that if there was a decimal separator
+                            // matching also a literal string then it was the
+                            // last. We could find the last possible match to
+                            // support literals in fractions, but really..
+                            nThousand = nNumericsCnt - 1;
+                        }
                     }
                     else if ( nNumericsCnt != nThousand+2 )
                     {


More information about the Libreoffice-commits mailing list