[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - include/svl svl/source
Laurent Balland-Poirier
laurent.balland-poirier at laposte.net
Wed May 25 15:42:19 UTC 2016
include/svl/zformat.hxx | 3 ++-
svl/source/numbers/zformat.cxx | 20 +++++++-------------
2 files changed, 9 insertions(+), 14 deletions(-)
New commits:
commit 700a6c6360c1c83433545d472511c48ac355a1d2
Author: Laurent Balland-Poirier <laurent.balland-poirier at 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 <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
(cherry picked from commit 48435bfddf38de2b31df50e70438ef7946a0c3cb)
Reviewed-on: https://gerrit.libreoffice.org/25451
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index c204702..3ae701ab 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -574,7 +574,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 9c5bbf9..3b6384e 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -3991,13 +3991,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)
@@ -4037,6 +4037,7 @@ bool SvNumberformat::ImpDecimalFill( OUStringBuffer& sStr, // number string
if ( sStr[k] != '0' )
{
bTrailing = false;
+ bFilled = true;
}
if (bTrailing)
{
@@ -4084,16 +4085,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;
}
@@ -4103,7 +4095,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
@@ -4128,7 +4121,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();
More information about the Libreoffice-commits
mailing list