summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-05-10 16:51:21 +0200
committerAndras Timar <andras.timar@collabora.com>2021-05-16 23:47:23 +0200
commit7e0665231813cc155f714ed1f39120ae7efea26e (patch)
treebac8c6890933b7295edfc4015711e7af1b310d51 /svl
parentfaa87bbfd05a3ff57b48b91999b350c66f621e02 (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 (cherry picked from commit 3561978410579c5222889eb7dce68f917b550334) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115277 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx28
1 files changed, 23 insertions, 5 deletions
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 )
{