summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-11-19 15:51:41 +0100
committerEike Rathke <erack@redhat.com>2011-11-19 16:15:22 +0100
commit4b030331f725c63bc5ef0f365091179f0e6a78e5 (patch)
treeb1ab159eb97161cab005297e8ef261bd20594c61 /i18npool
parent769511019bd5a02a5a2c307c2c8558279742672c (diff)
add narrow (one letter) month names
While introducing Calendar2 and the XCalendar3 interface anyway, as well the "one letter" narrow month names sometimes needed in calendaring can be added. These are not always the first capitalized letters of the months in all locales, and might even not necessarily be just one character. Introduces a new struct css::i18n::Calendar2 that is not derived from css::i18n::Calendar because it uses a new struct css::i18n::CalendarItem2 to hold the NarrowName elements. In locale data the elements DaysOfMonth, MonthsOfYear and GenitiveMonths now have an optional element DefaultNarrowName. If not specified, the first character of DefaultFullName is taken. LocaleDataWrapper and CalendarWrapper use and return the new Calendar2 and sequences of CalendarItem2 structs. Application code adapted. The number formatter now displays narrow month names (genitive if applicable) for the MMMMM code, previously it displayed the first 16 bit code point of the full name (not even utf-16 aware). Narrow day names currently are not used, except in svtools' Calendar control.
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/calendarImpl.hxx4
-rw-r--r--i18npool/inc/calendar_gregorian.hxx4
-rw-r--r--i18npool/inc/localedata.hxx9
-rw-r--r--i18npool/source/calendar/calendarImpl.cxx26
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx36
-rw-r--r--i18npool/source/localedata/LocaleNode.cxx121
-rw-r--r--i18npool/source/localedata/data/locale.dtd8
-rw-r--r--i18npool/source/localedata/localedata.cxx84
8 files changed, 204 insertions, 88 deletions
diff --git a/i18npool/inc/calendarImpl.hxx b/i18npool/inc/calendarImpl.hxx
index d117e53a4a83..da69ef886a5a 100644
--- a/i18npool/inc/calendarImpl.hxx
+++ b/i18npool/inc/calendarImpl.hxx
@@ -87,7 +87,9 @@ public:
// XCalendar3
virtual Calendar2 SAL_CALL getLoadedCalendar2() throw(com::sun::star::uno::RuntimeException);
- virtual com::sun::star::uno::Sequence < CalendarItem > SAL_CALL getGenitiveMonths() throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getDays2() throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getMonths2() throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getGenitiveMonths2() throw(com::sun::star::uno::RuntimeException);
//XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx
index b95ab22630fb..42d7599d59d6 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -86,7 +86,9 @@ public:
// XCalendar3
virtual Calendar2 SAL_CALL getLoadedCalendar2() throw(com::sun::star::uno::RuntimeException);
- virtual com::sun::star::uno::Sequence < CalendarItem > SAL_CALL getGenitiveMonths() throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getDays2() throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getMonths2() throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getGenitiveMonths2() throw(com::sun::star::uno::RuntimeException);
//XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
diff --git a/i18npool/inc/localedata.hxx b/i18npool/inc/localedata.hxx
index dfdb826f12b6..a28f1049fab1 100644
--- a/i18npool/inc/localedata.hxx
+++ b/i18npool/inc/localedata.hxx
@@ -74,7 +74,7 @@ inline sal_Bool operator ==(const com::sun::star::lang::Locale& l1, const com::s
class LocaleData : public cppu::WeakImplHelper2
<
- XLocaleData3,
+ com::sun::star::i18n::XLocaleData3,
com::sun::star::lang::XServiceInfo
>
{
@@ -82,6 +82,9 @@ public:
LocaleData();
~LocaleData();
+ static com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > downcastCalendarItems( const com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > & rCi );
+ static com::sun::star::i18n::Calendar downcastCalendar( const com::sun::star::i18n::Calendar2 & rC );
+
virtual LanguageCountryInfo SAL_CALL getLanguageCountryInfo( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
virtual LocaleDataItem SAL_CALL getLocaleItem( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< Calendar2 > SAL_CALL getAllCalendars2( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
@@ -129,14 +132,14 @@ private :
sal_Unicode ** SAL_CALL getIndexArrayForAlgorithm(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rAlgorithm);
com::sun::star::i18n::Calendar2 ref_cal;
rtl::OUString ref_name;
- com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > &
+ com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > &
getCalendarItemByName(const rtl::OUString& name,
const com::sun::star::lang::Locale& rLocale,
const com::sun::star::uno::Sequence< com::sun::star::i18n::Calendar2 >& calendarsSeq,
sal_Int16 item) throw( com::sun::star::uno::RuntimeException );
/// Helper to obtain a sequence of days, months, gmonths or eras.
- com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > getCalendarItems(
+ com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > getCalendarItems(
sal_Unicode const * const * const allCalendars,
sal_Int16 & rnOffset,
const sal_Int16 nWhichItem,
diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx
index 52eea4ff0a44..aebc1d5accdc 100644
--- a/i18npool/source/calendar/calendarImpl.cxx
+++ b/i18npool/source/calendar/calendarImpl.cxx
@@ -292,11 +292,31 @@ CalendarImpl::getMonths() throw(RuntimeException)
}
-Sequence< CalendarItem > SAL_CALL
-CalendarImpl::getGenitiveMonths() throw(RuntimeException)
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getDays2() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getDays2();
+ else
+ throw ERROR ;
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getMonths2() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getMonths2();
+ else
+ throw ERROR ;
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getGenitiveMonths2() throw(RuntimeException)
{
if (xCalendar.is())
- return xCalendar->getGenitiveMonths();
+ return xCalendar->getGenitiveMonths2();
else
throw ERROR ;
}
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 21a6b12bad95..23e95220b25b 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -132,6 +132,7 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using ::rtl::OUString;
+
namespace com { namespace sun { namespace star { namespace i18n {
#define ERROR RuntimeException()
@@ -281,8 +282,7 @@ Calendar_gregorian::getLoadedCalendar2() throw(RuntimeException)
com::sun::star::i18n::Calendar SAL_CALL
Calendar_gregorian::getLoadedCalendar() throw(RuntimeException)
{
- // gets "down-copy-constructed"
- return aCalendar;
+ return LocaleData::downcastCalendar( aCalendar);
}
OUString SAL_CALL
@@ -838,6 +838,7 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
return CalendarFieldIndex::DAY_OF_MONTH;
case CalendarDisplayCode::SHORT_DAY_NAME:
case CalendarDisplayCode::LONG_DAY_NAME:
+ case CalendarDisplayCode::NARROW_DAY_NAME:
return CalendarFieldIndex::DAY_OF_WEEK;
case CalendarDisplayCode::SHORT_QUARTER:
case CalendarDisplayCode::LONG_QUARTER:
@@ -845,8 +846,10 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
case CalendarDisplayCode::LONG_MONTH:
case CalendarDisplayCode::SHORT_MONTH_NAME:
case CalendarDisplayCode::LONG_MONTH_NAME:
+ case CalendarDisplayCode::NARROW_MONTH_NAME:
case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
+ case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
return CalendarFieldIndex::MONTH;
case CalendarDisplayCode::SHORT_YEAR:
case CalendarDisplayCode::LONG_YEAR:
@@ -910,19 +913,33 @@ Calendar_gregorian::getNumberOfDaysInWeek() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getDays() throw(RuntimeException)
{
- return aCalendar.Days;
+ return LocaleData::downcastCalendarItems( aCalendar.Days);
}
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getMonths() throw(RuntimeException)
{
+ return LocaleData::downcastCalendarItems( aCalendar.Months);
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getDays2() throw(RuntimeException)
+{
+ return aCalendar.Days;
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getMonths2() throw(RuntimeException)
+{
return aCalendar.Months;
}
-Sequence< CalendarItem > SAL_CALL
-Calendar_gregorian::getGenitiveMonths() throw(RuntimeException)
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getGenitiveMonths2() throw(RuntimeException)
{
return aCalendar.GenitiveMonths;
}
@@ -943,18 +960,21 @@ Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_I
if( idx >= aCalendar.Days.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
else throw ERROR;
break;
case CalendarDisplayIndex::MONTH:
if( idx >= aCalendar.Months.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
else throw ERROR;
break;
case CalendarDisplayIndex::GENITIVE_MONTH:
if( idx >= aCalendar.GenitiveMonths.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.GenitiveMonths[idx].AbbrevName;
else if (nameType == 1) aStr = aCalendar.GenitiveMonths[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
else throw ERROR;
break;
case CalendarDisplayIndex::ERA:
@@ -1035,14 +1055,20 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16
return getDisplayName(CalendarDisplayIndex::DAY, value, 0);
case CalendarDisplayCode::LONG_DAY_NAME:
return getDisplayName(CalendarDisplayIndex::DAY, value, 1);
+ case CalendarDisplayCode::NARROW_DAY_NAME:
+ return getDisplayName(CalendarDisplayIndex::DAY, value, 2);
case CalendarDisplayCode::SHORT_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::MONTH, value, 0);
case CalendarDisplayCode::LONG_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::MONTH, value, 1);
+ case CalendarDisplayCode::NARROW_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::MONTH, value, 2);
case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 0);
case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 1);
+ case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 2);
case CalendarDisplayCode::SHORT_ERA:
return getDisplayName(CalendarDisplayIndex::ERA, value, 0);
case CalendarDisplayCode::LONG_ERA:
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index 0dbb77045a31..fac4583ad4ec 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -1134,6 +1134,64 @@ void LCIndexNode::generateCode (const OFileWriter &of) const
of.writeFunction("getFollowPageWords_", "nbOfPageWords", "FollowPageWordArray");
}
+
+static void lcl_writeAbbrFullNarrNames( const OFileWriter & of, const LocaleNode* currNode,
+ const sal_Char* elementTag, sal_Int16 i, sal_Int16 j )
+{
+ OUString aAbbrName = currNode->getChildAt(1)->getValue();
+ OUString aFullName = currNode->getChildAt(2)->getValue();
+ OUString aNarrName;
+ LocaleNode* p = (currNode->getNumberOfChildren() > 3 ? currNode->getChildAt(3) : 0);
+ if (p && p->getName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DefaultNarrowName")))
+ aNarrName = p->getValue();
+ else
+ {
+ sal_Int32 nIndex = 0;
+ sal_uInt32 nChar = aFullName.iterateCodePoints( &nIndex);
+ aNarrName = OUString( &nChar, 1);
+ }
+ of.writeParameter( elementTag, "DefaultAbbrvName", aAbbrName, i, j);
+ of.writeParameter( elementTag, "DefaultFullName", aFullName, i, j);
+ of.writeParameter( elementTag, "DefaultNarrowName", aNarrName, i, j);
+}
+
+static void lcl_writeTabTagString( const OFileWriter & of, const sal_Char* pTag, const sal_Char* pStr )
+{
+ of.writeAsciiString("\t");
+ of.writeAsciiString( pTag);
+ of.writeAsciiString( pStr);
+}
+
+static void lcl_writeTabTagStringNums( const OFileWriter & of,
+ const sal_Char* pTag, const sal_Char* pStr, sal_Int16 i, sal_Int16 j )
+{
+ lcl_writeTabTagString( of, pTag, pStr);
+ of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
+}
+
+static void lcl_writeAbbrFullNarrArrays( const OFileWriter & of, sal_Int16 nCount,
+ const sal_Char* elementTag, sal_Int16 i, bool bNarrow )
+{
+ if (nCount == 0)
+ {
+ lcl_writeTabTagString( of, elementTag, "Ref");
+ of.writeInt(i); of.writeAsciiString(",\n");
+ lcl_writeTabTagString( of, elementTag, "RefName");
+ of.writeInt(i); of.writeAsciiString(",\n");
+ }
+ else
+ {
+ for (sal_Int16 j = 0; j < nCount; j++)
+ {
+ lcl_writeTabTagStringNums( of, elementTag, "ID", i, j);
+ lcl_writeTabTagStringNums( of, elementTag, "DefaultAbbrvName", i, j);
+ lcl_writeTabTagStringNums( of, elementTag, "DefaultFullName", i, j);
+ if (bNarrow)
+ lcl_writeTabTagStringNums( of, elementTag, "DefaultNarrowName", i, j);
+ }
+ }
+}
+
void LCCalendarNode::generateCode (const OFileWriter &of) const
{
::rtl::OUString useLocale = getAttr().getValueByName("ref");
@@ -1192,8 +1250,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeParameter("dayID", dayID, i, j);
if (j == 0 && bGregorian && !dayID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "sun")))
incError( "First day of a week of a Gregorian calendar must be <DayID>sun</DayID>");
- of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j);
- of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j);
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
}
}
++nChild;
@@ -1225,8 +1282,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeParameter("monthID", monthID, i, j);
if (j == 0 && bGregorian && !monthID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "jan")))
incError( "First month of a year of a Gregorian calendar must be <MonthID>jan</MonthID>");
- of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j);
- of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j);
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
}
}
++nChild;
@@ -1261,8 +1317,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeParameter("genitiveMonthID", genitiveMonthID, i, j);
if (j == 0 && bGregorian && !genitiveMonthID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "jan")))
incError( "First genitive month of a year of a Gregorian calendar must be <MonthID>jan</MonthID>");
- of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j);
- of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j);
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
}
}
++nChild;
@@ -1377,56 +1432,10 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeAsciiString("\tdefaultCalendar");
of.writeInt(i);
of.writeAsciiString(",\n");
- if (nbOfDays[i] == 0) {
- of.writeAsciiString("\tdayRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\tdayRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfDays[i]; j++) {
- of.writeAsciiString("\tdayID");
- of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- of.writeAsciiString("\tdayDefaultAbbrvName");
- of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- of.writeAsciiString("\tdayDefaultFullName");of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- }
- }
- if (nbOfMonths[i] == 0) {
- of.writeAsciiString("\tmonthRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\tmonthRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfMonths[i]; j++) {
- of.writeAsciiString("\tmonthID");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tmonthDefaultAbbrvName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tmonthDefaultFullName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- }
- }
- if (nbOfGenitiveMonths[i] == 0) {
- of.writeAsciiString("\tgenitiveMonthRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\tgenitiveMonthRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfGenitiveMonths[i]; j++) {
- of.writeAsciiString("\tgenitiveMonthID");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tgenitiveMonthDefaultAbbrvName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tgenitiveMonthDefaultFullName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- }
- }
- if (nbOfEras[i] == 0) {
- of.writeAsciiString("\teraRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\teraRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfEras[i]; j++) {
- of.writeAsciiString("\teraID"); of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- of.writeAsciiString("\teraDefaultAbbrvName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\teraDefaultFullName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- }
- }
+ lcl_writeAbbrFullNarrArrays( of, nbOfDays[i], "day", i, true);
+ lcl_writeAbbrFullNarrArrays( of, nbOfMonths[i], "month", i, true);
+ lcl_writeAbbrFullNarrArrays( of, nbOfGenitiveMonths[i], "genitiveMonth", i, true);
+ lcl_writeAbbrFullNarrArrays( of, nbOfEras[i], "era", i, false /*noNarrow*/);
of.writeAsciiString("\tstartDayOfWeek");of.writeInt(i); of.writeAsciiString(",\n");
of.writeAsciiString("\tminimalDaysInFirstWeek");of.writeInt(i); of.writeAsciiString(",\n");
}
diff --git a/i18npool/source/localedata/data/locale.dtd b/i18npool/source/localedata/data/locale.dtd
index 8a0a9e781a0d..ac0cfa739aff 100644
--- a/i18npool/source/localedata/data/locale.dtd
+++ b/i18npool/source/localedata/data/locale.dtd
@@ -269,13 +269,17 @@
<!-- All Day elements of a Calendar must be given if the RefLocale mechanism is not used! -->
<!ATTLIST DaysOfWeek %RefLocale;>
<!-- Sequence of days is important, MUST start with Sunday. -->
-<!ELEMENT Day (DayID, DefaultAbbrvName, DefaultFullName)>
+<!ELEMENT Day (DayID, DefaultAbbrvName, DefaultFullName, DefaultNarrowName*)>
<!ELEMENT DayID (#PCDATA)>
<!-- Preferably the lower case abbreviated English name like sun for Sunday. -->
<!ELEMENT DefaultAbbrvName (#PCDATA)>
<!-- The abbreviated day name, e.g. Sun for Sunday. -->
<!ELEMENT DefaultFullName (#PCDATA)>
<!-- The full day name, e.g. Sunday for Sunday. -->
+<!ELEMENT DefaultNarrowName (#PCDATA)>
+<!-- The narrow day name, e.g. S for Sunday.
+ If not specified, the first letter of the corresponding DefaultFullName is taken.
+ -->
<!ELEMENT MonthsOfYear (Month*)>
<!-- All Month elements of a Calendar must be given if the RefLocale mechanism is not used! -->
@@ -294,7 +298,7 @@
year, e.g. January in a Gregorian calendar.
-->
-<!ELEMENT Month (MonthID, DefaultAbbrvName, DefaultFullName)>
+<!ELEMENT Month (MonthID, DefaultAbbrvName, DefaultFullName, DefaultNarrowName*)>
<!ELEMENT MonthID (#PCDATA)>
<!-- Preferably the lower case abbreviated English name like jan for January. -->
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index c859da5c3cb7..9b87de6c7976 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -281,6 +281,36 @@ struct LocaleDataLookupTableItem
}
};
+
+// static
+Sequence< CalendarItem > LocaleData::downcastCalendarItems( const Sequence< CalendarItem2 > & rCi )
+{
+ sal_Int32 nSize = rCi.getLength();
+ Sequence< CalendarItem > aCi( nSize);
+ CalendarItem* p1 = aCi.getArray();
+ const CalendarItem2* p2 = rCi.getConstArray();
+ for (sal_Int32 i=0; i < nSize; ++i, ++p1, ++p2)
+ *p1 = *p2;
+ return aCi;
+}
+
+
+// static
+Calendar LocaleData::downcastCalendar( const Calendar2 & rC )
+{
+ Calendar aCal(
+ downcastCalendarItems( rC.Days),
+ downcastCalendarItems( rC.Months),
+ downcastCalendarItems( rC.Eras),
+ rC.StartOfWeek,
+ rC.MinimumNumberOfDaysForFirstWeek,
+ rC.Default,
+ rC.Name
+ );
+ return aCal;
+}
+
+
LocaleData::LocaleData()
{
}
@@ -467,7 +497,7 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName(
#define REF_ERAS 3
#define REF_OFFSET_COUNT 4
-Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name,
+Sequence< CalendarItem2 > &LocaleData::getCalendarItemByName(const OUString& name,
const Locale& rLocale, const Sequence< Calendar2 >& calendarsSeq, sal_Int16 item)
throw(RuntimeException)
{
@@ -517,13 +547,13 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name
}
-Sequence< CalendarItem > LocaleData::getCalendarItems(
+Sequence< CalendarItem2 > LocaleData::getCalendarItems(
sal_Unicode const * const * const allCalendars, sal_Int16 & rnOffset,
const sal_Int16 nWhichItem, const sal_Int16 nCalendar,
const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq )
throw(RuntimeException)
{
- Sequence< CalendarItem > aItems;
+ Sequence< CalendarItem2 > aItems;
if (OUString( allCalendars[rnOffset]).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ref")))
{
aItems = getCalendarItemByName( OUString( allCalendars[rnOffset+1]), rLocale, calendarsSeq, nWhichItem);
@@ -533,12 +563,32 @@ Sequence< CalendarItem > LocaleData::getCalendarItems(
{
sal_Int32 nSize = allCalendars[nWhichItem][nCalendar];
aItems.realloc( nSize);
- CalendarItem* pItem = aItems.getArray();
- for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
+ CalendarItem2* pItem = aItems.getArray();
+ switch (nWhichItem)
{
- CalendarItem day( allCalendars[rnOffset], allCalendars[rnOffset+1], allCalendars[rnOffset+2]);
- *pItem = day;
- rnOffset += 3;
+ case REF_DAYS:
+ case REF_MONTHS:
+ case REF_GMONTHS:
+ for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
+ {
+ CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
+ allCalendars[rnOffset+2], allCalendars[rnOffset+3]);
+ *pItem = item;
+ rnOffset += 4;
+ }
+ break;
+ case REF_ERAS:
+ // Absent narrow name.
+ for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
+ {
+ CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
+ allCalendars[rnOffset+2], OUString());
+ *pItem = item;
+ rnOffset += 3;
+ }
+ break;
+ default:
+ OSL_FAIL( "LocaleData::getCalendarItems: unhandled REF_* case");
}
}
return aItems;
@@ -564,20 +614,20 @@ LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException)
offset++;
sal_Bool defaultCalendar = sal::static_int_cast<sal_Bool>( allCalendars[offset][0] );
offset++;
- Sequence< CalendarItem > days = getCalendarItems( allCalendars, offset, REF_DAYS, i,
+ Sequence< CalendarItem2 > days = getCalendarItems( allCalendars, offset, REF_DAYS, i,
rLocale, calendarsSeq);
- Sequence< CalendarItem > months = getCalendarItems( allCalendars, offset, REF_MONTHS, i,
+ Sequence< CalendarItem2 > months = getCalendarItems( allCalendars, offset, REF_MONTHS, i,
rLocale, calendarsSeq);
- Sequence< CalendarItem > gmonths = getCalendarItems( allCalendars, offset, REF_GMONTHS, i,
+ Sequence< CalendarItem2 > gmonths = getCalendarItems( allCalendars, offset, REF_GMONTHS, i,
rLocale, calendarsSeq);
- Sequence< CalendarItem > eras = getCalendarItems( allCalendars, offset, REF_ERAS, i,
+ Sequence< CalendarItem2 > eras = getCalendarItems( allCalendars, offset, REF_ERAS, i,
rLocale, calendarsSeq);
OUString startOfWeekDay(allCalendars[offset]);
offset++;
sal_Int16 minimalDaysInFirstWeek = allCalendars[offset][0];
offset++;
- Calendar2 aCalendar(days, months, eras, startOfWeekDay,
- minimalDaysInFirstWeek, defaultCalendar, calendarID, gmonths);
+ Calendar2 aCalendar(days, months, gmonths, eras, startOfWeekDay,
+ minimalDaysInFirstWeek, defaultCalendar, calendarID);
calendarsSeq[i] = aCalendar;
}
return calendarsSeq;
@@ -592,14 +642,14 @@ LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException)
Sequence< Calendar > SAL_CALL
LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException)
{
- Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale));
+ const Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale));
sal_Int32 nLen = aCal2.getLength();
Sequence< Calendar > aCal1( nLen);
- const Calendar2* p2 = aCal2.getArray();
+ const Calendar2* p2 = aCal2.getConstArray();
Calendar* p1 = aCal1.getArray();
for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2)
{
- *p1 = *p2;
+ *p1 = downcastCalendar( *p2);
}
return aCal1;
}