include/svl/zformat.hxx | 3 ++- svl/source/numbers/zformat.cxx | 20 +++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-)
New commits: commit 48435bfddf38de2b31df50e70438ef7946a0c3cb Author: Laurent Balland-Poirier <laurent.balland-poir...@laposte.net> Date: Mon May 2 10:41:26 2016 +0200 tdf#97835 No decimal separtor for empty decimal If decimal part is empty (with #) decimal separator should not be added. It was not removed if there was text after value. Change-Id: I891cad8b6bec0f27f4cef8aea80c5dad264f062d Reviewed-on: https://gerrit.libreoffice.org/24586 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx index 52a0deb..4117958 100644 --- a/include/svl/zformat.hxx +++ b/include/svl/zformat.hxx @@ -572,7 +572,8 @@ private: sal_Int32 k, sal_uInt16 j, sal_uInt16 nIx, - sal_Int32 nDigCnt ); + sal_Int32 nDigCnt, + bool bAddDecSep = true ); // Helper function to fill in the group (AKA thousand) separators // or to skip additional digits diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index eebee2a..f3d0e6c 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -3982,13 +3982,13 @@ bool SvNumberformat::ImpDecimalFill( OUStringBuffer& sStr, // number string bool bInteger) // is integer { bool bRes = false; + bool bFilled = false; // Was filled? const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); sal_Int32 k = sStr.getLength(); // After last figure // Decimal places: if (rInfo.nCntPost > 0) { bool bTrailing = true; // Trailing zeros? - bool bFilled = false; // Was filled? short nType; while (j > 0 && // Backwards (nType = rInfo.nTypeArray[j]) != NF_SYMBOLTYPE_DECSEP) @@ -4028,6 +4028,7 @@ bool SvNumberformat::ImpDecimalFill( OUStringBuffer& sStr, // number string if ( sStr[k] != '0' ) { bTrailing = false; + bFilled = true; } if (bTrailing) { @@ -4075,16 +4076,7 @@ bool SvNumberformat::ImpDecimalFill( OUStringBuffer& sStr, // number string } // of decimal places bRes |= ImpNumberFillWithThousands(sStr, rNumber, k, j, nIx, // Fill with . if needed - rInfo.nCntPre); - if ( rInfo.nCntPost > 0 ) - { - const OUString& rDecSep = GetFormatter().GetNumDecimalSep(); - sal_Int32 nLen = rDecSep.getLength(); - if ( sStr.getLength() > nLen && ( sStr.indexOf( rDecSep, sStr.getLength() - nLen) == sStr.getLength() - nLen) ) - { - sStr.truncate( sStr.getLength() - nLen ); // no decimals => strip DecSep - } - } + rInfo.nCntPre, bFilled ); return bRes; } @@ -4094,7 +4086,8 @@ bool SvNumberformat::ImpNumberFillWithThousands( OUStringBuffer& sBuff, // numb sal_Int32 k, // position within string sal_uInt16 j, // symbol index within format code sal_uInt16 nIx, // subformat index - sal_Int32 nDigCnt) // count of integer digits in format + sal_Int32 nDigCnt, // count of integer digits in format + bool bAddDecSep) // add decimal separator if necessary { bool bRes = false; sal_Int32 nLeadingStringChars = 0; // inserted StringChars before number @@ -4119,7 +4112,8 @@ bool SvNumberformat::ImpNumberFillWithThousands( OUStringBuffer& sBuff, // numb case NF_SYMBOLTYPE_STRING: case NF_SYMBOLTYPE_CURRENCY: case NF_SYMBOLTYPE_PERCENT: - sBuff.insert(k, rInfo.sStrArray[j]); + if ( rInfo.nTypeArray[j] != NF_SYMBOLTYPE_DECSEP || bAddDecSep ) + sBuff.insert(k, rInfo.sStrArray[j]); if ( k == 0 ) { nLeadingStringChars = nLeadingStringChars + rInfo.sStrArray[j].getLength(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits