Skip to content

Commit

Permalink
add NF_DATETIME_ISO_YYYYMMDD_HHMMSS YYYY-MM-DD HH:MM:SS builtin forma…
Browse files Browse the repository at this point in the history
…t code

Change-Id: I4fe6ef01a4c7fb795e4499e54aa55ebaaa0d433d
  • Loading branch information
erAck committed Jun 2, 2016
1 parent 5c24711 commit e7418e9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
17 changes: 15 additions & 2 deletions include/svl/zforlist.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ namespace com { namespace sun { namespace star {
Do NOT insert any new values!
The values here correspond with those in offapi/com/sun/star/i18n/NumberFormatIndex.idl
You may append values though.
*/
enum NfIndexTableOffset
{
Expand Down Expand Up @@ -131,6 +132,7 @@ enum NfIndexTableOffset
NF_DATE_DIN_MMDD, // 10-08 DIN
NF_DATE_DIN_YYMMDD, // 97-10-08 DIN
NF_DATE_DIN_YYYYMMDD, // 1997-10-08 DIN
NF_DATE_ISO_YYYYMMDD = NF_DATE_DIN_YYYYMMDD, // 1997-10-08 ISO clarify with name
NF_DATE_SYS_MMYY, // 10.97
NF_DATE_SYS_DDMMM, // 08.Oct
NF_DATE_MMMM, // October
Expand All @@ -156,15 +158,26 @@ enum NfIndexTableOffset
NF_BOOLEAN, // BOOLEAN
NF_TEXT, // @

NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // old number of predefined entries, locale data additions start after this
NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // == 50, old number of predefined entries, i18npool locale data additions start after this

// From here on are values of new built-in formats that are not in the
// original NumberFormatIndex.idl

// XXX Values appended here must also get a corresponding entry in
// svl/source/numbers/zforlist.cxx indexTable[] in the same order.

// XXX The dialog's number format shell assumes start/end spans
// (NF_..._START and NF_..._END above) to fill its categories with builtin
// formats, make new formats known to svx/source/items/numfmtsh.cxx
// 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_INDEX_TABLE_ENTRIES
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.
};


Expand Down
24 changes: 20 additions & 4 deletions svl/source/numbers/zforlist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ using namespace ::std;
* (old currency) is recognized as a date (#53155#). */
#define UNKNOWN_SUBSTITUTE LANGUAGE_ENGLISH_US

// Same order as in include/svl/zforlist.hxx enum NfIndexTableOffset
static sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = {
ZF_STANDARD, // NF_NUMBER_STANDARD
ZF_STANDARD + 1, // NF_NUMBER_INT
Expand Down Expand Up @@ -143,7 +144,8 @@ static sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = {
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 + 3, // NF_FRACTION_4
ZF_STANDARD_DATETIME + 2 // NF_DATETIME_ISO_YYYYMMDD_HHMMSS
};

/**
Expand Down Expand Up @@ -2495,7 +2497,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
ImpInsertFormat( aFormatSeq[nIdx],
CLOffset + ZF_STANDARD_NEWEXTENDED_DATE_DIN_YYMMDD /* NF_DATE_DIN_YYMMDD */ );

// YYYY-MM-DD DIN/EN
// YYYY-MM-DD DIN/EN/ISO
nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATE_DIN_YYYYMMDD );
ImpInsertFormat( aFormatSeq[nIdx],
CLOffset + ZF_STANDARD_NEWEXTENDED_DATE_DIN_YYYYMMDD /* NF_DATE_DIN_YYYYMMDD */ );
Expand Down Expand Up @@ -2555,6 +2557,22 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
ImpInsertFormat( aFormatSeq[nIdx],
CLOffset + ZF_STANDARD_DATETIME+1 /* NF_DATETIME_SYS_DDMMYYYY_HHMMSS */ );

const NfKeywordTable & rKeyword = pFormatScanner->GetKeywords();
i18n::NumberFormatCode aSingleFormatCode;
OUStringBuffer aBuf;
aSingleFormatCode.Usage = i18n::KNumberFormatUsage::DATE_TIME;

// YYYY-MM-DD HH:MM:SS ISO
aBuf.append( rKeyword[NF_KEY_YYYY]).append('-').
append( rKeyword[NF_KEY_MM]).append('-').
append( rKeyword[NF_KEY_DD]).append(' ').
append( rKeyword[NF_KEY_HH]).append(':').
append( rKeyword[NF_KEY_MMI]).append(':').
append( rKeyword[NF_KEY_SS]);
aSingleFormatCode.Code = aBuf.makeStringAndClear();
ImpInsertFormat( aSingleFormatCode,
CLOffset + ZF_STANDARD_DATETIME+2 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS */ );


// Scientific number
aFormatSeq = aNumberFormatCode.getAllFormatCode( i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER );
Expand All @@ -2572,7 +2590,6 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio


// Fraction number (no default option)
i18n::NumberFormatCode aSingleFormatCode;
aSingleFormatCode.Usage = i18n::KNumberFormatUsage::FRACTION_NUMBER;

// # ?/?
Expand All @@ -2598,7 +2615,6 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio


// Week of year
const NfKeywordTable & rKeyword = pFormatScanner->GetKeywords();
aSingleFormatCode.Code = rKeyword[NF_KEY_WW];
ImpInsertFormat( aSingleFormatCode,
CLOffset + ZF_STANDARD_NEWEXTENDED_DATE_WW /* NF_DATE_WW */ );
Expand Down
2 changes: 2 additions & 0 deletions svx/source/items/numfmtsh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ void SvxNumberFormatShell::FillEListWithStd_Impl( std::vector<OUString>& rList,
if(nPrivCat==CAT_DATE || nPrivCat==CAT_TIME)
{
nSelPos=FillEListWithDateTime_Impl(rList,nSelPos);
nSelPos = FillEListWithFormats_Impl( rList, nSelPos,
NF_DATETIME_ISO_YYYYMMDD_HHMMSS, NF_DATETIME_ISO_YYYYMMDD_HHMMSS);
}
}
}
Expand Down

0 comments on commit e7418e9

Please sign in to comment.