Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2474

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/74/2474/1

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)
---
M i18npool/inc/calendar_gregorian.hxx
M i18npool/source/calendar/calendar_gregorian.cxx
2 files changed, 40 insertions(+), 21 deletions(-)



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 @@
     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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 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 @@
                 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 @@
                 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 @@
                 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);
 }

-- 
To view, visit https://gerrit.libreoffice.org/2474
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39d6eb269b3d38046d32dcf0f66edd5617581b9d
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Eike Rathke <erack@redhat.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.