diff options
author | Eike Rathke <erack@redhat.com> | 2011-11-18 21:26:39 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2011-11-19 16:15:21 +0100 |
commit | a7dbdbf820cdc86f5e4f2d9f49ff3aa320890f78 (patch) | |
tree | 6a5c8998ecdae2655f0339c3d25be13e03259198 /i18npool | |
parent | 19f607d7839c53f0395db64246de3454ebdbcf37 (diff) |
implement possessive genitive case month names locale data API
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/inc/calendarImpl.hxx | 14 | ||||
-rw-r--r-- | i18npool/inc/calendar_gregorian.hxx | 6 | ||||
-rw-r--r-- | i18npool/inc/localedata.hxx | 11 | ||||
-rw-r--r-- | i18npool/source/calendar/calendarImpl.cxx | 33 | ||||
-rw-r--r-- | i18npool/source/calendar/calendar_gregorian.cxx | 33 | ||||
-rw-r--r-- | i18npool/source/localedata/localedata.cxx | 53 |
6 files changed, 117 insertions, 33 deletions
diff --git a/i18npool/inc/calendarImpl.hxx b/i18npool/inc/calendarImpl.hxx index 7923faed556f..d117e53a4a83 100644 --- a/i18npool/inc/calendarImpl.hxx +++ b/i18npool/inc/calendarImpl.hxx @@ -28,7 +28,7 @@ #ifndef _I18N_CALENDARIMPL_HXX_ #define _I18N_CALENDARIMPL_HXX_ -#include <com/sun/star/i18n/XExtendedCalendar.hpp> +#include <com/sun/star/i18n/XCalendar3.hpp> #include <com/sun/star/i18n/CalendarDisplayCode.hpp> #include <com/sun/star/i18n/CalendarFieldIndex.hpp> #include <com/sun/star/i18n/CalendarDisplayIndex.hpp> @@ -44,7 +44,7 @@ namespace com { namespace sun { namespace star { namespace i18n { class CalendarImpl : public cppu::WeakImplHelper2 < - com::sun::star::i18n::XExtendedCalendar, + com::sun::star::i18n::XCalendar3, com::sun::star::lang::XServiceInfo > { @@ -85,6 +85,10 @@ public: // Methods in XExtendedCalendar virtual rtl::OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException); + // 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); + //XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw(com::sun::star::uno::RuntimeException); @@ -92,14 +96,14 @@ public: private: struct lookupTableItem { - lookupTableItem(const rtl::OUString& _uniqueID, com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedCalendar >& _xCalendar) : + lookupTableItem(const rtl::OUString& _uniqueID, com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar3 >& _xCalendar) : uniqueID(_uniqueID), xCalendar(_xCalendar) {} rtl::OUString uniqueID; - com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedCalendar > xCalendar; + com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar3 > xCalendar; }; std::vector<lookupTableItem*> lookupTable; com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF; - com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedCalendar > xCalendar; + com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar3 > xCalendar; }; } } } } diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx index 1f9cdc8388cb..b95ab22630fb 100644 --- a/i18npool/inc/calendar_gregorian.hxx +++ b/i18npool/inc/calendar_gregorian.hxx @@ -84,6 +84,10 @@ public: // Methods in XExtendedCalendar virtual rtl::OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException); + // 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); + //XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw(com::sun::star::uno::RuntimeException); @@ -104,7 +108,7 @@ protected: void getValue() throw(com::sun::star::uno::RuntimeException); private: - Calendar aCalendar; + Calendar2 aCalendar; /** Submit fieldSetValue array according to fieldSet. */ void submitFields() throw(com::sun::star::uno::RuntimeException); diff --git a/i18npool/inc/localedata.hxx b/i18npool/inc/localedata.hxx index 55d9a0374a41..dfdb826f12b6 100644 --- a/i18npool/inc/localedata.hxx +++ b/i18npool/inc/localedata.hxx @@ -32,7 +32,7 @@ #include <comphelper/processfactory.hxx> -#include <com/sun/star/i18n/XLocaleData2.hpp> +#include <com/sun/star/i18n/XLocaleData3.hpp> #include <cppuhelper/implbase2.hxx> // helper for implementations @@ -74,7 +74,7 @@ inline sal_Bool operator ==(const com::sun::star::lang::Locale& l1, const com::s class LocaleData : public cppu::WeakImplHelper2 < - XLocaleData2, + XLocaleData3, com::sun::star::lang::XServiceInfo > { @@ -84,6 +84,7 @@ public: 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); virtual com::sun::star::uno::Sequence< Calendar > SAL_CALL getAllCalendars( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); virtual com::sun::star::uno::Sequence< Currency > SAL_CALL getAllCurrencies( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); virtual com::sun::star::uno::Sequence< Currency2 > SAL_CALL getAllCurrencies2( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); @@ -126,12 +127,12 @@ private : oslGenericFunction SAL_CALL getFunctionSymbolByName( const rtl::OUString& localeName, const sal_Char* pFunction ); sal_Unicode ** SAL_CALL getIndexArray(const com::sun::star::lang::Locale& rLocale, sal_Int16& indexCount); sal_Unicode ** SAL_CALL getIndexArrayForAlgorithm(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rAlgorithm); - com::sun::star::i18n::Calendar ref_cal; + com::sun::star::i18n::Calendar2 ref_cal; rtl::OUString ref_name; com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > & getCalendarItemByName(const rtl::OUString& name, const com::sun::star::lang::Locale& rLocale, - const com::sun::star::uno::Sequence< com::sun::star::i18n::Calendar >& calendarsSeq, + 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. @@ -141,7 +142,7 @@ private : const sal_Int16 nWhichItem, const sal_Int16 nCalendar, const com::sun::star::lang::Locale & rLocale, - const com::sun::star::uno::Sequence< com::sun::star::i18n::Calendar > & calendarsSeq ) + const com::sun::star::uno::Sequence< com::sun::star::i18n::Calendar2 > & calendarsSeq ) throw( com::sun::star::uno::RuntimeException ); }; 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: diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 49ded2295a65..c859da5c3cb7 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -468,7 +468,7 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName( #define REF_OFFSET_COUNT 4 Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name, - const Locale& rLocale, const Sequence< Calendar >& calendarsSeq, sal_Int16 item) + const Locale& rLocale, const Sequence< Calendar2 >& calendarsSeq, sal_Int16 item) throw(RuntimeException) { if (!ref_name.equals(name)) { @@ -476,11 +476,11 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name OUString language = name.getToken(0, under, index); OUString country = name.getToken(0, under, index); Locale loc(language, country, OUString()); - Sequence < Calendar > cals; + Sequence < Calendar2 > cals; if (loc == rLocale) { cals = calendarsSeq; } else { - cals = getAllCalendars(loc); + cals = getAllCalendars2(loc); } const OUString& id = name.getToken(0, under, index); for (index = 0; index < cals.getLength(); index++) { @@ -491,7 +491,7 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name } // Referred locale not found, return name for en_US locale. if (index == cals.getLength()) { - cals = getAllCalendars( + cals = getAllCalendars2( Locale(OUString(RTL_CONSTASCII_USTRINGPARAM("en")), OUString(RTL_CONSTASCII_USTRINGPARAM("US")), OUString())); if (cals.getLength() > 0) ref_cal = cals[0]; @@ -500,14 +500,27 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name } ref_name = name; } - return item == REF_DAYS ? ref_cal.Days : item == REF_MONTHS ? ref_cal.Months : ref_cal.Eras; + switch (item) + { + case REF_DAYS: + return ref_cal.Days; + case REF_MONTHS: + return ref_cal.Months; + case REF_GMONTHS: + return ref_cal.GenitiveMonths; + default: + OSL_FAIL( "LocaleData::getCalendarItemByName: unhandled REF_* case"); + // fallthru + case REF_ERAS: + return ref_cal.Eras; + } } Sequence< CalendarItem > LocaleData::getCalendarItems( sal_Unicode const * const * const allCalendars, sal_Int16 & rnOffset, const sal_Int16 nWhichItem, const sal_Int16 nCalendar, - const Locale & rLocale, const Sequence< Calendar > & calendarsSeq ) + const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq ) throw(RuntimeException) { Sequence< CalendarItem > aItems; @@ -532,8 +545,8 @@ Sequence< CalendarItem > LocaleData::getCalendarItems( } -Sequence< Calendar > SAL_CALL -LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) +Sequence< Calendar2 > SAL_CALL +LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException) { sal_Unicode const * const * allCalendars = NULL; @@ -544,7 +557,7 @@ LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) sal_Int16 calendarsCount = 0; allCalendars = func(calendarsCount); - Sequence< Calendar > calendarsSeq(calendarsCount); + Sequence< Calendar2 > calendarsSeq(calendarsCount); sal_Int16 offset = REF_OFFSET_COUNT; for(sal_Int16 i = 0; i < calendarsCount; i++) { OUString calendarID(allCalendars[offset]); @@ -563,19 +576,35 @@ LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) offset++; sal_Int16 minimalDaysInFirstWeek = allCalendars[offset][0]; offset++; - Calendar aCalendar(days, months, eras, startOfWeekDay, - minimalDaysInFirstWeek, defaultCalendar, calendarID); + Calendar2 aCalendar(days, months, eras, startOfWeekDay, + minimalDaysInFirstWeek, defaultCalendar, calendarID, gmonths); calendarsSeq[i] = aCalendar; } return calendarsSeq; } else { - Sequence< Calendar > seq1(0); + Sequence< Calendar2 > seq1(0); return seq1; } } +Sequence< Calendar > SAL_CALL +LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) +{ + Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale)); + sal_Int32 nLen = aCal2.getLength(); + Sequence< Calendar > aCal1( nLen); + const Calendar2* p2 = aCal2.getArray(); + Calendar* p1 = aCal1.getArray(); + for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2) + { + *p1 = *p2; + } + return aCal1; +} + + Sequence< Currency2 > SAL_CALL LocaleData::getAllCurrencies2( const Locale& rLocale ) throw(RuntimeException) { |