i18npool/inc/calendar_gregorian.hxx | 5 ++ i18npool/source/calendar/calendar_gregorian.cxx | 56 +++++++++++++++--------- 2 files changed, 40 insertions(+), 21 deletions(-)
New commits: commit 07b2b5ee619e123652bca2d18d4b61a94f94e00a Author: Eike Rathke <er...@redhat.com> Date: Thu Feb 28 18:34:41 2013 +0100 resolved fdo#60915 force long year only for ROC calendar Long year was forced unconditionally for all non-Gregorian calendars, do this only for ROC calendar. Change-Id: I39d6eb269b3d38046d32dcf0f66edd5617581b9d (cherry picked from commit be16dba682b8ab1c244f8d24f1bab3a539096962) Reviewed-on: https://gerrit.libreoffice.org/2477 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx index 03e4e81..9744be2 100644 --- a/i18npool/inc/calendar_gregorian.hxx +++ b/i18npool/inc/calendar_gregorian.hxx @@ -39,10 +39,13 @@ namespace com { namespace sun { namespace star { namespace i18n { +const sal_uInt8 kDisplayEraForcedLongYear = 0x01; + struct Era { sal_Int32 year; sal_Int32 month; sal_Int32 day; + sal_uInt8 flags; }; const sal_Int16 FIELD_INDEX_COUNT = CalendarFieldIndex::FIELD_COUNT2; @@ -110,6 +113,8 @@ protected: virtual void mapFromGregorian() throw(com::sun::star::uno::RuntimeException); void getValue() throw(com::sun::star::uno::RuntimeException); + rtl::OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode ) throw (com::sun::star::uno::RuntimeException); + private: Calendar2 aCalendar; diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index e32d391..e76c431 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -209,11 +209,11 @@ Calendar_hanja::loadCalendar( const OUString& /*uniqueID*/, const com::sun::star } static Era gengou_eraArray[] = { - {1868, 1, 1}, - {1912, 7, 30}, - {1926, 12, 25}, - {1989, 1, 8}, - {0, 0, 0} + {1868, 1, 1, 0}, + {1912, 7, 30, 0}, + {1926, 12, 25, 0}, + {1989, 1, 8, 0}, + {0, 0, 0, 0} }; Calendar_gengou::Calendar_gengou() : Calendar_gregorian(gengou_eraArray) { @@ -221,8 +221,8 @@ Calendar_gengou::Calendar_gengou() : Calendar_gregorian(gengou_eraArray) } static Era ROC_eraArray[] = { - {1912, 1, 1}, - {0, 0, 0} + {1912, 1, 1, kDisplayEraForcedLongYear}, // #i116701# + {0, 0, 0, 0} }; Calendar_ROC::Calendar_ROC() : Calendar_gregorian(ROC_eraArray) { @@ -230,8 +230,8 @@ Calendar_ROC::Calendar_ROC() : Calendar_gregorian(ROC_eraArray) } static Era buddhist_eraArray[] = { - {-542, 1, 1}, - {0, 0, 0} + {-542, 1, 1, 0}, + {0, 0, 0, 0} }; Calendar_buddhist::Calendar_buddhist() : Calendar_gregorian(buddhist_eraArray) { @@ -1011,6 +1011,13 @@ OUString SAL_CALL Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (RuntimeException) { + return getDisplayStringImpl( nCalendarDisplayCode, nNativeNumberMode, false); +} + +OUString +Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode ) + throw (RuntimeException) +{ sal_Int16 value = getValue(sal::static_int_cast<sal_Int16>( DisplayCode2FieldIndex(nCalendarDisplayCode) )); OUString aOUStr; @@ -1054,10 +1061,17 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 break; case CalendarDisplayCode::SHORT_YEAR: // Take last 2 digits, or only one if value<10, for example, - // in case of the Gengou calendar. - // #i116701# For values in non-Gregorian era years use all - // digits. - if (value < 100 || eraArray) + // in case of the Gengou calendar. For combined era+year always + // the full year is displayed, without leading 0. + // Workaround for non-combined calls in certain calendars is + // the kDisplayEraForcedLongYear flag, but this also could get + // called for YY not only E format codes, no differentiation + // possible here; the good news is that usually the Gregorian + // calendar is the default and hence YY calls for Gregorian and + // E for the other calendar and currently (2013-02-28) ROC is + // the only calendar using this. + // See i#116701 and fdo#60915 + if (value < 100 || bEraMode || (eraArray && (eraArray[0].flags & kDisplayEraForcedLongYear))) sprintf(aStr, "%d", value); // #100211# - checked else sprintf(aStr, "%02d", value % 100); // #100211# - checked @@ -1096,12 +1110,12 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 return getDisplayName(CalendarDisplayIndex::ERA, value, 1); case CalendarDisplayCode::SHORT_YEAR_AND_ERA: - return getDisplayString( CalendarDisplayCode::SHORT_ERA, nNativeNumberMode ) + - getDisplayString( CalendarDisplayCode::SHORT_YEAR, nNativeNumberMode ); + return getDisplayStringImpl( CalendarDisplayCode::SHORT_ERA, nNativeNumberMode, true ) + + getDisplayStringImpl( CalendarDisplayCode::SHORT_YEAR, nNativeNumberMode, true ); case CalendarDisplayCode::LONG_YEAR_AND_ERA: - return getDisplayString( CalendarDisplayCode::LONG_ERA, nNativeNumberMode ) + - getDisplayString( CalendarDisplayCode::LONG_YEAR, nNativeNumberMode ); + return getDisplayStringImpl( CalendarDisplayCode::LONG_ERA, nNativeNumberMode, true ) + + getDisplayStringImpl( CalendarDisplayCode::LONG_YEAR, nNativeNumberMode, true ); default: throw ERROR; @@ -1135,11 +1149,11 @@ Calendar_buddhist::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 n nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR_AND_ERA) && getValue(CalendarFieldIndex::ERA) == 0) { if (nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR_AND_ERA) - return getDisplayString( CalendarDisplayCode::SHORT_YEAR, nNativeNumberMode ) + - getDisplayString( CalendarDisplayCode::SHORT_ERA, nNativeNumberMode ); + return getDisplayStringImpl( CalendarDisplayCode::SHORT_YEAR, nNativeNumberMode, true ) + + getDisplayStringImpl( CalendarDisplayCode::SHORT_ERA, nNativeNumberMode, true ); else - return getDisplayString( CalendarDisplayCode::LONG_YEAR, nNativeNumberMode ) + - getDisplayString( CalendarDisplayCode::LONG_ERA, nNativeNumberMode ); + return getDisplayStringImpl( CalendarDisplayCode::LONG_YEAR, nNativeNumberMode, true ) + + getDisplayStringImpl( CalendarDisplayCode::LONG_ERA, nNativeNumberMode, true ); } return Calendar_gregorian::getDisplayString(nCalendarDisplayCode, nNativeNumberMode); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits