summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-11-22 14:29:35 +0100
committerEike Rathke <erack@redhat.com>2011-11-22 14:52:41 +0100
commit3b5ee26d2c27b9fb8d3836c470832fc81cda721f (patch)
treefae2e2fce03aaf000a18ae253493d50b68f377de /i18npool
parent734bfe16bdfe7c80fa8c0c71d680746353686961 (diff)
added partitive case month names
* Locale data: * nominative (nouns) month names always given in <MonthsOfYear> element * optional genitive case month names in <GenitiveMonths> element, following the <MonthsOfYear> element; if not given take nominative names * optional partitive case month names in <PartitiveMonths> element, following the <GenitiveMonths> element, or following the <MonthsOfYear> element if the <GenitiveMonths> element is not present; if not given take genitive case names, or nominative if genitive names aren't defined * currently known partitive case matters in Finnish locales * Rules for use of nominative / genitive / partitive case month names in number formatter: * no day of month (D or DD) present in format code => MMM or MMMM display nominative month name (noun) * day of month (D or DD) after MMM or MMMM => genitive name * no genitive names defined => nominative names * day of month (D or DD) before MMM or MMMM => partitive name * no partitive names defined => genitive names * no genitive names defined => nominative names
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/calendarImpl.hxx1
-rw-r--r--i18npool/inc/calendar_gregorian.hxx1
-rw-r--r--i18npool/source/calendar/calendarImpl.cxx10
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx23
-rw-r--r--i18npool/source/localedata/LocaleNode.cxx48
-rw-r--r--i18npool/source/localedata/data/locale.dtd12
-rw-r--r--i18npool/source/localedata/localedata.cxx12
7 files changed, 103 insertions, 4 deletions
diff --git a/i18npool/inc/calendarImpl.hxx b/i18npool/inc/calendarImpl.hxx
index da69ef886a5a..c71800619864 100644
--- a/i18npool/inc/calendarImpl.hxx
+++ b/i18npool/inc/calendarImpl.hxx
@@ -90,6 +90,7 @@ public:
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);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getPartitiveMonths2() 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 42d7599d59d6..03e4e8161d93 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -89,6 +89,7 @@ public:
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);
+ virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getPartitiveMonths2() throw(com::sun::star::uno::RuntimeException);
//XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx
index aebc1d5accdc..3c6d10c56260 100644
--- a/i18npool/source/calendar/calendarImpl.cxx
+++ b/i18npool/source/calendar/calendarImpl.cxx
@@ -322,6 +322,16 @@ CalendarImpl::getGenitiveMonths2() throw(RuntimeException)
}
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getPartitiveMonths2() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getPartitiveMonths2();
+ else
+ throw ERROR ;
+}
+
+
sal_Bool SAL_CALL
CalendarImpl::isValid() throw(RuntimeException)
{
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 23e95220b25b..703c847866f6 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -850,6 +850,9 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
+ case CalendarDisplayCode::SHORT_PARTITIVE_MONTH_NAME:
+ case CalendarDisplayCode::LONG_PARTITIVE_MONTH_NAME:
+ case CalendarDisplayCode::NARROW_PARTITIVE_MONTH_NAME:
return CalendarFieldIndex::MONTH;
case CalendarDisplayCode::SHORT_YEAR:
case CalendarDisplayCode::LONG_YEAR:
@@ -945,6 +948,13 @@ Calendar_gregorian::getGenitiveMonths2() throw(RuntimeException)
}
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getPartitiveMonths2() throw(RuntimeException)
+{
+ return aCalendar.PartitiveMonths;
+}
+
+
OUString SAL_CALL
Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException)
{
@@ -977,6 +987,13 @@ Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_I
else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
else throw ERROR;
break;
+ case CalendarDisplayIndex::PARTITIVE_MONTH:
+ if( idx >= aCalendar.PartitiveMonths.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.PartitiveMonths[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.PartitiveMonths[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.PartitiveMonths[idx].NarrowName;
+ else throw ERROR;
+ break;
case CalendarDisplayIndex::ERA:
if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
@@ -1069,6 +1086,12 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16
return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 1);
case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 2);
+ case CalendarDisplayCode::SHORT_PARTITIVE_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::PARTITIVE_MONTH, value, 0);
+ case CalendarDisplayCode::LONG_PARTITIVE_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::PARTITIVE_MONTH, value, 1);
+ case CalendarDisplayCode::NARROW_PARTITIVE_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::PARTITIVE_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 fac4583ad4ec..8d7d1a30c6ed 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -1204,6 +1204,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
sal_Int16 * nbOfDays = new sal_Int16[nbOfCalendars];
sal_Int16 * nbOfMonths = new sal_Int16[nbOfCalendars];
sal_Int16 * nbOfGenitiveMonths = new sal_Int16[nbOfCalendars];
+ sal_Int16 * nbOfPartitiveMonths = new sal_Int16[nbOfCalendars];
sal_Int16 * nbOfEras = new sal_Int16[nbOfCalendars];
sal_Int16 j;
sal_Int16 i;
@@ -1322,6 +1323,42 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
}
++nChild;
+ // Generate partitive Months of Year
+ // Optional, if not present fall back to genitive months, or nominative
+ // months (nouns) if that isn't present either.
+ if (!calNode->getChildAt(nChild)->getName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PartitiveMonths")))
+ --nChild;
+ LocaleNode * partitiveMonthsNode = NULL;
+ ref_name = calNode->getChildAt(nChild)->getAttr().getValueByName("ref");
+ if (ref_name.getLength() > 0 && i > 0) {
+ for (j = 0; j < i; j++) {
+ str = getChildAt(j)->getAttr().getValueByName("unoid");
+ if (str.equals(ref_name))
+ partitiveMonthsNode = getChildAt(j)->getChildAt(1);
+ }
+ }
+ if (ref_name.getLength() > 0 && partitiveMonthsNode == NULL) {
+ of.writeParameter("partitiveMonthRef", OUString(RTL_CONSTASCII_USTRINGPARAM("ref")), i);
+ of.writeParameter("partitiveMonthRefName", ref_name, i);
+ nbOfPartitiveMonths[i] = 0;
+ } else {
+ if (partitiveMonthsNode == NULL)
+ partitiveMonthsNode = calNode -> getChildAt(nChild);
+ nbOfPartitiveMonths[i] = sal::static_int_cast<sal_Int16>( partitiveMonthsNode->getNumberOfChildren() );
+ if (bGregorian && nbOfPartitiveMonths[i] != 12)
+ incErrorInt( "A Gregorian calendar must have 12 partitive months, this one has %d", nbOfPartitiveMonths[i]);
+ elementTag = "partitiveMonth";
+ for (j = 0; j < nbOfPartitiveMonths[i]; j++) {
+ LocaleNode *currNode = partitiveMonthsNode -> getChildAt(j);
+ OUString partitiveMonthID( currNode->getChildAt(0)->getValue());
+ of.writeParameter("partitiveMonthID", partitiveMonthID, i, j);
+ if (j == 0 && bGregorian && !partitiveMonthID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "jan")))
+ incError( "First partitive month of a year of a Gregorian calendar must be <MonthID>jan</MonthID>");
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
+ }
+ }
+ ++nChild;
+
// Generate Era name
LocaleNode * erasNode = NULL;
ref_name = calNode -> getChildAt(nChild) ->getAttr().getValueByName("ref");
@@ -1411,6 +1448,14 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeInt(nbOfGenitiveMonths[i]);
of.writeAsciiString("};\n");
+ of.writeAsciiString("static const sal_Unicode nbOfPartitiveMonths[] = {");
+ for(i = 0; i < nbOfCalendars - 1; i++) {
+ of.writeInt(nbOfPartitiveMonths[i]);
+ of.writeAsciiString(", ");
+ };
+ of.writeInt(nbOfPartitiveMonths[i]);
+ of.writeAsciiString("};\n");
+
of.writeAsciiString("static const sal_Unicode nbOfEras[] = {");
for(i = 0; i < nbOfCalendars - 1; i++) {
of.writeInt(nbOfEras[i]);
@@ -1424,6 +1469,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeAsciiString("\tnbOfDays,\n");
of.writeAsciiString("\tnbOfMonths,\n");
of.writeAsciiString("\tnbOfGenitiveMonths,\n");
+ of.writeAsciiString("\tnbOfPartitiveMonths,\n");
of.writeAsciiString("\tnbOfEras,\n");
for(i = 0; i < nbOfCalendars; i++) {
of.writeAsciiString("\tcalendarID");
@@ -1435,6 +1481,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
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, nbOfPartitiveMonths[i], "partitiveMonth", 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");
@@ -1446,6 +1493,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
delete []nbOfDays;
delete []nbOfMonths;
delete []nbOfGenitiveMonths;
+ delete []nbOfPartitiveMonths;
delete []nbOfEras;
}
diff --git a/i18npool/source/localedata/data/locale.dtd b/i18npool/source/localedata/data/locale.dtd
index ac0cfa739aff..ff88bfdbcf69 100644
--- a/i18npool/source/localedata/data/locale.dtd
+++ b/i18npool/source/localedata/data/locale.dtd
@@ -254,7 +254,7 @@
<!-- At least one Calendar element must be given if the RefLocale mechanism is not used! -->
<!ATTLIST LC_CALENDAR %RefLocale;>
-<!ELEMENT Calendar (DaysOfWeek, MonthsOfYear, GenitiveMonths*, Eras, StartDayOfWeek, MinimalDaysInFirstWeek) >
+<!ELEMENT Calendar (DaysOfWeek, MonthsOfYear, GenitiveMonths*, PartitiveMonths*, Eras, StartDayOfWeek, MinimalDaysInFirstWeek) >
<!ATTLIST Calendar %UNOModule;>
<!-- The unoid of a gregorian calendar MUST be lower case "gregorian",
calendars MUST match the names defined in the OASIS OpenDocument Format
@@ -298,6 +298,16 @@
year, e.g. January in a Gregorian calendar.
-->
+<!ELEMENT PartitiveMonths (Month*)>
+<!-- Partitive case month names, for example in Finnish locales. The
+ element is optional, but if present all Month elements of a Calendar must
+ be given if the RefLocale mechanism is not used! If not present,
+ GenitiveMonths names will be used. -->
+<!ATTLIST PartitiveMonths %RefLocale;>
+<!-- Sequence of months is important, MUST start with the first month of a
+ year, e.g. January in a Gregorian calendar.
+ -->
+
<!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 66a5b9325f02..c759ffe0877b 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -494,8 +494,9 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName(
#define REF_DAYS 0
#define REF_MONTHS 1
#define REF_GMONTHS 2
-#define REF_ERAS 3
-#define REF_OFFSET_COUNT 4
+#define REF_PMONTHS 3
+#define REF_ERAS 4
+#define REF_OFFSET_COUNT 5
Sequence< CalendarItem2 > &LocaleData::getCalendarItemByName(const OUString& name,
const Locale& rLocale, const Sequence< Calendar2 >& calendarsSeq, sal_Int16 item)
@@ -538,6 +539,8 @@ Sequence< CalendarItem2 > &LocaleData::getCalendarItemByName(const OUString& nam
return ref_cal.Months;
case REF_GMONTHS:
return ref_cal.GenitiveMonths;
+ case REF_PMONTHS:
+ return ref_cal.PartitiveMonths;
default:
OSL_FAIL( "LocaleData::getCalendarItemByName: unhandled REF_* case");
// fallthru
@@ -569,6 +572,7 @@ Sequence< CalendarItem2 > LocaleData::getCalendarItems(
case REF_DAYS:
case REF_MONTHS:
case REF_GMONTHS:
+ case REF_PMONTHS:
for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
{
CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
@@ -620,13 +624,15 @@ LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException)
rLocale, calendarsSeq);
Sequence< CalendarItem2 > gmonths = getCalendarItems( allCalendars, offset, REF_GMONTHS, i,
rLocale, calendarsSeq);
+ Sequence< CalendarItem2 > pmonths = getCalendarItems( allCalendars, offset, REF_PMONTHS, i,
+ rLocale, calendarsSeq);
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, gmonths, eras, startOfWeekDay,
+ Calendar2 aCalendar(days, months, gmonths, pmonths, eras, startOfWeekDay,
minimalDaysInFirstWeek, defaultCalendar, calendarID);
calendarsSeq[i] = aCalendar;
}