Kaydet (Commit) a7dbdbf8 authored tarafından Eike Rathke's avatar Eike Rathke

implement possessive genitive case month names locale data API

üst 19f607d7
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#ifndef _I18N_CALENDARIMPL_HXX_ #ifndef _I18N_CALENDARIMPL_HXX_
#define _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/CalendarDisplayCode.hpp>
#include <com/sun/star/i18n/CalendarFieldIndex.hpp> #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
#include <com/sun/star/i18n/CalendarDisplayIndex.hpp> #include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
...@@ -44,7 +44,7 @@ namespace com { namespace sun { namespace star { namespace i18n { ...@@ -44,7 +44,7 @@ namespace com { namespace sun { namespace star { namespace i18n {
class CalendarImpl : public cppu::WeakImplHelper2 class CalendarImpl : public cppu::WeakImplHelper2
< <
com::sun::star::i18n::XExtendedCalendar, com::sun::star::i18n::XCalendar3,
com::sun::star::lang::XServiceInfo com::sun::star::lang::XServiceInfo
> >
{ {
...@@ -85,6 +85,10 @@ public: ...@@ -85,6 +85,10 @@ public:
// Methods in XExtendedCalendar // Methods in XExtendedCalendar
virtual rtl::OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException); 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 //XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException); 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); virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw(com::sun::star::uno::RuntimeException);
...@@ -92,14 +96,14 @@ public: ...@@ -92,14 +96,14 @@ public:
private: private:
struct lookupTableItem { 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) {} uniqueID(_uniqueID), xCalendar(_xCalendar) {}
rtl::OUString uniqueID; 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; std::vector<lookupTableItem*> lookupTable;
com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF; 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;
}; };
} } } } } } } }
......
...@@ -84,6 +84,10 @@ public: ...@@ -84,6 +84,10 @@ public:
// Methods in XExtendedCalendar // Methods in XExtendedCalendar
virtual rtl::OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException); 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 //XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException); 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); virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw(com::sun::star::uno::RuntimeException);
...@@ -104,7 +108,7 @@ protected: ...@@ -104,7 +108,7 @@ protected:
void getValue() throw(com::sun::star::uno::RuntimeException); void getValue() throw(com::sun::star::uno::RuntimeException);
private: private:
Calendar aCalendar; Calendar2 aCalendar;
/** Submit fieldSetValue array according to fieldSet. */ /** Submit fieldSetValue array according to fieldSet. */
void submitFields() throw(com::sun::star::uno::RuntimeException); void submitFields() throw(com::sun::star::uno::RuntimeException);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <comphelper/processfactory.hxx> #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 #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 ...@@ -74,7 +74,7 @@ inline sal_Bool operator ==(const com::sun::star::lang::Locale& l1, const com::s
class LocaleData : public cppu::WeakImplHelper2 class LocaleData : public cppu::WeakImplHelper2
< <
XLocaleData2, XLocaleData3,
com::sun::star::lang::XServiceInfo com::sun::star::lang::XServiceInfo
> >
{ {
...@@ -84,6 +84,7 @@ public: ...@@ -84,6 +84,7 @@ public:
virtual LanguageCountryInfo SAL_CALL getLanguageCountryInfo( const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException); 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 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< 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< 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); 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 : ...@@ -126,12 +127,12 @@ private :
oslGenericFunction SAL_CALL getFunctionSymbolByName( const rtl::OUString& localeName, const sal_Char* pFunction ); 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 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); 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; rtl::OUString ref_name;
com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > & com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > &
getCalendarItemByName(const rtl::OUString& name, getCalendarItemByName(const rtl::OUString& name,
const com::sun::star::lang::Locale& rLocale, 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 ); sal_Int16 item) throw( com::sun::star::uno::RuntimeException );
/// Helper to obtain a sequence of days, months, gmonths or eras. /// Helper to obtain a sequence of days, months, gmonths or eras.
...@@ -141,7 +142,7 @@ private : ...@@ -141,7 +142,7 @@ private :
const sal_Int16 nWhichItem, const sal_Int16 nWhichItem,
const sal_Int16 nCalendar, const sal_Int16 nCalendar,
const com::sun::star::lang::Locale & rLocale, 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 ); throw( com::sun::star::uno::RuntimeException );
}; };
......
...@@ -57,7 +57,7 @@ CalendarImpl::~CalendarImpl() ...@@ -57,7 +57,7 @@ CalendarImpl::~CalendarImpl()
void SAL_CALL void SAL_CALL
CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeException) 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++) { for (sal_Int32 i = 0; i < xC.getLength(); i++) {
if (xC[i].Default) { if (xC[i].Default) {
loadCalendar(xC[i].Name, rLocale); loadCalendar(xC[i].Name, rLocale);
...@@ -70,7 +70,7 @@ CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeExceptio ...@@ -70,7 +70,7 @@ CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeExceptio
void SAL_CALL void SAL_CALL
CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) throw (RuntimeException) CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) throw (RuntimeException)
{ {
Reference < XExtendedCalendar > xOldCalendar( xCalendar ); // backup Reference < XCalendar3 > xOldCalendar( xCalendar ); // backup
sal_Int32 i; sal_Int32 i;
for (i = 0; i < sal::static_int_cast<sal_Int32>(lookupTable.size()); 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 ...@@ -87,7 +87,7 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr
if ( ! xI.is() ) { if ( ! xI.is() ) {
// check if the calendar is defined in localedata, load gregorian calendar service. // 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++) { for (i = 0; i < xC.getLength(); i++) {
if (uniqueID == xC[i].Name) { if (uniqueID == xC[i].Name) {
xI = xMSF->createInstance( xI = xMSF->createInstance(
...@@ -98,7 +98,7 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr ...@@ -98,7 +98,7 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr
} }
if ( xI.is() ) if ( xI.is() )
xI->queryInterface(::getCppuType((const Reference< XExtendedCalendar>*)0)) >>= xCalendar; xI->queryInterface(::getCppuType((const Reference< XCalendar3>*)0)) >>= xCalendar;
else else
throw ERROR; throw ERROR;
...@@ -122,6 +122,15 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr ...@@ -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 Calendar SAL_CALL
CalendarImpl::getLoadedCalendar() throw(RuntimeException) CalendarImpl::getLoadedCalendar() throw(RuntimeException)
{ {
...@@ -134,7 +143,7 @@ CalendarImpl::getLoadedCalendar() throw(RuntimeException) ...@@ -134,7 +143,7 @@ CalendarImpl::getLoadedCalendar() throw(RuntimeException)
Sequence< OUString > SAL_CALL Sequence< OUString > SAL_CALL
CalendarImpl::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) CalendarImpl::getAllCalendars( const Locale& rLocale ) throw(RuntimeException)
{ {
Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale); Sequence< Calendar2 > xC = LocaleData().getAllCalendars2(rLocale);
sal_Int32 nLen = xC.getLength(); sal_Int32 nLen = xC.getLength();
Sequence< OUString > xSeq( nLen ); Sequence< OUString > xSeq( nLen );
for (sal_Int32 i = 0; i < nLen; i++) for (sal_Int32 i = 0; i < nLen; i++)
...@@ -263,6 +272,16 @@ CalendarImpl::getNumberOfDaysInWeek() throw(RuntimeException) ...@@ -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 Sequence< CalendarItem > SAL_CALL
CalendarImpl::getMonths() throw(RuntimeException) CalendarImpl::getMonths() throw(RuntimeException)
{ {
...@@ -274,10 +293,10 @@ CalendarImpl::getMonths() throw(RuntimeException) ...@@ -274,10 +293,10 @@ CalendarImpl::getMonths() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL Sequence< CalendarItem > SAL_CALL
CalendarImpl::getDays() throw(RuntimeException) CalendarImpl::getGenitiveMonths() throw(RuntimeException)
{ {
if (xCalendar.is()) if (xCalendar.is())
return xCalendar->getDays(); return xCalendar->getGenitiveMonths();
else else
throw ERROR ; throw ERROR ;
} }
......
...@@ -246,7 +246,7 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star ...@@ -246,7 +246,7 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star
getValue(); getValue();
aLocale = rLocale; aLocale = rLocale;
Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale); Sequence< Calendar2 > xC = LocaleData().getAllCalendars2(rLocale);
for (sal_Int32 i = 0; i < xC.getLength(); i++) for (sal_Int32 i = 0; i < xC.getLength(); i++)
{ {
if (uniqueID == xC[i].Name) if (uniqueID == xC[i].Name)
...@@ -272,9 +272,16 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star ...@@ -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 com::sun::star::i18n::Calendar SAL_CALL
Calendar_gregorian::getLoadedCalendar() throw(RuntimeException) Calendar_gregorian::getLoadedCalendar() throw(RuntimeException)
{ {
// gets "down-copy-constructed"
return aCalendar; return aCalendar;
} }
...@@ -838,6 +845,8 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode) ...@@ -838,6 +845,8 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
case CalendarDisplayCode::LONG_MONTH: case CalendarDisplayCode::LONG_MONTH:
case CalendarDisplayCode::SHORT_MONTH_NAME: case CalendarDisplayCode::SHORT_MONTH_NAME:
case CalendarDisplayCode::LONG_MONTH_NAME: case CalendarDisplayCode::LONG_MONTH_NAME:
case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
return CalendarFieldIndex::MONTH; return CalendarFieldIndex::MONTH;
case CalendarDisplayCode::SHORT_YEAR: case CalendarDisplayCode::SHORT_YEAR:
case CalendarDisplayCode::LONG_YEAR: case CalendarDisplayCode::LONG_YEAR:
...@@ -898,6 +907,13 @@ Calendar_gregorian::getNumberOfDaysInWeek() throw(RuntimeException) ...@@ -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 Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getMonths() throw(RuntimeException) Calendar_gregorian::getMonths() throw(RuntimeException)
{ {
...@@ -906,11 +922,12 @@ Calendar_gregorian::getMonths() throw(RuntimeException) ...@@ -906,11 +922,12 @@ Calendar_gregorian::getMonths() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getDays() throw(RuntimeException) Calendar_gregorian::getGenitiveMonths() throw(RuntimeException)
{ {
return aCalendar.Days; return aCalendar.GenitiveMonths;
} }
OUString SAL_CALL OUString SAL_CALL
Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException) 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 ...@@ -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 if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
else throw ERROR; else throw ERROR;
break; 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: case CalendarDisplayIndex::ERA:
if( idx >= aCalendar.Eras.getLength() ) throw ERROR; if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName; if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
...@@ -1016,6 +1039,10 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 ...@@ -1016,6 +1039,10 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16
return getDisplayName(CalendarDisplayIndex::MONTH, value, 0); return getDisplayName(CalendarDisplayIndex::MONTH, value, 0);
case CalendarDisplayCode::LONG_MONTH_NAME: case CalendarDisplayCode::LONG_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::MONTH, value, 1); 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: case CalendarDisplayCode::SHORT_ERA:
return getDisplayName(CalendarDisplayIndex::ERA, value, 0); return getDisplayName(CalendarDisplayIndex::ERA, value, 0);
case CalendarDisplayCode::LONG_ERA: case CalendarDisplayCode::LONG_ERA:
......
...@@ -468,7 +468,7 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName( ...@@ -468,7 +468,7 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName(
#define REF_OFFSET_COUNT 4 #define REF_OFFSET_COUNT 4
Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name, 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) throw(RuntimeException)
{ {
if (!ref_name.equals(name)) { if (!ref_name.equals(name)) {
...@@ -476,11 +476,11 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name ...@@ -476,11 +476,11 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name
OUString language = name.getToken(0, under, index); OUString language = name.getToken(0, under, index);
OUString country = name.getToken(0, under, index); OUString country = name.getToken(0, under, index);
Locale loc(language, country, OUString()); Locale loc(language, country, OUString());
Sequence < Calendar > cals; Sequence < Calendar2 > cals;
if (loc == rLocale) { if (loc == rLocale) {
cals = calendarsSeq; cals = calendarsSeq;
} else { } else {
cals = getAllCalendars(loc); cals = getAllCalendars2(loc);
} }
const OUString& id = name.getToken(0, under, index); const OUString& id = name.getToken(0, under, index);
for (index = 0; index < cals.getLength(); index++) { for (index = 0; index < cals.getLength(); index++) {
...@@ -491,7 +491,7 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name ...@@ -491,7 +491,7 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name
} }
// Referred locale not found, return name for en_US locale. // Referred locale not found, return name for en_US locale.
if (index == cals.getLength()) { if (index == cals.getLength()) {
cals = getAllCalendars( cals = getAllCalendars2(
Locale(OUString(RTL_CONSTASCII_USTRINGPARAM("en")), OUString(RTL_CONSTASCII_USTRINGPARAM("US")), OUString())); Locale(OUString(RTL_CONSTASCII_USTRINGPARAM("en")), OUString(RTL_CONSTASCII_USTRINGPARAM("US")), OUString()));
if (cals.getLength() > 0) if (cals.getLength() > 0)
ref_cal = cals[0]; ref_cal = cals[0];
...@@ -500,14 +500,27 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name ...@@ -500,14 +500,27 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name
} }
ref_name = 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( Sequence< CalendarItem > LocaleData::getCalendarItems(
sal_Unicode const * const * const allCalendars, sal_Int16 & rnOffset, sal_Unicode const * const * const allCalendars, sal_Int16 & rnOffset,
const sal_Int16 nWhichItem, const sal_Int16 nCalendar, const sal_Int16 nWhichItem, const sal_Int16 nCalendar,
const Locale & rLocale, const Sequence< Calendar > & calendarsSeq ) const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq )
throw(RuntimeException) throw(RuntimeException)
{ {
Sequence< CalendarItem > aItems; Sequence< CalendarItem > aItems;
...@@ -532,8 +545,8 @@ Sequence< CalendarItem > LocaleData::getCalendarItems( ...@@ -532,8 +545,8 @@ Sequence< CalendarItem > LocaleData::getCalendarItems(
} }
Sequence< Calendar > SAL_CALL Sequence< Calendar2 > SAL_CALL
LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException)
{ {
sal_Unicode const * const * allCalendars = NULL; sal_Unicode const * const * allCalendars = NULL;
...@@ -544,7 +557,7 @@ LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) ...@@ -544,7 +557,7 @@ LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException)
sal_Int16 calendarsCount = 0; sal_Int16 calendarsCount = 0;
allCalendars = func(calendarsCount); allCalendars = func(calendarsCount);
Sequence< Calendar > calendarsSeq(calendarsCount); Sequence< Calendar2 > calendarsSeq(calendarsCount);
sal_Int16 offset = REF_OFFSET_COUNT; sal_Int16 offset = REF_OFFSET_COUNT;
for(sal_Int16 i = 0; i < calendarsCount; i++) { for(sal_Int16 i = 0; i < calendarsCount; i++) {
OUString calendarID(allCalendars[offset]); OUString calendarID(allCalendars[offset]);
...@@ -563,19 +576,35 @@ LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException) ...@@ -563,19 +576,35 @@ LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException)
offset++; offset++;
sal_Int16 minimalDaysInFirstWeek = allCalendars[offset][0]; sal_Int16 minimalDaysInFirstWeek = allCalendars[offset][0];
offset++; offset++;
Calendar aCalendar(days, months, eras, startOfWeekDay, Calendar2 aCalendar(days, months, eras, startOfWeekDay,
minimalDaysInFirstWeek, defaultCalendar, calendarID); minimalDaysInFirstWeek, defaultCalendar, calendarID, gmonths);
calendarsSeq[i] = aCalendar; calendarsSeq[i] = aCalendar;
} }
return calendarsSeq; return calendarsSeq;
} }
else { else {
Sequence< Calendar > seq1(0); Sequence< Calendar2 > seq1(0);
return seq1; 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 Sequence< Currency2 > SAL_CALL
LocaleData::getAllCurrencies2( const Locale& rLocale ) throw(RuntimeException) LocaleData::getAllCurrencies2( const Locale& rLocale ) throw(RuntimeException)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment