diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2016-07-06 00:10:38 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-07-15 19:34:45 +0000 |
commit | d32dab699f6584a13eb10fc1eb2801423ef52fb2 (patch) | |
tree | c47aa88941438b6a7b7450c7cb801740d19d6268 /svl/source/numbers | |
parent | 7e70b938618a49c4130502421d6909a2a3871579 (diff) |
tdf#100755 Allow '0' for denominator symbol
Fraction number format
Accept '0' in numerator and denominator format: 0 0/0
Represent integer 3 as: 3 0/1
Load and save format to Excel
As it cannot (yet) be saved in ODF, replace 0 by ? during save to ODF
Change-Id: I4721a751431d3f9b903b369d199146ddfb76b43d
Reviewed-on: https://gerrit.libreoffice.org/27062
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl/source/numbers')
-rw-r--r-- | svl/source/numbers/zformat.cxx | 16 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.cxx | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 13505251ca4d..f3321da6629b 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2499,11 +2499,15 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber, sStr.appendAscii( aBuf ); impTransliterate(sStr, NumFor[nIx].GetNatNum()); } - if (rInfo.nCntPre > 0 && nFrac == 0) + bool bHideFraction = (rInfo.nCntPre > 0 && nFrac == 0 + && (lcl_GetNumeratorString(rInfo, nAnz).indexOf('0') < 0) + && (lcl_GetDenominatorString(rInfo, nAnz).indexOf('0') < 0 + || lcl_GetDenominatorString(rInfo, nAnz).toInt32() > 0) ); + if ( bHideFraction ) { sDiv.truncate(); } - else + else // if there are some '0' in format, force display of fraction { sFrac = ImpIntToString( nIx, nFrac ); sDiv = ImpIntToString( nIx, nDiv ); @@ -2517,7 +2521,7 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber, bool bCont = true; if (rInfo.nTypeArray[j] == NF_SYMBOLTYPE_FRAC) { - if (rInfo.nCntPre > 0 && nFrac == 0) + if ( bHideFraction ) { sDiv.insert(0, ' '); } @@ -4306,8 +4310,10 @@ void SvNumberformat::GetNumForInfo( sal_uInt16 nNumFor, short& rScannedType, nAnzLeading++; } } - else if (nType == NF_SYMBOLTYPE_DECSEP || nType == NF_SYMBOLTYPE_EXP) - { + else if (nType == NF_SYMBOLTYPE_DECSEP + || nType == NF_SYMBOLTYPE_EXP + || nType == NF_SYMBOLTYPE_FRACBLANK) // Fraction: stop after integer part, + { // do not count '0' of fraction bStop = true; } i++; diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx index 8025ae6fd1e0..1e4ba4775101 100644 --- a/svl/source/numbers/zforscan.cxx +++ b/svl/source/numbers/zforscan.cxx @@ -1740,10 +1740,6 @@ sal_Int32 ImpSvNumberformatScan::FinalScan( OUString& rString ) { return nPos; // Error } - else if (bFrac && cHere == '0') - { - return nPos; // Denominator is 0 - } nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; nPos = nPos + rStr.getLength(); i++; |