summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-05-29 16:48:38 +0200
committerCaolán McNamara <caolanm@redhat.com>2016-06-02 10:43:35 +0000
commit1744120145648a891b58af8c85af7585f38696f6 (patch)
tree5dd09a9cc31ab7d7d2b14a33c9420c98dd5a15e3
parent08c8d094390c7ccedde7d9c04c503a62ed907ae2 (diff)
tdf#100122 Correctly treat fraction without integer part
If there is no integer part (with format such as ?/?): - sStr should be skiped - SFrac should be completed with the right number of ?, j==0 must also be treated in ImpNumberFill Change-Id: I57448eb3b0c68e10779d7fa565379e2604f7f63b Reviewed-on: https://gerrit.libreoffice.org/25612 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> (cherry picked from commit a3471916370c53c6627ba4010489f539c174bdf9) Reviewed-on: https://gerrit.libreoffice.org/25803 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--svl/source/numbers/zformat.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 38efb37be8c9..9f987f591035 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2694,16 +2694,14 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber,
else
{
bRes |= ImpNumberFill(sFrac, fNumber, k, j, nIx, NF_SYMBOLTYPE_FRACBLANK);
+ bCont = false; // there is no main number?
if (rInfo.nTypeArray[j] == NF_SYMBOLTYPE_FRACBLANK)
{
sFrac.insert(0, rInfo.sStrArray[j]);
if ( j )
{
j--;
- }
- else
- {
- bCont = false;
+ bCont = true; // Yes, there is a main number
}
}
}
@@ -4294,6 +4292,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
short eSymbolType ) // type of stop condition
{
bool bRes = false;
+ bool bStop = false;
const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
// no normal thousands separators if number divided by thousands
bool bDoThousands = (rInfo.nThousand == 0);
@@ -4301,7 +4300,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
k = sBuff.getLength(); // behind last digit
- while (j > 0 && (nType = rInfo.nTypeArray[j]) != eSymbolType ) // Backwards
+ while (!bStop && (nType = rInfo.nTypeArray[j]) != eSymbolType ) // Backwards
{
switch ( nType )
{
@@ -4376,7 +4375,10 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
sBuff.insert(k, rInfo.sStrArray[j]);
break;
} // of switch
- j--; // Next String
+ if ( j )
+ j--; // Next String
+ else
+ bStop = true;
} // of while
return bRes;
}