xmloff/source/style/xmlnumfe.cxx |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit a6b9b1128d5ced0e3f82f88e442a7bba243ce164
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed Mar 10 23:02:42 2021 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Mar 11 16:33:24 2021 +0100

    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 <er...@redhat.com>
    Tested-by: Jenkins

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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to