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>
This commit is contained in:
Laurent Balland-Poirier
2016-06-24 23:28:39 +02:00
committed by Eike Rathke
parent 9ed5793a8b
commit 6951f28bba
5 changed files with 60 additions and 19 deletions

View File

@@ -100,9 +100,9 @@ enum NfIndexTableOffset
NF_PERCENT_END = NF_PERCENT_DEC2,
NF_FRACTION_START,
NF_FRACTION_1 = NF_FRACTION_START, // # ?/?
NF_FRACTION_2, // # ??/??
NF_FRACTION_END = NF_FRACTION_2,
NF_FRACTION_1D = NF_FRACTION_START, // # ?/?
NF_FRACTION_2D, // # ??/??
NF_FRACTION_END = NF_FRACTION_2D,
NF_NUMERIC_END = NF_FRACTION_END,
@@ -172,12 +172,17 @@ enum NfIndexTableOffset
// SvxNumberFormatShell::FillEListWithStd_Impl(), otherwise they will not
// be be listed at all. Yes that is ugly.
NF_FRACTION_3 = NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // # ?/4
NF_FRACTION_4, // # ?/100
NF_FRACTION_3D = NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // # ???/???
NF_FRACTION_2, // # ?/2
NF_FRACTION_4, // # ?/4
NF_FRACTION_8, // # ?/8
NF_FRACTION_16, // # ??/16
NF_FRACTION_10, // # ??/10
NF_FRACTION_100, // # ??/100
NF_DATETIME_ISO_YYYYMMDD_HHMMSS, // 1997-10-08 01:23:45 ISO (with blank instead of T)
NF_INDEX_TABLE_ENTRIES // == 53, reserved up to 59 to not use in i18npool locale data.
NF_INDEX_TABLE_ENTRIES // == 59, reserved up to 59 to not use in i18npool locale data.
};

View File

@@ -829,8 +829,8 @@ static const XclBuiltInFormat spBuiltInFormats_DONTKNOW[] =
EXC_NUMFMT_OFFSET( 9, NF_PERCENT_INT ), // 0%
EXC_NUMFMT_OFFSET( 10, NF_PERCENT_DEC2 ), // 0.00%
EXC_NUMFMT_OFFSET( 11, NF_SCIENTIFIC_000E00 ), // 0.00E+00
EXC_NUMFMT_OFFSET( 12, NF_FRACTION_1 ), // # ?/?
EXC_NUMFMT_OFFSET( 13, NF_FRACTION_2 ), // # ??/??
EXC_NUMFMT_OFFSET( 12, NF_FRACTION_1D ), // # ?/?
EXC_NUMFMT_OFFSET( 13, NF_FRACTION_2D ), // # ??/??
// 14...22 date and time formats
EXC_NUMFMT_OFFSET( 14, NF_DATE_SYS_DDMMYYYY ),

View File

@@ -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 },

View File

@@ -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

View File

@@ -642,7 +642,7 @@ void SvxNumberFormatShell::FillEListWithStd_Impl( std::vector<OUString>& rList,
case CAT_FRACTION :eOffsetStart=NF_FRACTION_START;
eOffsetEnd=NF_FRACTION_END;
nSelPos = FillEListWithFormats_Impl( rList, nSelPos, eOffsetStart, eOffsetEnd);
nSelPos = FillEListWithFormats_Impl( rList, nSelPos, NF_FRACTION_3, NF_FRACTION_4);
nSelPos = FillEListWithFormats_Impl( rList, nSelPos, NF_FRACTION_3D, NF_FRACTION_100);
return;
case CAT_BOOLEAN :eOffsetStart=NF_BOOLEAN;
eOffsetEnd=NF_BOOLEAN;