summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-02-22 18:52:06 +0100
committerEike Rathke <erack@redhat.com>2020-02-22 20:17:54 +0100
commit8453f6e5d1fd98700a37e30346a1af0daf8fb753 (patch)
tree9d5ee1a300bc922dd4c577365e598a2e7a814218 /svl
parent3ac9f491c20fb56c4544444d876687dd6d8de231 (diff)
Resolves: tdf#130563 Add predefined 4-digit year date+time format
Add a predefined NF_DATETIME_SYS_DDMMYYYY_HHMM format code with formatindex="50" to all locale data files, which shifts all reserved area internally generated built-in formats up by one. Reserved area was filled already so that boundary has to be increased as well. Add some flexibility for future additions by setting the new boundary to 65, free first format index to be used by additional locale data formats is 66 now. Adapt all locales to the new boundary. The existing predefined NF_DATETIME_SYSTEM_SHORT_HHMM format code with formatindex="46" mostly was and is used with 2-digit years (stemming back from the old binary format and Excel compatibility), some locales that don't use 2-digit years at all already defined it to 4-digit years. Keep those but move the default="true" attribute (if so) to the new "50" format. Modify populating the format list such that resulting duplicates will be suppressed there as well. Also try to match the new format in ODF import if a long year was requested with date+time. Finally set the new format as default for all *_IT locales. In future changing the default date+time format to 4-digit year is just a matter of moving the default="true" attribute to the new format. Change-Id: Ib16aa9fda0e71b2d03f78e3dd013785de03cd288 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89265 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/svl.cxx21
-rw-r--r--svl/source/numbers/zforlist.cxx23
2 files changed, 34 insertions, 10 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 8eb3cf4b6dfa..707754ac920f 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -220,6 +220,19 @@ void Test::testNumberFormat()
nullptr
};
+// Following aren't in range of NF_DATETIME_START and NF_DATETIME_END
+// see enum NfIndexTableOffset in svl/inc/svl/zforlist.hxx
+ const char* pDateTimeExt1[] = {
+ "MM/DD/YYYY HH:MM AM/PM",
+ nullptr
+ };
+
+ const char* pDateTimeExt2[] = {
+ "YYYY-MM-DD HH:MM:SS",
+ "YYYY-MM-DD\"T\"HH:MM:SS",
+ nullptr
+ };
+
const char* pBoolean[] = {
"BOOLEAN",
nullptr
@@ -240,13 +253,15 @@ 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_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 },
{ NF_DATETIME_START, NF_DATETIME_END, 2, pDateTime },
{ NF_BOOLEAN, NF_BOOLEAN, 1, pBoolean },
- { NF_TEXT, NF_TEXT, 1, pText }
+ { NF_TEXT, NF_TEXT, 1, pText },
+ { NF_DATETIME_SYS_DDMMYYYY_HHMM, NF_DATETIME_SYS_DDMMYYYY_HHMM, 1, pDateTimeExt1 },
+ { NF_FRACTION_3D, NF_FRACTION_100, 7, pFractionExt },
+ { NF_DATETIME_ISO_YYYYMMDD_HHMMSS, NF_DATETIME_ISO_YYYYMMDDTHHMMSS, 2, pDateTimeExt2 }
};
SvNumberFormatter aFormatter(m_xContext, eLang);
@@ -267,7 +282,7 @@ void Test::testNumberFormat()
CPPUNIT_ASSERT_MESSAGE("Number format entry is expected, but doesn't exist.", p);
OUString aCode = p->GetFormatstring();
- CPPUNIT_ASSERT_EQUAL( aCode.toUtf8() , OString( aTests[i].pCodes[j-nStart] ) );
+ CPPUNIT_ASSERT_EQUAL( OString( aTests[i].pCodes[j-nStart] ), aCode.toUtf8());
}
}
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 7243d0f7105c..1e7738caaf20 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -93,11 +93,14 @@ using namespace ::std;
static_assert( ZF_STANDARD_TEXT == NF_STANDARD_FORMAT_TEXT, "definition mismatch" );
+static_assert( NF_INDEX_TABLE_RESERVED_START == i18npool::nStopPredefinedFormatIndex,
+ "NfIndexTableOffset does not match i18npool's locale data predefined format code index bounds.");
+
static_assert( NF_INDEX_TABLE_ENTRIES <= i18npool::nFirstFreeFormatIndex,
"NfIndexTableOffset crosses i18npool's locale data reserved format code index bounds.\n"
"You will need to adapt all locale data files defining index values "
"(formatIndex=\"...\") in that range and increment those and when done "
- "adjust nFirstFreeFormatIndex in i18npool/reservedconstants.hxx");
+ "adjust nFirstFreeFormatIndex in include/i18npool/reservedconstants.hxx");
/* Locale that is set if an unknown locale (from another system) is loaded of
* legacy documents. Can not be SYSTEM because else, for example, a German "DM"
@@ -156,6 +159,7 @@ 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_DATETIME + 4, // NF_DATETIME_SYS_DDMMYYYY_HHMM
ZF_STANDARD_FRACTION + 2, // NF_FRACTION_3D
ZF_STANDARD_FRACTION + 3, // NF_FRACTION_2
ZF_STANDARD_FRACTION + 4, // NF_FRACTION_4
@@ -1954,15 +1958,15 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat( const css::i18n::NumberForma
sal_uInt32 nPos, bool bAfterChangingSystemCL,
sal_Int16 nOrgIndex )
{
- SAL_WARN_IF( NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS <= rCode.Index && rCode.Index < NF_INDEX_TABLE_ENTRIES,
+ SAL_WARN_IF( NF_INDEX_TABLE_RESERVED_START <= rCode.Index && rCode.Index < NF_INDEX_TABLE_ENTRIES,
"svl.numbers", "i18npool locale '" << maLanguageTag.getBcp47() <<
"' uses reserved formatIndex value " << rCode.Index << ", next free: " << NF_INDEX_TABLE_ENTRIES <<
" Please see description in include/svl/zforlist.hxx at end of enum NfIndexTableOffset");
- assert( (rCode.Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS || NF_INDEX_TABLE_ENTRIES <= rCode.Index) &&
+ assert( (rCode.Index < NF_INDEX_TABLE_RESERVED_START || NF_INDEX_TABLE_ENTRIES <= rCode.Index) &&
"reserved formatIndex, see warning above");
OUString aCodeStr( rCode.Code );
- if ( rCode.Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS &&
+ if ( rCode.Index < NF_INDEX_TABLE_RESERVED_START &&
rCode.Usage == css::i18n::KNumberFormatUsage::CURRENCY &&
rCode.Index != NF_CURRENCY_1000DEC2_CCC )
{ // strip surrounding [$...] on automatic currency
@@ -1999,7 +2003,7 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat( const css::i18n::NumberForma
}
return nullptr;
}
- if ( rCode.Index >= NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
+ if ( rCode.Index >= NF_INDEX_TABLE_RESERVED_START )
{
sal_uInt32 nCLOffset = nPos - (nPos % SV_COUNTRY_LANGUAGE_OFFSET);
sal_uInt32 nKey = ImpIsEntry( aCodeStr, nCLOffset, ActLnge );
@@ -2717,6 +2721,11 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
ImpInsertFormat( aFormatSeq[nIdx],
CLOffset + ZF_STANDARD_DATETIME+1 /* NF_DATETIME_SYS_DDMMYYYY_HHMMSS */ );
+ // DD.MM.YYYY HH:MM System
+ nIdx = ImpGetFormatCodeIndex( aFormatSeq, NF_DATETIME_SYS_DDMMYYYY_HHMM );
+ ImpInsertFormat( aFormatSeq[nIdx],
+ CLOffset + ZF_STANDARD_DATETIME+4 /* NF_DATETIME_SYS_DDMMYYYY_HHMM */ );
+
const NfKeywordTable & rKeyword = pFormatScanner->GetKeywords();
i18n::NumberFormatCode aSingleFormatCode;
aSingleFormatCode.Usage = i18n::KNumberFormatUsage::DATE_TIME;
@@ -2855,7 +2864,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
break; // for
}
- if ( rFormat.Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS &&
+ if ( rFormat.Index < NF_INDEX_TABLE_RESERVED_START &&
rFormat.Index != NF_CURRENCY_1000DEC2_CCC )
{ // Insert only if not already inserted, but internal index must be
// above so ImpInsertFormat can distinguish it.
@@ -2890,7 +2899,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
break; // for
}
- if ( rFormat.Index >= NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
+ if ( rFormat.Index >= NF_INDEX_TABLE_RESERVED_START )
{
if ( SvNumberformat* pNewFormat = ImpInsertFormat( rFormat, nPos+1,
bAfterChangingSystemCL ) )