diff options
author | Eike Rathke <erack@redhat.com> | 2021-03-10 23:02:42 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2021-03-11 16:33:24 +0100 |
commit | a6b9b1128d5ced0e3f82f88e442a7bba243ce164 (patch) | |
tree | 957032a8eb1ce0a5f0affde764152cbb2eb0a70b /xmloff/source | |
parent | 08e783903cf67e9c6673e21f99dfff816f8d5872 (diff) |
ODF save: handle implicit other calendar and switch to Gregorian for YYYY
In preparation for https://gerrit.libreoffice.org/c/core/+/108532
to add dual calendar mixed formats.
Change-Id: Ibc9294af3ad294c702ee6597b1a8831dec39b948
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112285
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/style/xmlnumfe.cxx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index b961eb2620f5..24c0524a4239 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -1268,6 +1268,8 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt sal_Int32 nMinDecimals = nPrecision; OUString sCurrExt; OUString aCalendar; + bool bImplicitOtherCalendar = false; + bool bExplicitCalendar = false; sal_uInt16 nPos = 0; bool bEnd = false; while (!bEnd) @@ -1336,7 +1338,10 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt case NF_KEY_R: case NF_KEY_RR: if (aCalendar.isEmpty()) + { aCalendar = lcl_GetDefaultCalendar( pFormatter, nLang ); + bImplicitOtherCalendar = true; + } break; } ++nPos; @@ -1579,7 +1584,10 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt case NF_SYMBOLTYPE_CALENDAR: if ( pElemStr ) + { aCalendar = *pElemStr; + bExplicitCalendar = true; + } break; // date elements: @@ -1640,10 +1648,16 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt case NF_KEY_R: //! R acts as EE, no attribute available { //! distinguish EE and R - // calendar attribute for E and EE and R is set in first loop + // Calendar attribute for E and EE and R is set in + // first loop. If set and not an explicit calendar and + // YY or YYYY is encountered, switch temporarily to + // Gregorian, i.e. empty calendar name. bool bLong = ( nElemType == NF_KEY_YYYY || nElemType == NF_KEY_EEC || nElemType == NF_KEY_R ); - WriteYearElement_Impl( aCalendar, ( bSystemDate ? bLongSysDate : bLong ) ); + WriteYearElement_Impl( + ((bImplicitOtherCalendar && !bExplicitCalendar + && (nElemType == NF_KEY_YY || nElemType == NF_KEY_YYYY)) ? OUString() : aCalendar), + (bSystemDate ? bLongSysDate : bLong)); bAnyContent = true; } break; |