summaryrefslogtreecommitdiff
path: root/i18npool/source/calendar
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-11-18 21:26:39 +0100
committerEike Rathke <erack@redhat.com>2011-11-19 16:15:21 +0100
commita7dbdbf820cdc86f5e4f2d9f49ff3aa320890f78 (patch)
tree6a5c8998ecdae2655f0339c3d25be13e03259198 /i18npool/source/calendar
parent19f607d7839c53f0395db64246de3454ebdbcf37 (diff)
implement possessive genitive case month names locale data API
Diffstat (limited to 'i18npool/source/calendar')
-rw-r--r--i18npool/source/calendar/calendarImpl.cxx33
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx33
2 files changed, 56 insertions, 10 deletions
diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx
index 787f0ae150cc..52eea4ff0a44 100644
--- a/i18npool/source/calendar/calendarImpl.cxx
+++ b/i18npool/source/calendar/calendarImpl.cxx
@@ -57,7 +57,7 @@ CalendarImpl::~CalendarImpl()
void SAL_CALL
CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeException)
{
- Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale);
+ Sequence< Calendar2 > xC = LocaleData().getAllCalendars2(rLocale);
for (sal_Int32 i = 0; i < xC.getLength(); i++) {
if (xC[i].Default) {
loadCalendar(xC[i].Name, rLocale);
@@ -70,7 +70,7 @@ CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeExceptio
void SAL_CALL
CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) throw (RuntimeException)
{
- Reference < XExtendedCalendar > xOldCalendar( xCalendar ); // backup
+ Reference < XCalendar3 > xOldCalendar( xCalendar ); // backup
sal_Int32 i;
for (i = 0; i < sal::static_int_cast<sal_Int32>(lookupTable.size()); i++) {
@@ -87,7 +87,7 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr
if ( ! xI.is() ) {
// check if the calendar is defined in localedata, load gregorian calendar service.
- Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale);
+ Sequence< Calendar2 > xC = LocaleData().getAllCalendars2(rLocale);
for (i = 0; i < xC.getLength(); i++) {
if (uniqueID == xC[i].Name) {
xI = xMSF->createInstance(
@@ -98,7 +98,7 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr
}
if ( xI.is() )
- xI->queryInterface(::getCppuType((const Reference< XExtendedCalendar>*)0)) >>= xCalendar;
+ xI->queryInterface(::getCppuType((const Reference< XCalendar3>*)0)) >>= xCalendar;
else
throw ERROR;
@@ -122,6 +122,15 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr
}
}
+Calendar2 SAL_CALL
+CalendarImpl::getLoadedCalendar2() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getLoadedCalendar2();
+ else
+ throw ERROR ;
+}
+
Calendar SAL_CALL
CalendarImpl::getLoadedCalendar() throw(RuntimeException)
{
@@ -134,7 +143,7 @@ CalendarImpl::getLoadedCalendar() throw(RuntimeException)
Sequence< OUString > SAL_CALL
CalendarImpl::getAllCalendars( const Locale& rLocale ) throw(RuntimeException)
{
- Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale);
+ Sequence< Calendar2 > xC = LocaleData().getAllCalendars2(rLocale);
sal_Int32 nLen = xC.getLength();
Sequence< OUString > xSeq( nLen );
for (sal_Int32 i = 0; i < nLen; i++)
@@ -264,6 +273,16 @@ CalendarImpl::getNumberOfDaysInWeek() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL
+CalendarImpl::getDays() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getDays();
+ else
+ throw ERROR ;
+}
+
+
+Sequence< CalendarItem > SAL_CALL
CalendarImpl::getMonths() throw(RuntimeException)
{
if (xCalendar.is())
@@ -274,10 +293,10 @@ CalendarImpl::getMonths() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL
-CalendarImpl::getDays() throw(RuntimeException)
+CalendarImpl::getGenitiveMonths() throw(RuntimeException)
{
if (xCalendar.is())
- return xCalendar->getDays();
+ return xCalendar->getGenitiveMonths();
else
throw ERROR ;
}
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 7c1e15cc995c..21a6b12bad95 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -246,7 +246,7 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star
getValue();
aLocale = rLocale;
- Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale);
+ Sequence< Calendar2 > xC = LocaleData().getAllCalendars2(rLocale);
for (sal_Int32 i = 0; i < xC.getLength(); i++)
{
if (uniqueID == xC[i].Name)
@@ -272,9 +272,16 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star
}
+com::sun::star::i18n::Calendar2 SAL_CALL
+Calendar_gregorian::getLoadedCalendar2() throw(RuntimeException)
+{
+ return aCalendar;
+}
+
com::sun::star::i18n::Calendar SAL_CALL
Calendar_gregorian::getLoadedCalendar() throw(RuntimeException)
{
+ // gets "down-copy-constructed"
return aCalendar;
}
@@ -838,6 +845,8 @@ 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::SHORT_GENITIVE_MONTH_NAME:
+ case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
return CalendarFieldIndex::MONTH;
case CalendarDisplayCode::SHORT_YEAR:
case CalendarDisplayCode::LONG_YEAR:
@@ -899,6 +908,13 @@ Calendar_gregorian::getNumberOfDaysInWeek() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL
+Calendar_gregorian::getDays() throw(RuntimeException)
+{
+ return aCalendar.Days;
+}
+
+
+Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getMonths() throw(RuntimeException)
{
return aCalendar.Months;
@@ -906,11 +922,12 @@ Calendar_gregorian::getMonths() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL
-Calendar_gregorian::getDays() throw(RuntimeException)
+Calendar_gregorian::getGenitiveMonths() throw(RuntimeException)
{
- return aCalendar.Days;
+ return aCalendar.GenitiveMonths;
}
+
OUString SAL_CALL
Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException)
{
@@ -934,6 +951,12 @@ Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_I
else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
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 throw ERROR;
+ break;
case CalendarDisplayIndex::ERA:
if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
@@ -1016,6 +1039,10 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16
return getDisplayName(CalendarDisplayIndex::MONTH, value, 0);
case CalendarDisplayCode::LONG_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::MONTH, value, 1);
+ 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::SHORT_ERA:
return getDisplayName(CalendarDisplayIndex::ERA, value, 0);
case CalendarDisplayCode::LONG_ERA: