summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-06-24 23:28:39 +0200
committerEike Rathke <erack@redhat.com>2016-06-29 14:38:09 +0000
commit6951f28bbac44b29741089e88f842f124baf317f (patch)
treea5df76daaa40d5f1d0f0b075700eb982d842ffb8 /svl
parent9ed5793a8b602f992ad0f52b919e066d25eda49e (diff)
tdf#100592 Add extra number formats for fraction
Change-Id: Ia3a5fa02029e06e083fcc10748b0deb3048dae79 Reviewed-on: https://gerrit.libreoffice.org/26675 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/svl.cxx7
-rw-r--r--svl/source/numbers/zforlist.cxx49
2 files changed, 46 insertions, 10 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index d54fda3936f2..5c6b7452d1e8 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -146,7 +146,12 @@ void Test::testNumberFormat()
// Followings aren't in range of NF_FRACTION_START and NF_FRACTION_END
// see enum NfIndexTableOffset in svl/inc/svl/zforlist.hxx
const char* pFractionExt[] = {
+ "# \?\?\?/\?\?\?",
+ "# \?/2",
"# \?/4",
+ "# \?/8",
+ "# \?\?/16",
+ "# \?\?/10",
"# \?\?/100",
nullptr
};
@@ -223,7 +228,7 @@ void Test::testNumberFormat()
{ NF_SCIENTIFIC_START, NF_SCIENTIFIC_END, 2, pScientific },
{ NF_PERCENT_START, NF_PERCENT_END, 2, pPercent },
{ NF_FRACTION_START, NF_FRACTION_END, 2, pFraction },
- { NF_FRACTION_3, NF_FRACTION_4, 2, pFractionExt },
+ { NF_FRACTION_3D, NF_FRACTION_100, 7, pFractionExt },
{ NF_CURRENCY_START, NF_CURRENCY_END, 6, pCurrency },
{ NF_DATE_START, NF_DATE_END, 21, pDate },
{ NF_TIME_START, NF_TIME_END, 7, pTime },
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 29f95bc18a0f..bd67e25e9c09 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -67,7 +67,7 @@ using namespace ::std;
#define ZF_STANDARD_TIME 40
#define ZF_STANDARD_DATETIME 50
#define ZF_STANDARD_SCIENTIFIC 60
-#define ZF_STANDARD_FRACTION 70
+#define ZF_STANDARD_FRACTION 65
// Additional builtin formats not fitting into the first 10 of a category (TLOT
// = The Legacy Of Templin; unfortunately TLOT intended only 10 builtin formats
@@ -104,8 +104,8 @@ static sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = {
ZF_STANDARD_SCIENTIFIC + 1, // NF_SCIENTIFIC_000E00
ZF_STANDARD_PERCENT, // NF_PERCENT_INT
ZF_STANDARD_PERCENT + 1, // NF_PERCENT_DEC2
- ZF_STANDARD_FRACTION, // NF_FRACTION_1
- ZF_STANDARD_FRACTION + 1, // NF_FRACTION_2
+ ZF_STANDARD_FRACTION, // NF_FRACTION_1D
+ ZF_STANDARD_FRACTION + 1, // NF_FRACTION_2D
ZF_STANDARD_CURRENCY, // NF_CURRENCY_1000INT
ZF_STANDARD_CURRENCY + 1, // NF_CURRENCY_1000DEC2
ZF_STANDARD_CURRENCY + 2, // NF_CURRENCY_1000INT_RED
@@ -144,8 +144,13 @@ static sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = {
ZF_STANDARD_DATETIME + 1, // NF_DATETIME_SYS_DDMMYYYY_HHMMSS
ZF_STANDARD_LOGICAL, // NF_BOOLEAN
ZF_STANDARD_TEXT, // NF_TEXT
- ZF_STANDARD_FRACTION + 2, // NF_FRACTION_3
- ZF_STANDARD_FRACTION + 3, // NF_FRACTION_4
+ ZF_STANDARD_FRACTION + 2, // NF_FRACTION_3D
+ ZF_STANDARD_FRACTION + 3, // NF_FRACTION_2
+ ZF_STANDARD_FRACTION + 4, // NF_FRACTION_4
+ ZF_STANDARD_FRACTION + 5, // NF_FRACTION_8
+ ZF_STANDARD_FRACTION + 6, // NF_FRACTION_16
+ ZF_STANDARD_FRACTION + 7, // NF_FRACTION_10
+ ZF_STANDARD_FRACTION + 8, // NF_FRACTION_100
ZF_STANDARD_DATETIME + 2 // NF_DATETIME_ISO_YYYYMMDD_HHMMSS
};
@@ -2596,23 +2601,49 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
// # ?/?
aSingleFormatCode.Code = "# ?/?";
ImpInsertFormat( aSingleFormatCode,
- CLOffset + ZF_STANDARD_FRACTION /* NF_FRACTION_1 */ );
+ CLOffset + ZF_STANDARD_FRACTION /* NF_FRACTION_1D */ );
// # ??/??
//! "??/" would be interpreted by the compiler as a trigraph for '\'
aSingleFormatCode.Code = "# ?\?/?\?";
ImpInsertFormat( aSingleFormatCode,
- CLOffset + ZF_STANDARD_FRACTION+1 /* NF_FRACTION_2 */ );
+ CLOffset + ZF_STANDARD_FRACTION+1 /* NF_FRACTION_2D */ );
+
+ // # ???/???
+ //! "??/" would be interpreted by the compiler as a trigraph for '\'
+ aSingleFormatCode.Code = "# ?\?\?/?\?\?";
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + ZF_STANDARD_FRACTION+2 /* NF_FRACTION_3D */ );
+
+ // # ?/2
+ aSingleFormatCode.Code = "# ?/2";
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + ZF_STANDARD_FRACTION+3 /* NF_FRACTION_2 */ );
// # ?/4
aSingleFormatCode.Code = "# ?/4";
ImpInsertFormat( aSingleFormatCode,
- CLOffset + ZF_STANDARD_FRACTION+2 /* NF_FRACTION_3 */ );
+ CLOffset + ZF_STANDARD_FRACTION+4 /* NF_FRACTION_4 */ );
+
+ // # ?/8
+ aSingleFormatCode.Code = "# ?/8";
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + ZF_STANDARD_FRACTION+5 /* NF_FRACTION_8 */ );
+
+ // # ??/16
+ aSingleFormatCode.Code = "# ?\?/16";
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + ZF_STANDARD_FRACTION+6 /* NF_FRACTION_16 */ );
+
+ // # ??/10
+ aSingleFormatCode.Code = "# ?\?/10";
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + ZF_STANDARD_FRACTION+7 /* NF_FRACTION_10 */ );
// # ??/100
aSingleFormatCode.Code = "# ?\?/100";
ImpInsertFormat( aSingleFormatCode,
- CLOffset + ZF_STANDARD_FRACTION+3 /* NF_FRACTION_4 */ );
+ CLOffset + ZF_STANDARD_FRACTION+8 /* NF_FRACTION_100 */ );
// Week of year