svl/source/numbers/zformat.cxx | 16 +++++++++++----- svl/source/numbers/zforscan.cxx | 4 ---- xmloff/source/style/xmlnumfe.cxx | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-)
New commits: commit d32dab699f6584a13eb10fc1eb2801423ef52fb2 Author: Laurent Balland-Poirier <laurent.balland-poir...@laposte.net> Date: Wed Jul 6 00:10:38 2016 +0200 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 <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 1350525..f3321da 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 8025ae6..1e4ba47 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++; diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 3fd0d5c..70ac995 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -731,13 +731,14 @@ void SvXMLNumFmtExport::WriteFractionElement_Impl( { FinishTextElement_Impl(); sal_Int32 nMaxNumeratorDigits = aNumeratorString.getLength(); - sal_Int32 nMinNumeratorDigits = aNumeratorString.indexOf('?'); + // As '0' cannot (yet) be saved in extended ODF, replace them by '?' + sal_Int32 nMinNumeratorDigits = aNumeratorString.replaceAll("0","?").indexOf('?'); if ( nMinNumeratorDigits >= 0 ) nMinNumeratorDigits = nMaxNumeratorDigits - nMinNumeratorDigits; else nMinNumeratorDigits = 0; sal_Int32 nMaxDenominatorDigits = aDenominatorString.getLength(); - sal_Int32 nMinDenominatorDigits = aDenominatorString.indexOf('?'); + sal_Int32 nMinDenominatorDigits = aDenominatorString.replaceAll("0","?").indexOf('?'); if ( nMinDenominatorDigits >= 0 ) nMinDenominatorDigits = nMaxDenominatorDigits - nMinDenominatorDigits; else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits