From a7dbdbf820cdc86f5e4f2d9f49ff3aa320890f78 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 18 Nov 2011 21:26:39 +0100 Subject: implement possessive genitive case month names locale data API --- i18npool/source/calendar/calendarImpl.cxx | 33 +++++++++++++++++++------ i18npool/source/calendar/calendar_gregorian.cxx | 33 ++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 10 deletions(-) (limited to 'i18npool/source/calendar') 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(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++) @@ -263,6 +272,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) { @@ -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: @@ -898,6 +907,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) { @@ -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: -- cgit