Resolves: tdf#128649 Do not insert duplicate LCID for currency
Fallout from
commit d0f8daa0980ba8e403b32006831657c5a0a4ea17
CommitDate: Wed Aug 22 19:03:27 2018 +0200
Resolves: tdf#73063 preserve and roundtrip LCID from/to Excel number formats
Change-Id: I356f37624786d753370a272b0f1b54b17b5d206c
Reviewed-on: https://gerrit.libreoffice.org/82249
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ <xiscofauli@libreoffice.org>
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index eb2b47d..ce04f09 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5239,6 +5239,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
{
aStr.append( aPrefix );
}
sal_Int32 nPosHaveLCID = -1;
sal_Int32 nPosInsertLCID = aStr.getLength();
sal_uInt32 nCalendarID = 0x0000000; // Excel ID of calendar used in sub-format see tdf#36038
if ( nCnt )
@@ -5318,6 +5319,10 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
if ( nCalendarID > 0 )
j = j+2;
break;
case NF_SYMBOLTYPE_CURREXT :
nPosHaveLCID = aStr.getLength();
aStr.append( rStrArray[j] );
break;
default:
aStr.append( rStrArray[j] );
}
@@ -5428,19 +5433,24 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
if ( aNatNum.GetDBNum() > 0 && nLanguageID == LANGUAGE_SYSTEM )
nLanguageID = MsLangId::getRealLanguage( aNatNum.GetLang());
}
else if (!bSystemLanguage && nOriginalLang != LANGUAGE_DONTKNOW)
else if (nPosHaveLCID < 0)
{
// Explicit locale, write only to the first subformat.
if (n == 0)
nLanguageID = MsLangId::getRealLanguage( nOriginalLang);
}
else if (bSystemLanguage && maLocale.meLanguageWithoutLocaleData != LANGUAGE_DONTKNOW)
{
// Explicit locale but no locale data thus assigned to system
// locale, preserve for roundtrip, write only to the first
// subformat.
if (n == 0)
nLanguageID = maLocale.meLanguageWithoutLocaleData;
// Do not insert a duplicated LCID that was already given with a
// currency format as [$R-1C09]
if (!bSystemLanguage && nOriginalLang != LANGUAGE_DONTKNOW)
{
// Explicit locale, write only to the first subformat.
if (n == 0)
nLanguageID = MsLangId::getRealLanguage( nOriginalLang);
}
else if (bSystemLanguage && maLocale.meLanguageWithoutLocaleData != LANGUAGE_DONTKNOW)
{
// Explicit locale but no locale data thus assigned to system
// locale, preserve for roundtrip, write only to the first
// subformat.
if (n == 0)
nLanguageID = maLocale.meLanguageWithoutLocaleData;
}
}
if ( nCalendarID > 0 )
{ // Add alphabet and language to calendar