[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - i18npool/inc i18npool/source
Eike Rathke
erack at redhat.com
Fri Mar 1 08:57:01 PST 2013
i18npool/inc/calendar_gregorian.hxx | 5 ++
i18npool/source/calendar/calendar_gregorian.cxx | 56 +++++++++++++++---------
2 files changed, 40 insertions(+), 21 deletions(-)
New commits:
commit 38fed1b25a1679ed4384ef0ed9ff4669f67a6723
Author: Eike Rathke <erack at 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/2474
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx
index 2a8ac14..929f759 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -30,10 +30,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;
@@ -101,6 +104,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 c92d720..a2a5324 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -200,11 +200,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)
{
@@ -212,8 +212,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)
{
@@ -221,8 +221,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)
{
@@ -1002,6 +1002,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;
@@ -1045,10 +1052,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
@@ -1087,12 +1101,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;
@@ -1126,11 +1140,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);
}
More information about the Libreoffice-commits
mailing list