summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-05-29 16:48:38 +0200
committerEike Rathke <erack@redhat.com>2016-05-30 22:47:18 +0000
commita3471916370c53c6627ba4010489f539c174bdf9 (patch)
treee7940e61592dad8f3de7306363cade3550e4b467 /svl
parentb07e0a11766f2d2878a0dc2681feddb0c381c68d (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>
Diffstat (limited to 'svl')
-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 172f80219057..a80fc5360f24 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2718,16 +2718,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
}
}
}
@@ -4318,6 +4316,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);
@@ -4325,7 +4324,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 )
{
@@ -4400,7 +4399,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;
}