diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2016-07-11 09:20:21 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-07-12 09:33:25 +0000 |
commit | 0727e6e79994b66836841978a554b7f6855449dc (patch) | |
tree | 039f5b640f79f5fe2dc89075be29f4f3caa089cc /svl/source | |
parent | 8192da8e4de7a058ef95253f992f4143f83fa0f1 (diff) |
tdf#100842 Do not insert things in the middle of the number
With fraction number format, if number is longer than number of digits in format
jump to the beginning of number before inserting extras:
strings, blank, star filling
Do not do this for exponent of scientific format as it may contain
unwanted 0 at beginning.
Change-Id: Ide99f5cba198f76541f0e4e17b29469a99b57b9f
Reviewed-on: https://gerrit.libreoffice.org/27097
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/numbers/zformat.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index aea14d0e3a37..13505251ca4d 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -4144,6 +4144,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); // no normal thousands separators if number divided by thousands bool bDoThousands = (rInfo.nThousand == 0); + bool bFoundNumber = false; short nType; k = sBuff.getLength(); // behind last digit @@ -4155,12 +4156,18 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string case NF_SYMBOLTYPE_STAR: if( bStarFlag ) { + if ( bFoundNumber && eSymbolType != NF_SYMBOLTYPE_EXP ) + k = 0; // tdf#100842 jump to beginning of number before inserting something else bRes = lcl_insertStarFillChar( sBuff, k, rInfo.sStrArray[j]); } break; case NF_SYMBOLTYPE_BLANK: if (rInfo.sStrArray[j].getLength() >= 2) + { + if ( bFoundNumber && eSymbolType != NF_SYMBOLTYPE_EXP ) + k = 0; // tdf#100842 jump to beginning of number before inserting something else k = InsertBlanks(sBuff, k, rInfo.sStrArray[j][1] ); + } break; case NF_SYMBOLTYPE_THSEP: // Same as in ImpNumberFillWithThousands() above, do not insert @@ -4181,6 +4188,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string break; case NF_SYMBOLTYPE_DIGIT: { + bFoundNumber = true; const OUString& rStr = rInfo.sStrArray[j]; const sal_Unicode* p1 = rStr.getStr(); const sal_Unicode* p = p1 + rStr.getLength(); @@ -4211,6 +4219,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string case NF_KEY_GENERAL: // Standard in the String { OUStringBuffer sNum; + bFoundNumber = true; ImpGetOutputStandard(rNumber, sNum); sNum.stripStart('-'); sBuff.insert(k, sNum.makeStringAndClear()); @@ -4220,6 +4229,8 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string break; default: + if ( bFoundNumber && eSymbolType != NF_SYMBOLTYPE_EXP ) + k = 0; // tdf#100842 jump to beginning of number before inserting something else sBuff.insert(k, rInfo.sStrArray[j]); break; } // of switch |