summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-03-15 15:57:18 +0100
committerEike Rathke <erack@redhat.com>2021-03-15 20:25:47 +0100
commitc98891a4ba67a73d7a683ffb24845512705a4bbf (patch)
tree50940bce0074dd6dd524f5461fc09c33b34140d6 /svl
parent8a7b46c0372eb2445c0bd35c1ebe4a7c96115e5c (diff)
xls load: suppress secondary [~gengou] calendar modifier in format code
ja-JP Gengou calendar is an implicit secondary calendar switched to and from by format codes. Change-Id: Iea268310ac5e917f2168fec0166754424baa925d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112511 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zformat.cxx30
1 files changed, 27 insertions, 3 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 8787f0977984..f74b178a0419 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -442,8 +442,10 @@ OUString SvNumberformat::ImpObtainCalendarAndNumerals( OUStringBuffer& rString,
switch ( aTmpLocale.mnCalendarType & 0x7F )
{
case 0x03 : // Gengou calendar
- sCalendar = "[~gengou]";
- // Only Japanese language support Gengou calendar
+ // Only Japanese language support Gengou calendar.
+ // It is an implicit "other" calendar where E, EE, R and RR
+ // automatically switch to and YY and YYYY switch to Gregorian. Do
+ // not add the "[~gengou]" modifier.
if ( nLocaleLang != LANGUAGE_JAPANESE )
{
nLang = maLocale.meLanguage = LANGUAGE_JAPANESE;
@@ -5252,6 +5254,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
sal_Int32 nPosHaveLCID = -1;
sal_Int32 nPosInsertLCID = aStr.getLength();
sal_uInt32 nCalendarID = 0x0000000; // Excel ID of calendar used in sub-format see tdf#36038
+ constexpr sal_uInt32 kCalGengou = 0x0030000;
if ( nCnt )
{
auto& rTypeArray = NumFor[n].Info().nTypeArray;
@@ -5265,6 +5268,27 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
{
aStr.append( rLocWrp.getLongDateDayOfWeekSep() );
}
+ switch (rTypeArray[j])
+ {
+ case NF_KEY_EC:
+ case NF_KEY_EEC:
+ case NF_KEY_R:
+ case NF_KEY_RR:
+ // Implicit secondary (non-gregorian) calendar.
+ // Currently only for ja-JP.
+ /* TODO: same for all locales in
+ * LocaleDataWrapper::doesSecondaryCalendarUseEC() ?
+ * Should split the locales off that then. */
+ if (!nCalendarID)
+ {
+ const LanguageType nLang = MsLangId::getRealLanguage( nOriginalLang);
+ if (nLang == LANGUAGE_JAPANESE)
+ nCalendarID = kCalGengou;
+ }
+ break;
+ default:
+ ; // nothing
+ }
}
else
{
@@ -5313,7 +5337,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
break;
if ( rStrArray[j+1] == "gengou" )
{
- nCalendarID = 0x0030000;
+ nCalendarID = kCalGengou;
}
else if ( rStrArray[j+1] == "hijri" )
{