include/xmloff/xmlnumfi.hxx | 2 - xmloff/source/style/xmlnumfi.cxx | 41 +++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 15 deletions(-)
New commits: commit e12c9b41012e44275761b35795b83ec4bc838d42 Author: Eike Rathke <er...@redhat.com> Date: Tue Sep 13 19:33:11 2016 +0200 do not add calendar modifier to format code when importing as E or EE keyword ... with implicit calendar switch. Change-Id: Ie4d848e261fe86bbe504954b2e0c7cf24bc181bc diff --git a/include/xmloff/xmlnumfi.hxx b/include/xmloff/xmlnumfi.hxx index a3eb590..10283e6 100644 --- a/include/xmloff/xmlnumfi.hxx +++ b/include/xmloff/xmlnumfi.hxx @@ -186,7 +186,7 @@ public: void SetHasLongDoW(bool bSet) { bHasLongDoW = bSet; } bool HasEra() const { return bHasEra; } - void UpdateCalendar( const OUString& rNewCalendar ); + void UpdateCalendar( const OUString& rNewCalendar, bool bImplicitSecondaryCalendarEC = false ); const LocaleDataWrapper& GetLocaleData() const; diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 164ce76..257d945 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -1201,20 +1201,33 @@ void SvXMLNumFmtElementContext::EndElement() : ( bEffLong ? NF_KEY_MM : NF_KEY_M ) ) ); break; case XML_TOK_STYLE_YEAR: - rParent.UpdateCalendar( sCalendar ); //! I18N doesn't provide SYSTEM or extended date information yet - // Y after G (era) is replaced by E, also if we're switching to the - // other second known calendar for a locale. - if ( rParent.HasEra() || rParent.GetLocaleData().doesSecondaryCalendarUseEC( sCalendar)) { - rParent.AddNfKeyword( - sal::static_int_cast< sal_uInt16 >( - bEffLong ? NF_KEY_EEC : NF_KEY_EC ) ); + // Y after G (era) is replaced by E, also if we're switching to the + // other second known calendar for a locale. + bool bImplicitEC = (!sCalendar.isEmpty() && + rParent.GetLocaleData().doesSecondaryCalendarUseEC( sCalendar)); + if (rParent.HasEra() || bImplicitEC) + { + // If E or EE is the first format keyword, passing + // bImplicitEC=true suppresses the superfluous calendar + // modifier for this format. This does not help for + // something like [~cal]DD/MM/EE but so far only YMD order + // is used with such calendars. Live with the modifier if + // other keywords precede this. + rParent.UpdateCalendar( sCalendar, bImplicitEC); + rParent.AddNfKeyword( + sal::static_int_cast< sal_uInt16 >( + bEffLong ? NF_KEY_EEC : NF_KEY_EC ) ); + } + else + { + rParent.UpdateCalendar( sCalendar ); + rParent.AddNfKeyword( + sal::static_int_cast< sal_uInt16 >( + bEffLong ? NF_KEY_YYYY : NF_KEY_YY ) ); + } } - else - rParent.AddNfKeyword( - sal::static_int_cast< sal_uInt16 >( - bEffLong ? NF_KEY_YYYY : NF_KEY_YY ) ); break; case XML_TOK_STYLE_ERA: rParent.UpdateCalendar( sCalendar ); @@ -2257,12 +2270,12 @@ void SvXMLNumFormatContext::AddColor( sal_uInt32 const nColor ) } } -void SvXMLNumFormatContext::UpdateCalendar( const OUString& rNewCalendar ) +void SvXMLNumFormatContext::UpdateCalendar( const OUString& rNewCalendar, bool bImplicitSecondaryCalendarEC ) { if ( rNewCalendar != sCalendar ) { sCalendar = rNewCalendar; - if ( !sCalendar.isEmpty() ) + if ( !sCalendar.isEmpty() && !bImplicitSecondaryCalendarEC ) { aFormatCode.append( "[~" ); // intro for calendar code aFormatCode.append( sCalendar ); commit 426723912fcb9bca39e0cada68e209f5f1be927c Author: Eike Rathke <er...@redhat.com> Date: Tue Sep 13 16:18:32 2016 +0200 that copypasta comment fragment makes no sense Change-Id: I835fd6045e5ab5aeb93c91edb07037b1ed3ea4a9 diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 1fd5afd..164ce76 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -2266,7 +2266,7 @@ void SvXMLNumFormatContext::UpdateCalendar( const OUString& rNewCalendar ) { aFormatCode.append( "[~" ); // intro for calendar code aFormatCode.append( sCalendar ); - aFormatCode.append( ']' ); // end of "new" currency symbolcalendar code + aFormatCode.append( ']' ); // end of calendar code } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits