diff options
author | Eike Rathke <erack@redhat.com> | 2021-05-10 16:51:21 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2021-05-10 18:52:22 +0200 |
commit | 3561978410579c5222889eb7dce68f917b550334 (patch) | |
tree | 317230a58f41454e5086dcb46178165679df6053 /svl | |
parent | 06ae35e5e26bf5054598e002cfc6639d844346ab (diff) |
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@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 273e23bcd9d1..068fc73abdf4 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 ) { |