[Libreoffice-commits] .: 12 commits - basic/source editeng/source i18npool/inc i18npool/source offapi/com offapi/UnoApi_offapi.mk sc/source solenv/bin svl/inc svl/source svtools/source svtools/workben sw/source unotools/inc unotools/source
Eike Rathke
erack at kemper.freedesktop.org
Sat Nov 19 07:15:48 PST 2011
basic/source/runtime/methods1.cxx | 32
editeng/source/editeng/editeng.cxx | 6
i18npool/inc/calendarImpl.hxx | 16
i18npool/inc/calendar_gregorian.hxx | 8
i18npool/inc/localedata.hxx | 25
i18npool/source/calendar/calendarImpl.cxx | 55 -
i18npool/source/calendar/calendar_gregorian.cxx | 63 +
i18npool/source/localedata/LocaleNode.cxx | 198 ++-
i18npool/source/localedata/Makefile | 3
i18npool/source/localedata/data/locale.dtd | 32
i18npool/source/localedata/localedata.cxx | 1195 +++++++++++-----------
offapi/UnoApi_offapi.mk | 4
offapi/com/sun/star/i18n/Calendar2.idl | 92 +
offapi/com/sun/star/i18n/CalendarDisplayCode.idl | 96 +
offapi/com/sun/star/i18n/CalendarDisplayIndex.idl | 23
offapi/com/sun/star/i18n/CalendarItem2.idl | 63 +
offapi/com/sun/star/i18n/LocaleCalendar.idl | 2
offapi/com/sun/star/i18n/LocaleData.idl | 2
offapi/com/sun/star/i18n/XCalendar.idl | 14
offapi/com/sun/star/i18n/XCalendar3.idl | 84 +
offapi/com/sun/star/i18n/XLocaleData.idl | 6
offapi/com/sun/star/i18n/XLocaleData3.idl | 65 +
sc/source/core/tool/userlist.cxx | 4
sc/source/ui/docshell/impex.cxx | 2
solenv/bin/create-ids | 7
svl/inc/svl/zformat.hxx | 9
svl/source/numbers/zforfind.cxx | 43
svl/source/numbers/zforfind.hxx | 2
svl/source/numbers/zformat.cxx | 53
svtools/source/control/calendar.cxx | 7
svtools/workben/svdem.cxx | 4
sw/source/ui/docvw/edtwin.cxx | 2
unotools/inc/unotools/calendarwrapper.hxx | 19
unotools/inc/unotools/localedatawrapper.hxx | 15
unotools/source/i18n/calendarwrapper.cxx | 81 -
unotools/source/i18n/localedatawrapper.cxx | 58 -
36 files changed, 1574 insertions(+), 816 deletions(-)
New commits:
commit 4b030331f725c63bc5ef0f365091179f0e6a78e5
Author: Eike Rathke <erack at redhat.com>
Date: Sat Nov 19 15:51:41 2011 +0100
add narrow (one letter) month names
While introducing Calendar2 and the XCalendar3 interface anyway, as well the
"one letter" narrow month names sometimes needed in calendaring can be added.
These are not always the first capitalized letters of the months in all
locales, and might even not necessarily be just one character.
Introduces a new struct css::i18n::Calendar2 that is not derived from
css::i18n::Calendar because it uses a new struct css::i18n::CalendarItem2 to
hold the NarrowName elements.
In locale data the elements DaysOfMonth, MonthsOfYear and GenitiveMonths now
have an optional element DefaultNarrowName. If not specified, the first
character of DefaultFullName is taken.
LocaleDataWrapper and CalendarWrapper use and return the new Calendar2 and
sequences of CalendarItem2 structs. Application code adapted.
The number formatter now displays narrow month names (genitive if applicable)
for the MMMMM code, previously it displayed the first 16 bit code point of the
full name (not even utf-16 aware).
Narrow day names currently are not used, except in svtools' Calendar control.
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 8802245..64847d3 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -62,7 +62,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/i18n/XCalendar.hpp>
+#include <com/sun/star/i18n/XCalendar3.hpp>
#include <com/sun/star/sheet/XFunctionAccess.hpp>
using namespace comphelper;
@@ -73,15 +73,15 @@ using namespace com::sun::star::i18n;
void unoToSbxValue( SbxVariable* pVar, const Any& aValue );
Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, com::sun::star::beans::Property* pUnoProperty = NULL );
-static Reference< XCalendar > getLocaleCalendar( void )
+static Reference< XCalendar3 > getLocaleCalendar( void )
{
- static Reference< XCalendar > xCalendar;
+ static Reference< XCalendar3 > xCalendar;
if( !xCalendar.is() )
{
Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
if( xSMgr.is() )
{
- xCalendar = Reference< XCalendar >( xSMgr->createInstance
+ xCalendar = Reference< XCalendar3 >( xSMgr->createInstance
( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.LocaleCalendar" )) ), UNO_QUERY );
}
}
@@ -1752,13 +1752,13 @@ RTLFUNC(MonthName)
return;
}
- Reference< XCalendar > xCalendar = getLocaleCalendar();
+ Reference< XCalendar3 > xCalendar = getLocaleCalendar();
if( !xCalendar.is() )
{
StarBASIC::Error( SbERR_INTERNAL_ERROR );
return;
}
- Sequence< CalendarItem > aMonthSeq = xCalendar->getMonths();
+ Sequence< CalendarItem2 > aMonthSeq = xCalendar->getMonths2();
sal_Int32 nMonthCount = aMonthSeq.getLength();
sal_Int16 nVal = rPar.Get(1)->GetInteger();
@@ -1772,8 +1772,8 @@ RTLFUNC(MonthName)
if( nParCount == 3 )
bAbbreviate = rPar.Get(2)->GetBool();
- const CalendarItem* pCalendarItems = aMonthSeq.getConstArray();
- const CalendarItem& rItem = pCalendarItems[nVal - 1];
+ const CalendarItem2* pCalendarItems = aMonthSeq.getConstArray();
+ const CalendarItem2& rItem = pCalendarItems[nVal - 1];
::rtl::OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
rPar.Get(0)->PutString( String(aRetStr) );
@@ -1792,14 +1792,14 @@ RTLFUNC(WeekdayName)
return;
}
- Reference< XCalendar > xCalendar = getLocaleCalendar();
+ Reference< XCalendar3 > xCalendar = getLocaleCalendar();
if( !xCalendar.is() )
{
StarBASIC::Error( SbERR_INTERNAL_ERROR );
return;
}
- Sequence< CalendarItem > aDaySeq = xCalendar->getDays();
+ Sequence< CalendarItem2 > aDaySeq = xCalendar->getDays2();
sal_Int16 nDayCount = (sal_Int16)aDaySeq.getLength();
sal_Int16 nDay = rPar.Get(1)->GetInteger();
sal_Int16 nFirstDay = 0;
@@ -1830,8 +1830,8 @@ RTLFUNC(WeekdayName)
bAbbreviate = pPar2->GetBool();
}
- const CalendarItem* pCalendarItems = aDaySeq.getConstArray();
- const CalendarItem& rItem = pCalendarItems[nDay - 1];
+ const CalendarItem2* pCalendarItems = aDaySeq.getConstArray();
+ const CalendarItem2& rItem = pCalendarItems[nDay - 1];
::rtl::OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
rPar.Get(0)->PutString( String(aRetStr) );
@@ -1860,7 +1860,7 @@ sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam = false, sal_Int16 n
}
if( nFirstDay == 0 )
{
- Reference< XCalendar > xCalendar = getLocaleCalendar();
+ Reference< XCalendar3 > xCalendar = getLocaleCalendar();
if( !xCalendar.is() )
{
StarBASIC::Error( SbERR_INTERNAL_ERROR );
@@ -2189,7 +2189,7 @@ RTLFUNC(DateDiff)
}
if( nFirstDay == 0 )
{
- Reference< XCalendar > xCalendar = getLocaleCalendar();
+ Reference< XCalendar3 > xCalendar = getLocaleCalendar();
if( !xCalendar.is() )
{
StarBASIC::Error( SbERR_INTERNAL_ERROR );
@@ -2249,7 +2249,7 @@ double implGetDateOfFirstDayInFirstWeek
if( nFirstWeek < 0 || nFirstWeek > 3 )
nError = SbERR_BAD_ARGUMENT;
- Reference< XCalendar > xCalendar;
+ Reference< XCalendar3 > xCalendar;
if( nFirstDay == 0 || nFirstWeek == 0 )
{
xCalendar = getLocaleCalendar();
@@ -2453,7 +2453,7 @@ RTLFUNC(FormatDateTime)
}
}
- Reference< XCalendar > xCalendar = getLocaleCalendar();
+ Reference< XCalendar3 > xCalendar = getLocaleCalendar();
if( !xCalendar.is() )
{
StarBASIC::Error( SbERR_INTERNAL_ERROR );
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index b8c563f..cfbf1b8 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1051,9 +1051,9 @@ sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditVie
pImpEditEngine->xTransliterationWrapper.changeLocale( eLang);
const ::utl::TransliterationWrapper* pTransliteration = pImpEditEngine->xTransliterationWrapper.get();
- Sequence< i18n::CalendarItem > xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarDays();
+ Sequence< i18n::CalendarItem2 > xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarDays();
sal_Int32 nCount = xItem.getLength();
- const i18n::CalendarItem* pArr = xItem.getArray();
+ const i18n::CalendarItem2* pArr = xItem.getArray();
for( sal_Int32 n = 0; n <= nCount; ++n )
{
const ::rtl::OUString& rDay = pArr[n].FullName;
@@ -1068,7 +1068,7 @@ sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditVie
{
xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarMonths();
sal_Int32 nMonthCount = xItem.getLength();
- const i18n::CalendarItem* pMonthArr = xItem.getArray();
+ const i18n::CalendarItem2* pMonthArr = xItem.getArray();
for( sal_Int32 n = 0; n <= nMonthCount; ++n )
{
const ::rtl::OUString& rMon = pMonthArr[n].FullName;
diff --git a/i18npool/inc/calendarImpl.hxx b/i18npool/inc/calendarImpl.hxx
index d117e53..da69ef8 100644
--- a/i18npool/inc/calendarImpl.hxx
+++ b/i18npool/inc/calendarImpl.hxx
@@ -87,7 +87,9 @@ public:
// 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);
+ 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);
//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 b95ab22..42d7599 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -86,7 +86,9 @@ public:
// 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);
+ 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);
//XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
diff --git a/i18npool/inc/localedata.hxx b/i18npool/inc/localedata.hxx
index dfdb826..a28f104 100644
--- a/i18npool/inc/localedata.hxx
+++ b/i18npool/inc/localedata.hxx
@@ -74,7 +74,7 @@ inline sal_Bool operator ==(const com::sun::star::lang::Locale& l1, const com::s
class LocaleData : public cppu::WeakImplHelper2
<
- XLocaleData3,
+ com::sun::star::i18n::XLocaleData3,
com::sun::star::lang::XServiceInfo
>
{
@@ -82,6 +82,9 @@ public:
LocaleData();
~LocaleData();
+ static com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > downcastCalendarItems( const com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > & rCi );
+ static com::sun::star::i18n::Calendar downcastCalendar( const com::sun::star::i18n::Calendar2 & rC );
+
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);
@@ -129,14 +132,14 @@ private :
sal_Unicode ** SAL_CALL getIndexArrayForAlgorithm(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rAlgorithm);
com::sun::star::i18n::Calendar2 ref_cal;
rtl::OUString ref_name;
- com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > &
+ com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > &
getCalendarItemByName(const rtl::OUString& name,
const com::sun::star::lang::Locale& rLocale,
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.
- com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem > getCalendarItems(
+ com::sun::star::uno::Sequence< com::sun::star::i18n::CalendarItem2 > getCalendarItems(
sal_Unicode const * const * const allCalendars,
sal_Int16 & rnOffset,
const sal_Int16 nWhichItem,
diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx
index 52eea4f..aebc1d5 100644
--- a/i18npool/source/calendar/calendarImpl.cxx
+++ b/i18npool/source/calendar/calendarImpl.cxx
@@ -292,11 +292,31 @@ CalendarImpl::getMonths() throw(RuntimeException)
}
-Sequence< CalendarItem > SAL_CALL
-CalendarImpl::getGenitiveMonths() throw(RuntimeException)
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getDays2() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getDays2();
+ else
+ throw ERROR ;
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getMonths2() throw(RuntimeException)
+{
+ if (xCalendar.is())
+ return xCalendar->getMonths2();
+ else
+ throw ERROR ;
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+CalendarImpl::getGenitiveMonths2() throw(RuntimeException)
{
if (xCalendar.is())
- return xCalendar->getGenitiveMonths();
+ return xCalendar->getGenitiveMonths2();
else
throw ERROR ;
}
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 21a6b12..23e9522 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -132,6 +132,7 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using ::rtl::OUString;
+
namespace com { namespace sun { namespace star { namespace i18n {
#define ERROR RuntimeException()
@@ -281,8 +282,7 @@ Calendar_gregorian::getLoadedCalendar2() throw(RuntimeException)
com::sun::star::i18n::Calendar SAL_CALL
Calendar_gregorian::getLoadedCalendar() throw(RuntimeException)
{
- // gets "down-copy-constructed"
- return aCalendar;
+ return LocaleData::downcastCalendar( aCalendar);
}
OUString SAL_CALL
@@ -838,6 +838,7 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
return CalendarFieldIndex::DAY_OF_MONTH;
case CalendarDisplayCode::SHORT_DAY_NAME:
case CalendarDisplayCode::LONG_DAY_NAME:
+ case CalendarDisplayCode::NARROW_DAY_NAME:
return CalendarFieldIndex::DAY_OF_WEEK;
case CalendarDisplayCode::SHORT_QUARTER:
case CalendarDisplayCode::LONG_QUARTER:
@@ -845,8 +846,10 @@ 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::NARROW_MONTH_NAME:
case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
+ case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
return CalendarFieldIndex::MONTH;
case CalendarDisplayCode::SHORT_YEAR:
case CalendarDisplayCode::LONG_YEAR:
@@ -910,19 +913,33 @@ Calendar_gregorian::getNumberOfDaysInWeek() throw(RuntimeException)
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getDays() throw(RuntimeException)
{
- return aCalendar.Days;
+ return LocaleData::downcastCalendarItems( aCalendar.Days);
}
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getMonths() throw(RuntimeException)
{
+ return LocaleData::downcastCalendarItems( aCalendar.Months);
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getDays2() throw(RuntimeException)
+{
+ return aCalendar.Days;
+}
+
+
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getMonths2() throw(RuntimeException)
+{
return aCalendar.Months;
}
-Sequence< CalendarItem > SAL_CALL
-Calendar_gregorian::getGenitiveMonths() throw(RuntimeException)
+Sequence< CalendarItem2 > SAL_CALL
+Calendar_gregorian::getGenitiveMonths2() throw(RuntimeException)
{
return aCalendar.GenitiveMonths;
}
@@ -943,18 +960,21 @@ Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_I
if( idx >= aCalendar.Days.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
else throw ERROR;
break;
case CalendarDisplayIndex::MONTH:
if( idx >= aCalendar.Months.getLength() ) throw ERROR;
if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
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 if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
else throw ERROR;
break;
case CalendarDisplayIndex::ERA:
@@ -1035,14 +1055,20 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16
return getDisplayName(CalendarDisplayIndex::DAY, value, 0);
case CalendarDisplayCode::LONG_DAY_NAME:
return getDisplayName(CalendarDisplayIndex::DAY, value, 1);
+ case CalendarDisplayCode::NARROW_DAY_NAME:
+ return getDisplayName(CalendarDisplayIndex::DAY, value, 2);
case CalendarDisplayCode::SHORT_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::MONTH, value, 0);
case CalendarDisplayCode::LONG_MONTH_NAME:
return getDisplayName(CalendarDisplayIndex::MONTH, value, 1);
+ case CalendarDisplayCode::NARROW_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::MONTH, value, 2);
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::NARROW_GENITIVE_MONTH_NAME:
+ return getDisplayName(CalendarDisplayIndex::GENITIVE_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 0dbb770..fac4583 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -1134,6 +1134,64 @@ void LCIndexNode::generateCode (const OFileWriter &of) const
of.writeFunction("getFollowPageWords_", "nbOfPageWords", "FollowPageWordArray");
}
+
+static void lcl_writeAbbrFullNarrNames( const OFileWriter & of, const LocaleNode* currNode,
+ const sal_Char* elementTag, sal_Int16 i, sal_Int16 j )
+{
+ OUString aAbbrName = currNode->getChildAt(1)->getValue();
+ OUString aFullName = currNode->getChildAt(2)->getValue();
+ OUString aNarrName;
+ LocaleNode* p = (currNode->getNumberOfChildren() > 3 ? currNode->getChildAt(3) : 0);
+ if (p && p->getName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DefaultNarrowName")))
+ aNarrName = p->getValue();
+ else
+ {
+ sal_Int32 nIndex = 0;
+ sal_uInt32 nChar = aFullName.iterateCodePoints( &nIndex);
+ aNarrName = OUString( &nChar, 1);
+ }
+ of.writeParameter( elementTag, "DefaultAbbrvName", aAbbrName, i, j);
+ of.writeParameter( elementTag, "DefaultFullName", aFullName, i, j);
+ of.writeParameter( elementTag, "DefaultNarrowName", aNarrName, i, j);
+}
+
+static void lcl_writeTabTagString( const OFileWriter & of, const sal_Char* pTag, const sal_Char* pStr )
+{
+ of.writeAsciiString("\t");
+ of.writeAsciiString( pTag);
+ of.writeAsciiString( pStr);
+}
+
+static void lcl_writeTabTagStringNums( const OFileWriter & of,
+ const sal_Char* pTag, const sal_Char* pStr, sal_Int16 i, sal_Int16 j )
+{
+ lcl_writeTabTagString( of, pTag, pStr);
+ of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
+}
+
+static void lcl_writeAbbrFullNarrArrays( const OFileWriter & of, sal_Int16 nCount,
+ const sal_Char* elementTag, sal_Int16 i, bool bNarrow )
+{
+ if (nCount == 0)
+ {
+ lcl_writeTabTagString( of, elementTag, "Ref");
+ of.writeInt(i); of.writeAsciiString(",\n");
+ lcl_writeTabTagString( of, elementTag, "RefName");
+ of.writeInt(i); of.writeAsciiString(",\n");
+ }
+ else
+ {
+ for (sal_Int16 j = 0; j < nCount; j++)
+ {
+ lcl_writeTabTagStringNums( of, elementTag, "ID", i, j);
+ lcl_writeTabTagStringNums( of, elementTag, "DefaultAbbrvName", i, j);
+ lcl_writeTabTagStringNums( of, elementTag, "DefaultFullName", i, j);
+ if (bNarrow)
+ lcl_writeTabTagStringNums( of, elementTag, "DefaultNarrowName", i, j);
+ }
+ }
+}
+
void LCCalendarNode::generateCode (const OFileWriter &of) const
{
::rtl::OUString useLocale = getAttr().getValueByName("ref");
@@ -1192,8 +1250,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeParameter("dayID", dayID, i, j);
if (j == 0 && bGregorian && !dayID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "sun")))
incError( "First day of a week of a Gregorian calendar must be <DayID>sun</DayID>");
- of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j);
- of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j);
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
}
}
++nChild;
@@ -1225,8 +1282,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeParameter("monthID", monthID, i, j);
if (j == 0 && bGregorian && !monthID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "jan")))
incError( "First month of a year of a Gregorian calendar must be <MonthID>jan</MonthID>");
- of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j);
- of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j);
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
}
}
++nChild;
@@ -1261,8 +1317,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeParameter("genitiveMonthID", genitiveMonthID, i, j);
if (j == 0 && bGregorian && !genitiveMonthID.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "jan")))
incError( "First genitive month of a year of a Gregorian calendar must be <MonthID>jan</MonthID>");
- of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j);
- of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j);
+ lcl_writeAbbrFullNarrNames( of, currNode, elementTag, i, j);
}
}
++nChild;
@@ -1377,56 +1432,10 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
of.writeAsciiString("\tdefaultCalendar");
of.writeInt(i);
of.writeAsciiString(",\n");
- if (nbOfDays[i] == 0) {
- of.writeAsciiString("\tdayRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\tdayRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfDays[i]; j++) {
- of.writeAsciiString("\tdayID");
- of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- of.writeAsciiString("\tdayDefaultAbbrvName");
- of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- of.writeAsciiString("\tdayDefaultFullName");of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- }
- }
- if (nbOfMonths[i] == 0) {
- of.writeAsciiString("\tmonthRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\tmonthRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfMonths[i]; j++) {
- of.writeAsciiString("\tmonthID");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tmonthDefaultAbbrvName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tmonthDefaultFullName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- }
- }
- if (nbOfGenitiveMonths[i] == 0) {
- of.writeAsciiString("\tgenitiveMonthRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\tgenitiveMonthRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfGenitiveMonths[i]; j++) {
- of.writeAsciiString("\tgenitiveMonthID");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tgenitiveMonthDefaultAbbrvName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\tgenitiveMonthDefaultFullName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- }
- }
- if (nbOfEras[i] == 0) {
- of.writeAsciiString("\teraRef");
- of.writeInt(i); of.writeAsciiString(",\n");
- of.writeAsciiString("\teraRefName");
- of.writeInt(i); of.writeAsciiString(",\n");
- } else {
- for(j = 0; j < nbOfEras[i]; j++) {
- of.writeAsciiString("\teraID"); of.writeInt(i); of.writeInt(j); of.writeAsciiString(",\n");
- of.writeAsciiString("\teraDefaultAbbrvName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- of.writeAsciiString("\teraDefaultFullName");of.writeInt(i);of.writeInt(j);of.writeAsciiString(",\n");
- }
- }
+ 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, nbOfEras[i], "era", i, false /*noNarrow*/);
of.writeAsciiString("\tstartDayOfWeek");of.writeInt(i); of.writeAsciiString(",\n");
of.writeAsciiString("\tminimalDaysInFirstWeek");of.writeInt(i); of.writeAsciiString(",\n");
}
diff --git a/i18npool/source/localedata/data/locale.dtd b/i18npool/source/localedata/data/locale.dtd
index 8a0a9e7..ac0cfa7 100644
--- a/i18npool/source/localedata/data/locale.dtd
+++ b/i18npool/source/localedata/data/locale.dtd
@@ -269,13 +269,17 @@
<!-- All Day elements of a Calendar must be given if the RefLocale mechanism is not used! -->
<!ATTLIST DaysOfWeek %RefLocale;>
<!-- Sequence of days is important, MUST start with Sunday. -->
-<!ELEMENT Day (DayID, DefaultAbbrvName, DefaultFullName)>
+<!ELEMENT Day (DayID, DefaultAbbrvName, DefaultFullName, DefaultNarrowName*)>
<!ELEMENT DayID (#PCDATA)>
<!-- Preferably the lower case abbreviated English name like sun for Sunday. -->
<!ELEMENT DefaultAbbrvName (#PCDATA)>
<!-- The abbreviated day name, e.g. Sun for Sunday. -->
<!ELEMENT DefaultFullName (#PCDATA)>
<!-- The full day name, e.g. Sunday for Sunday. -->
+<!ELEMENT DefaultNarrowName (#PCDATA)>
+<!-- The narrow day name, e.g. S for Sunday.
+ If not specified, the first letter of the corresponding DefaultFullName is taken.
+ -->
<!ELEMENT MonthsOfYear (Month*)>
<!-- All Month elements of a Calendar must be given if the RefLocale mechanism is not used! -->
@@ -294,7 +298,7 @@
year, e.g. January in a Gregorian calendar.
-->
-<!ELEMENT Month (MonthID, DefaultAbbrvName, DefaultFullName)>
+<!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 c859da5..9b87de6 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -281,6 +281,36 @@ struct LocaleDataLookupTableItem
}
};
+
+// static
+Sequence< CalendarItem > LocaleData::downcastCalendarItems( const Sequence< CalendarItem2 > & rCi )
+{
+ sal_Int32 nSize = rCi.getLength();
+ Sequence< CalendarItem > aCi( nSize);
+ CalendarItem* p1 = aCi.getArray();
+ const CalendarItem2* p2 = rCi.getConstArray();
+ for (sal_Int32 i=0; i < nSize; ++i, ++p1, ++p2)
+ *p1 = *p2;
+ return aCi;
+}
+
+
+// static
+Calendar LocaleData::downcastCalendar( const Calendar2 & rC )
+{
+ Calendar aCal(
+ downcastCalendarItems( rC.Days),
+ downcastCalendarItems( rC.Months),
+ downcastCalendarItems( rC.Eras),
+ rC.StartOfWeek,
+ rC.MinimumNumberOfDaysForFirstWeek,
+ rC.Default,
+ rC.Name
+ );
+ return aCal;
+}
+
+
LocaleData::LocaleData()
{
}
@@ -467,7 +497,7 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName(
#define REF_ERAS 3
#define REF_OFFSET_COUNT 4
-Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name,
+Sequence< CalendarItem2 > &LocaleData::getCalendarItemByName(const OUString& name,
const Locale& rLocale, const Sequence< Calendar2 >& calendarsSeq, sal_Int16 item)
throw(RuntimeException)
{
@@ -517,13 +547,13 @@ Sequence< CalendarItem > &LocaleData::getCalendarItemByName(const OUString& name
}
-Sequence< CalendarItem > LocaleData::getCalendarItems(
+Sequence< CalendarItem2 > LocaleData::getCalendarItems(
sal_Unicode const * const * const allCalendars, sal_Int16 & rnOffset,
const sal_Int16 nWhichItem, const sal_Int16 nCalendar,
const Locale & rLocale, const Sequence< Calendar2 > & calendarsSeq )
throw(RuntimeException)
{
- Sequence< CalendarItem > aItems;
+ Sequence< CalendarItem2 > aItems;
if (OUString( allCalendars[rnOffset]).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ref")))
{
aItems = getCalendarItemByName( OUString( allCalendars[rnOffset+1]), rLocale, calendarsSeq, nWhichItem);
@@ -533,12 +563,32 @@ Sequence< CalendarItem > LocaleData::getCalendarItems(
{
sal_Int32 nSize = allCalendars[nWhichItem][nCalendar];
aItems.realloc( nSize);
- CalendarItem* pItem = aItems.getArray();
- for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
+ CalendarItem2* pItem = aItems.getArray();
+ switch (nWhichItem)
{
- CalendarItem day( allCalendars[rnOffset], allCalendars[rnOffset+1], allCalendars[rnOffset+2]);
- *pItem = day;
- rnOffset += 3;
+ case REF_DAYS:
+ case REF_MONTHS:
+ case REF_GMONTHS:
+ for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
+ {
+ CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
+ allCalendars[rnOffset+2], allCalendars[rnOffset+3]);
+ *pItem = item;
+ rnOffset += 4;
+ }
+ break;
+ case REF_ERAS:
+ // Absent narrow name.
+ for (sal_Int16 j = 0; j < nSize; ++j, ++pItem)
+ {
+ CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
+ allCalendars[rnOffset+2], OUString());
+ *pItem = item;
+ rnOffset += 3;
+ }
+ break;
+ default:
+ OSL_FAIL( "LocaleData::getCalendarItems: unhandled REF_* case");
}
}
return aItems;
@@ -564,20 +614,20 @@ LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException)
offset++;
sal_Bool defaultCalendar = sal::static_int_cast<sal_Bool>( allCalendars[offset][0] );
offset++;
- Sequence< CalendarItem > days = getCalendarItems( allCalendars, offset, REF_DAYS, i,
+ Sequence< CalendarItem2 > days = getCalendarItems( allCalendars, offset, REF_DAYS, i,
rLocale, calendarsSeq);
- Sequence< CalendarItem > months = getCalendarItems( allCalendars, offset, REF_MONTHS, i,
+ Sequence< CalendarItem2 > months = getCalendarItems( allCalendars, offset, REF_MONTHS, i,
rLocale, calendarsSeq);
- Sequence< CalendarItem > gmonths = getCalendarItems( allCalendars, offset, REF_GMONTHS, i,
+ Sequence< CalendarItem2 > gmonths = getCalendarItems( allCalendars, offset, REF_GMONTHS, i,
rLocale, calendarsSeq);
- Sequence< CalendarItem > eras = getCalendarItems( allCalendars, offset, REF_ERAS, i,
+ 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, eras, startOfWeekDay,
- minimalDaysInFirstWeek, defaultCalendar, calendarID, gmonths);
+ Calendar2 aCalendar(days, months, gmonths, eras, startOfWeekDay,
+ minimalDaysInFirstWeek, defaultCalendar, calendarID);
calendarsSeq[i] = aCalendar;
}
return calendarsSeq;
@@ -592,14 +642,14 @@ LocaleData::getAllCalendars2( const Locale& rLocale ) throw(RuntimeException)
Sequence< Calendar > SAL_CALL
LocaleData::getAllCalendars( const Locale& rLocale ) throw(RuntimeException)
{
- Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale));
+ const Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale));
sal_Int32 nLen = aCal2.getLength();
Sequence< Calendar > aCal1( nLen);
- const Calendar2* p2 = aCal2.getArray();
+ const Calendar2* p2 = aCal2.getConstArray();
Calendar* p1 = aCal1.getArray();
for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2)
{
- *p1 = *p2;
+ *p1 = downcastCalendar( *p2);
}
return aCal1;
}
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 01d8eed..d022429 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2561,6 +2561,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,offapi,offapi/com/sun/star/i18n,\
CalendarDisplayIndex \
CalendarFieldIndex \
CalendarItem \
+ CalendarItem2 \
CharType \
CharacterIteratorMode \
CollatorOptions \
diff --git a/offapi/com/sun/star/i18n/Calendar2.idl b/offapi/com/sun/star/i18n/Calendar2.idl
index 0be7a22..c066678 100644
--- a/offapi/com/sun/star/i18n/Calendar2.idl
+++ b/offapi/com/sun/star/i18n/Calendar2.idl
@@ -29,7 +29,7 @@
#ifndef __com_sun_star_i18n_Calendar2_idl__
#define __com_sun_star_i18n_Calendar2_idl__
-#include <com/sun/star/i18n/Calendar.idl>
+#include <com/sun/star/i18n/CalendarItem2.idl>
//=============================================================================
@@ -41,12 +41,17 @@ module com { module sun { module star { module i18n {
Calendar items as returned in a sequence by
<member>XLocaleData3::getAllCalendars2()</member>.
- <p> Derived from
+ <p> Similar to
<type scope="::com::sun::star::i18n">Calendar</type> this provides
an additional member with a sequence of possessive (genitive case)
month names for locales that use them, for example Slavic locales.
If a locale does not provide the possessive form, the names are
- identical to the nouns in <member>Calendar::Months</member>
+ identical to the nouns in <member>Calendar::Months</member> </p>
+
+ <p> The sequences are of type
+ <type scope="com::sun::star::i18n">CalendarItem2</type> instead of
+ <type scope="com::sun::star::i18n">CalendarItem</type>, with the
+ additional <member>NarrowName</member> member.
@see XLocaleData
for links to DTD of XML locale data files.
@@ -54,12 +59,31 @@ module com { module sun { module star { module i18n {
@since LibreOffice 3.5
*/
-published struct Calendar2 : com::sun::star::i18n::Calendar
+published struct Calendar2
{
- /** the months of the year in possessive genitive case, see also
- <type>CalendarItem</type>.
- */
- sequence< CalendarItem > GenitiveMonths;
+ /// The days of the week.
+ sequence< CalendarItem2 > Days;
+
+ /// The months of the year.
+ sequence< CalendarItem2 > Months;
+
+ /// The months of the year in possessive genitive case.
+ sequence< CalendarItem2 > GenitiveMonths;
+
+ /// The possible eras.
+ sequence< CalendarItem2 > Eras;
+
+ /// The ID of the day with which the week begins.
+ string StartOfWeek;
+
+ /// How many days must reside in the first week of a year.
+ short MinimumNumberOfDaysForFirstWeek;
+
+ /// If this is the default calendar for a given locale.
+ boolean Default;
+
+ /// The name of the calendar, for example, <b>Gregorian</b>.
+ string Name;
};
//=============================================================================
diff --git a/offapi/com/sun/star/i18n/CalendarDisplayCode.idl b/offapi/com/sun/star/i18n/CalendarDisplayCode.idl
index 5f77985..e7ce30c 100644
--- a/offapi/com/sun/star/i18n/CalendarDisplayCode.idl
+++ b/offapi/com/sun/star/i18n/CalendarDisplayCode.idl
@@ -47,51 +47,67 @@ module com { module sun { module star { module i18n {
*/
published constants CalendarDisplayCode
{
- /// Day of month, one or two digits, no leading zero.
- const long SHORT_DAY = 1;
- /// Day of month, two digits, with leading zero.
- const long LONG_DAY = 2;
- /// Day of week, abbreviated name.
- const long SHORT_DAY_NAME = 3;
- /// Day of week, full name.
- const long LONG_DAY_NAME = 4;
-
- /// Month of year, one or two digits, no leading zero.
- const long SHORT_MONTH = 5;
- /// Month of year, with leading zero.
- const long LONG_MONTH = 6;
- /// Full month name.
- const long SHORT_MONTH_NAME = 7;
- /// Abbreviated month name.
- const long LONG_MONTH_NAME = 8;
-
- /// Year, two digits.
- const long SHORT_YEAR = 9;
- /// Year, four digits.
- const long LONG_YEAR = 10;
- /// Full era name, for example, "Before Christ" or "Anno Dominus".
- const long SHORT_ERA = 11;
- /// Abbreviated era name, for example, BC or AD.
- const long LONG_ERA = 12;
- /// Combined short year and era, order depends on locale/calendar.
- const long SHORT_YEAR_AND_ERA = 13;
- /// Combined full year and era, order depends on locale/calendar.
- const long LONG_YEAR_AND_ERA = 14;
-
- /// Short quarter, for example, "Q1"
- const long SHORT_QUARTER = 15;
- /// Long quarter, for example, "1st quarter"
- const long LONG_QUARTER = 16;
+ /// Day of month, one or two digits, no leading zero.
+ const long SHORT_DAY = 1;
+ /// Day of month, two digits, with leading zero.
+ const long LONG_DAY = 2;
+ /// Day of week, abbreviated name.
+ const long SHORT_DAY_NAME = 3;
+ /// Day of week, full name.
+ const long LONG_DAY_NAME = 4;
+
+ /// Month of year, one or two digits, no leading zero.
+ const long SHORT_MONTH = 5;
+ /// Month of year, with leading zero.
+ const long LONG_MONTH = 6;
+ /// Full month name.
+ const long SHORT_MONTH_NAME = 7;
+ /// Abbreviated month name.
+ const long LONG_MONTH_NAME = 8;
+
+ /// Year, two digits.
+ const long SHORT_YEAR = 9;
+ /// Year, four digits.
+ const long LONG_YEAR = 10;
+ /// Full era name, for example, "Before Christ" or "Anno Dominus".
+ const long SHORT_ERA = 11;
+ /// Abbreviated era name, for example, BC or AD.
+ const long LONG_ERA = 12;
+ /// Combined short year and era, order depends on locale/calendar.
+ const long SHORT_YEAR_AND_ERA = 13;
+ /// Combined full year and era, order depends on locale/calendar.
+ const long LONG_YEAR_AND_ERA = 14;
+
+ /// Short quarter, for example, "Q1"
+ const long SHORT_QUARTER = 15;
+ /// Long quarter, for example, "1st quarter"
+ const long LONG_QUARTER = 16;
/** Abbreviated possessive genitive case month name.
@since LibreOffice 3.5
*/
- const long SHORT_GENITIVE_MONTH_NAME = 17;
+ const long SHORT_GENITIVE_MONTH_NAME = 17;
/** Full possessive genitive case month name.
@since LibreOffice 3.5
*/
- const long LONG_GENITIVE_MONTH_NAME = 18;
+ const long LONG_GENITIVE_MONTH_NAME = 18;
+
+ /** Narrow possessive genitive case month name.
+ @since LibreOffice 3.5
+ */
+ const long NARROW_GENITIVE_MONTH_NAME = 19;
+
+ /** Day of week, narrow name.
+ @since LibreOffice 3.5
+ */
+ const long NARROW_DAY_NAME = 20;
+
+ /** Narrow month name.
+ @since LibreOffice 3.5
+ */
+ const long NARROW_MONTH_NAME = 21;
+
};
//=============================================================================
diff --git a/offapi/com/sun/star/i18n/CalendarDisplayIndex.idl b/offapi/com/sun/star/i18n/CalendarDisplayIndex.idl
index 76f17e3..777f9fa 100644
--- a/offapi/com/sun/star/i18n/CalendarDisplayIndex.idl
+++ b/offapi/com/sun/star/i18n/CalendarDisplayIndex.idl
@@ -42,13 +42,13 @@ published constants CalendarDisplayIndex
{
/// name of an AM/PM value
const short AM_PM = 0;
- /// name of a day of week
+ /// name of a day of week
const short DAY = 1;
- /// name of a month
+ /// name of a month
const short MONTH = 2;
- /// name of a year (if used for a specific calendar)
+ /// name of a year (if used for a specific calendar)
const short YEAR = 3;
- /// name of an era, like BC/AD
+ /// name of an era, like BC/AD
const short ERA = 4;
/** name of a possessive genitive case month
diff --git a/offapi/com/sun/star/i18n/CalendarItem2.idl b/offapi/com/sun/star/i18n/CalendarItem2.idl
new file mode 100644
index 0000000..a284441
--- /dev/null
+++ b/offapi/com/sun/star/i18n/CalendarItem2.idl
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Eike Rathke <erack at redhat.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __com_sun_star_i18n_CalendarItem2_idl__
+#define __com_sun_star_i18n_CalendarItem2_idl__
+
+#include <com/sun/star/i18n/CalendarItem.idl>
+
+//=============================================================================
+
+module com { module sun { module star { module i18n {
+
+//=============================================================================
+
+
+/**
+ One entry in a calendar, for example, a day of week or a month or an
+ era.
+
+ <p> Derived from <type scope="com::sun::star::i18n">CalendarItem</type>
+ this provides an additional member for narrow names. </p>
+
+ @since LibreOffice 3.5
+ */
+
+published struct CalendarItem2 : com::sun::star::i18n::CalendarItem
+{
+ /** The narrow name, for example, <b>"S"</b> for Sunday or
+ <b>"J"</b> for January.
+ */
+ string NarrowName;
+};
+
+//=============================================================================
+}; }; }; };
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/i18n/XCalendar.idl b/offapi/com/sun/star/i18n/XCalendar.idl
index 49ab4b6..4dacf04 100644
--- a/offapi/com/sun/star/i18n/XCalendar.idl
+++ b/offapi/com/sun/star/i18n/XCalendar.idl
@@ -209,12 +209,20 @@ published interface XCalendar : com::sun::star::uno::XInterface
@param nNameType
A value indicating whether to return the abbreviated or the
- full name.
+ full name, or the narrow name for some
+ <type>CalendarDisplayIndex</type> values.
<dl>
<dt> 0 </dt>
<dd>abbreviated name, e.g. <b>"Jan"</b></dd>
<dt> 1 </dt>
<dd>full name, e.g. <b>"January"</b></dd>
+ <dt> 2 </dt>
+ <dd>narrow name, e.g. <b>"J"</b> <br>
+ Valid only for <const>CalendarDisplayIndex::DAY</const>,
+ <const>CalendarDisplayIndex::MONTH</const> and
+ <const>CalendarDisplayIndex::GENITIVE_MONTH</const> <br>
+ @since LibreOffice 3.5
+ </dd>
<p> This parameter is not used if the
<em>nCalendarDisplayIndex</em> argument equals
diff --git a/offapi/com/sun/star/i18n/XCalendar3.idl b/offapi/com/sun/star/i18n/XCalendar3.idl
index 8de9550..2ffe25b 100644
--- a/offapi/com/sun/star/i18n/XCalendar3.idl
+++ b/offapi/com/sun/star/i18n/XCalendar3.idl
@@ -46,7 +46,8 @@ module com { module sun { module star { module i18n {
<p> It is derived from
<type scope="::com::sun::star::i18n">XExtendedCalendar</type> and
provides additional methods to obtain <type>Calendar2</type> items
- that include the possessive genitive case month names. </p>
+ that include the possessive genitive case month names and sequences
+ of <type>CalendarItem2</type> items.. </p>
@since LibreOffice 3.5
*/
@@ -57,10 +58,22 @@ published interface XCalendar3 : com::sun::star::i18n::XExtendedCalendar
Calendar2 getLoadedCalendar2();
//------------------------------------------------------------------------
- /** returns a sequence of <type>CalendarItem</type> describing the
+ /** returns a sequence of <type>CalendarItem2</type> describing the
+ day names.
+ */
+ sequence< CalendarItem2 > getDays2();
+
+ //------------------------------------------------------------------------
+ /** returns a sequence of <type>CalendarItem2</type> describing the
+ month names.
+ */
+ sequence< CalendarItem2 > getMonths2();
+
+ //------------------------------------------------------------------------
+ /** returns a sequence of <type>CalendarItem2</type> describing the
genitive case month names.
*/
- sequence< CalendarItem > getGenitiveMonths();
+ sequence< CalendarItem2 > getGenitiveMonths2();
};
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index fed58ca..72e65f7 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -219,7 +219,7 @@ ScUserList::ScUserList()
using namespace ::com::sun::star;
sal_Unicode cDelimiter = ScGlobal::cListDelimiter;
- uno::Sequence< i18n::CalendarItem > xCal;
+ uno::Sequence< i18n::CalendarItem2 > xCal;
uno::Sequence< i18n::Calendar2 > xCalendars(
ScGlobal::pLocaleData->getAllCalendars() );
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index f7eb41a..712f696 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -983,7 +983,7 @@ static bool lcl_PutString(
{
static const String aSeptCorrect( RTL_CONSTASCII_USTRINGPARAM( "SEPT" ) );
static const String aSepShortened( RTL_CONSTASCII_USTRINGPARAM( "SEP" ) );
- uno::Sequence< i18n::CalendarItem > xMonths;
+ uno::Sequence< i18n::CalendarItem2 > xMonths;
sal_Int32 i, nMonthCount;
// first test all month names from local international
xMonths = rCalendar.getMonths();
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index a408633..bb249be 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -2431,7 +2431,7 @@ void ImpSvNumberInputScan::InitText()
delete [] pUpperMonthText;
delete [] pUpperAbbrevMonthText;
- ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > xElems
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > xElems
= pCal->getMonths();
nElems = xElems.getLength();
pUpperMonthText = new String[nElems];
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index e6da610..a56abdc 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -3194,7 +3194,9 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber,
break;
case NF_KEY_MMMMM: // MMMMM
OutString += rCal.getDisplayString(
- CalendarDisplayCode::LONG_MONTH_NAME, nNatNum ).GetChar(0);
+ (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ?
+ CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME :
+ CalendarDisplayCode::NARROW_MONTH_NAME), nNatNum );
break;
case NF_KEY_Q: // Q
OutString += rCal.getDisplayString(
@@ -3521,7 +3523,9 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber,
break;
case NF_KEY_MMMMM: // MMMMM
OutString += rCal.getDisplayString(
- CalendarDisplayCode::LONG_MONTH_NAME, nNatNum ).GetChar(0);
+ (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ?
+ CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME :
+ CalendarDisplayCode::NARROW_MONTH_NAME), nNatNum );
break;
case NF_KEY_Q: // Q
OutString += rCal.getDisplayString(
diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx
index 46101bc..b49c53c 100644
--- a/svtools/source/control/calendar.cxx
+++ b/svtools/source/control/calendar.cxx
@@ -467,12 +467,9 @@ void Calendar::ImplFormat()
sal_Int16 nDay = maCalendarWrapper.getFirstDayOfWeek();
for ( sal_Int16 nDayOfWeek = 0; nDayOfWeek < 7; nDayOfWeek++ )
{
- // Use first character of full name, since the abbreviated name may
- // be roman digits or similar in some locales. Proper
- // implementation would need narrow one letter month names defined
- // in locale data.
+ // Use narrow name.
String aDayOfWeek( maCalendarWrapper.getDisplayName(
- i18n::CalendarDisplayIndex::DAY, nDay, 1).GetChar(0));
+ i18n::CalendarDisplayIndex::DAY, nDay, 2));
long nOffX = (mnDayWidth-GetTextWidth( aDayOfWeek ))/2;
if ( mnWinStyle & WB_BOLDTEXT )
nOffX++;
diff --git a/svtools/workben/svdem.cxx b/svtools/workben/svdem.cxx
index f459ab2..3352e09 100644
--- a/svtools/workben/svdem.cxx
+++ b/svtools/workben/svdem.cxx
@@ -599,8 +599,8 @@ MyCalendar::MyCalendar( Window* pParent ) :
aMenuBar.SetPopupMenu( 1, &aWeekStartMenu );
aMenuBar.SetPopupMenu( 2, &aWeekCountMenu );
sal_Int16 nDays = rCal.getNumberOfDaysInWeek();
- uno::Sequence< i18n::CalendarItem> xItems = rCal.getDays();
- const i18n::CalendarItem* pArr = xItems.getArray();
+ uno::Sequence< i18n::CalendarItem2> xItems = rCal.getDays();
+ const i18n::CalendarItem2* pArr = xItems.getArray();
for ( sal_Int16 i = 0; i < nDays; i++ )
aWeekStartMenu.InsertItem( 10+(sal_uInt16)i, pArr[i].FullName, MIB_AUTOCHECK | MIB_RADIOCHECK );
aWeekStartMenu.CheckItem( 10+(sal_uInt16)rCal.getFirstDayOfWeek() );
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 0bb9dac..78e9a69 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5605,7 +5605,7 @@ void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord )
(*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() );
{
- uno::Sequence< i18n::CalendarItem > aNames(
+ uno::Sequence< i18n::CalendarItem2 > aNames(
(*pCalendar)->getMonths() );
for( int n = 0; n < 2; ++n )
{
diff --git a/unotools/inc/unotools/calendarwrapper.hxx b/unotools/inc/unotools/calendarwrapper.hxx
index e278539..cc67696 100644
--- a/unotools/inc/unotools/calendarwrapper.hxx
+++ b/unotools/inc/unotools/calendarwrapper.hxx
@@ -91,8 +91,6 @@ public:
void setMinimumNumberOfDaysForFirstWeek( sal_Int16 nDays );
sal_Int16 getNumberOfMonthsInYear() const;
sal_Int16 getNumberOfDaysInWeek() const;
- ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getMonths() const;
- ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getDays() const;
String getDisplayName( sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType ) const;
/** Convenience method to get timezone offset in milliseconds, taking both
@@ -110,8 +108,10 @@ public:
// wrapper implementations of XCalendar3
- ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getGenitiveMonths() const;
::com::sun::star::i18n::Calendar2 getLoadedCalendar() const;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDays() const;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getMonths() const;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getGenitiveMonths() const;
// convenience methods
diff --git a/unotools/inc/unotools/localedatawrapper.hxx b/unotools/inc/unotools/localedatawrapper.hxx
index 8564bfa..0bfaa97 100644
--- a/unotools/inc/unotools/localedatawrapper.hxx
+++ b/unotools/inc/unotools/localedatawrapper.hxx
@@ -183,10 +183,10 @@ public:
const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > getDefaultCalendar() const;
/// Convenience method to obtain the day names of the default calendar.
- const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getDefaultCalendarDays() const;
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDefaultCalendarDays() const;
/// Convenience method to obtain the month names of the default calendar.
- const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getDefaultCalendarMonths() const;
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDefaultCalendarMonths() const;
/** Obtain digit grouping. The usually known grouping by thousands (#,###)
is actually only one of possible groupings. Another one, for example,
diff --git a/unotools/source/i18n/calendarwrapper.cxx b/unotools/source/i18n/calendarwrapper.cxx
index 5b7f415..6d7aa4b 100644
--- a/unotools/source/i18n/calendarwrapper.cxx
+++ b/unotools/source/i18n/calendarwrapper.cxx
@@ -503,12 +503,12 @@ sal_Int16 CalendarWrapper::getNumberOfDaysInWeek() const
}
-::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > CalendarWrapper::getMonths() const
+::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > CalendarWrapper::getMonths() const
{
try
{
if ( xC.is() )
- return xC->getMonths();
+ return xC->getMonths2();
}
catch ( Exception& e )
{
@@ -520,16 +520,16 @@ sal_Int16 CalendarWrapper::getNumberOfDaysInWeek() const
(void)e;
#endif
}
- return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > (0);
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > (0);
}
-::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > CalendarWrapper::getDays() const
+::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > CalendarWrapper::getDays() const
{
try
{
if ( xC.is() )
- return xC->getDays();
+ return xC->getDays2();
}
catch ( Exception& e )
{
@@ -541,7 +541,7 @@ sal_Int16 CalendarWrapper::getNumberOfDaysInWeek() const
(void)e;
#endif
}
- return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > (0);
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > (0);
}
@@ -612,12 +612,12 @@ String CalendarWrapper::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_In
}
-::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > CalendarWrapper::getGenitiveMonths() const
+::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > CalendarWrapper::getGenitiveMonths() const
{
try
{
if ( xC.is() )
- return xC->getGenitiveMonths();
+ return xC->getGenitiveMonths2();
}
catch ( Exception& e )
{
@@ -629,7 +629,7 @@ String CalendarWrapper::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_In
(void)e;
#endif
}
- return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > (0);
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > (0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index 81960aa..ee893b2 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -614,13 +614,13 @@ const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > LocaleDataWrapper
}
-const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > LocaleDataWrapper::getDefaultCalendarDays() const
+const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > LocaleDataWrapper::getDefaultCalendarDays() const
{
return getDefaultCalendar()->Days;
}
-const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > LocaleDataWrapper::getDefaultCalendarMonths() const
+const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > LocaleDataWrapper::getDefaultCalendarMonths() const
{
return getDefaultCalendar()->Months;
}
commit 769511019bd5a02a5a2c307c2c8558279742672c
Author: Eike Rathke <erack at redhat.com>
Date: Fri Nov 18 21:26:39 2011 +0100
use possessive genitive case month names in number formatter
* Switching between noun and genitive case month names is very simply done:
* If the format contains a day of month (D or DD) code, genitive case is used.
* If there is no day of month, the month noun is used. For example for
a standalone MMMM code or a combined MMMM-YYYY code.
* For input both, noun and genitive case, forms are recognized.
diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx
index 9ad2895..1ad50d7 100644
--- a/svl/inc/svl/zformat.hxx
+++ b/svl/inc/svl/zformat.hxx
@@ -476,6 +476,15 @@ private:
SVL_DLLPRIVATE bool ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const;
+ /** Whether to use possessive genitive case month name instead of noun.
+ @param io_nState
+ 0: execute check, set to 1 if true is returned, set to 2 if false
+ is returned <br>
+ 1: don't execute check, return true <br>
+ 2: don't execute check, return false <br>
+ */
+ SVL_DLLPRIVATE bool ImpUseGenitiveMonth( int & io_nState, const ImpSvNumFor& rNumFor ) const;
+
#ifdef THE_FUTURE
SVL_DLLPRIVATE bool ImpSwitchToSpecifiedCalendar( String& rOrgCalendar,
double& fOrgDateTime, const ImpSvNumFor& rNumFor ) const;
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 36d6903..a408633 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -84,6 +84,8 @@ ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
:
pUpperMonthText( NULL ),
pUpperAbbrevMonthText( NULL ),
+ pUpperGenitiveMonthText( NULL ),
+ pUpperGenitiveAbbrevMonthText( NULL ),
pUpperDayText( NULL ),
pUpperAbbrevDayText( NULL ),
eScannedType( NUMBERFORMAT_UNDEFINED ),
@@ -106,6 +108,8 @@ ImpSvNumberInputScan::~ImpSvNumberInputScan()
delete pNullDate;
delete [] pUpperMonthText;
delete [] pUpperAbbrevMonthText;
+ delete [] pUpperGenitiveMonthText;
+ delete [] pUpperGenitiveAbbrevMonthText;
delete [] pUpperDayText;
delete [] pUpperAbbrevDayText;
}
@@ -556,14 +560,26 @@ short ImpSvNumberInputScan::GetMonth( const String& rString, xub_StrLen& nPos )
sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
for ( sal_Int16 i = 0; i < nMonths; i++ )
{
- if ( StringContains( pUpperMonthText[i], rString, nPos ) )
- { // full names first
+ if ( StringContains( pUpperGenitiveMonthText[i], rString, nPos ) )
+ { // genitive full names first
+ nPos = nPos + pUpperGenitiveMonthText[i].Len();
+ res = i+1;
+ break; // for
+ }
+ else if ( StringContains( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) )
+ { // genitive abbreviated
+ nPos = nPos + pUpperGenitiveAbbrevMonthText[i].Len();
+ res = sal::static_int_cast< short >(-(i+1)); // negative
+ break; // for
+ }
+ else if ( StringContains( pUpperMonthText[i], rString, nPos ) )
+ { // noun full names
nPos = nPos + pUpperMonthText[i].Len();
res = i+1;
break; // for
}
else if ( StringContains( pUpperAbbrevMonthText[i], rString, nPos ) )
- { // abbreviated
+ { // noun abbreviated
nPos = nPos + pUpperAbbrevMonthText[i].Len();
res = sal::static_int_cast< short >(-(i+1)); // negative
break; // for
@@ -2412,6 +2428,7 @@ void ImpSvNumberInputScan::InitText()
sal_Int32 j, nElems;
const CharClass* pChrCls = pFormatter->GetCharClass();
const CalendarWrapper* pCal = pFormatter->GetCalendar();
+
delete [] pUpperMonthText;
delete [] pUpperAbbrevMonthText;
::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > xElems
@@ -2424,6 +2441,19 @@ void ImpSvNumberInputScan::InitText()
pUpperMonthText[j] = pChrCls->upper( xElems[j].FullName );
pUpperAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
}
+
+ delete [] pUpperGenitiveMonthText;
+ delete [] pUpperGenitiveAbbrevMonthText;
+ xElems = pCal->getGenitiveMonths();
+ nElems = xElems.getLength();
+ pUpperGenitiveMonthText = new String[nElems];
+ pUpperGenitiveAbbrevMonthText = new String[nElems];
+ for ( j=0; j<nElems; j++ )
+ {
+ pUpperGenitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
+ pUpperGenitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
+ }
+
delete [] pUpperDayText;
delete [] pUpperAbbrevDayText;
xElems = pCal->getDays();
@@ -2435,6 +2465,7 @@ void ImpSvNumberInputScan::InitText()
pUpperDayText[j] = pChrCls->upper( xElems[j].FullName );
pUpperAbbrevDayText[j] = pChrCls->upper( xElems[j].AbbrevName );
}
+
bTextInitialized = true;
}
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index 3b9fd9b..158a456 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -73,6 +73,8 @@ private:
SvNumberFormatter* pFormatter;
String* pUpperMonthText; // Array of month names, uppercase
String* pUpperAbbrevMonthText; // Array of month names, abbreviated, uppercase
+ String* pUpperGenitiveMonthText; // Array of genitive month names, uppercase
+ String* pUpperGenitiveAbbrevMonthText; // Array of genitive month names, abbreviated, uppercase
String* pUpperDayText; // Array of day of week names, uppercase
String* pUpperAbbrevDayText; // Array of day of week names, abbreviated, uppercase
String aUpperCurrSymbol; // Currency symbol, uppercase
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 214d89f..e6da610 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2942,6 +2942,33 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber,
return bRes;
}
+
+/** If a day of month occurs within the format, the month name is in possessive
+ genitive case.
+ */
+bool SvNumberformat::ImpUseGenitiveMonth( int & io_nState, const ImpSvNumFor& rNumFor ) const
+{
+ if (io_nState)
+ return io_nState == 1;
+
+ const ImpSvNumberformatInfo& rInfo = rNumFor.Info();
+ const sal_uInt16 nAnz = rNumFor.GetCount();
+ sal_uInt16 i;
+ for ( i = 0; i < nAnz; i++ )
+ {
+ switch ( rInfo.nTypeArray[i] )
+ {
+ case NF_KEY_D :
+ case NF_KEY_DD :
+ io_nState = 1;
+ return true;
+ }
+ }
+ io_nState = 2;
+ return false;
+}
+
+
bool SvNumberformat::ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const
{
if ( GetCal().getUniqueID() != Gregorian::get() )
@@ -3101,6 +3128,7 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber,
double fDiff = DateTime(*(rScan.GetNullDate())) - rCal.getEpochStart();
fNumber += fDiff;
rCal.setLocalDateTime( fNumber );
+ int nUseGenitiveMonth = 0; // not decided yet
String aOrgCalendar; // empty => not changed yet
double fOrgDateTime;
bool bOtherCalendar = ImpIsOtherCalendar( NumFor[nIx] );
@@ -3154,11 +3182,15 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber,
break;
case NF_KEY_MMM: // MMM
OutString += rCal.getDisplayString(
- CalendarDisplayCode::SHORT_MONTH_NAME, nNatNum );
+ (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ?
+ CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME :
+ CalendarDisplayCode::SHORT_MONTH_NAME), nNatNum );
break;
case NF_KEY_MMMM: // MMMM
OutString += rCal.getDisplayString(
- CalendarDisplayCode::LONG_MONTH_NAME, nNatNum );
+ (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ?
+ CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME :
+ CalendarDisplayCode::LONG_MONTH_NAME), nNatNum );
break;
case NF_KEY_MMMMM: // MMMMM
OutString += rCal.getDisplayString(
@@ -3309,6 +3341,7 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber,
}
rCal.setLocalDateTime( fNumber );
+ int nUseGenitiveMonth = 0; // not decided yet
String aOrgCalendar; // empty => not changed yet
double fOrgDateTime;
bool bOtherCalendar = ImpIsOtherCalendar( NumFor[nIx] );
@@ -3476,11 +3509,15 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber,
break;
case NF_KEY_MMM: // MMM
OutString += rCal.getDisplayString(
- CalendarDisplayCode::SHORT_MONTH_NAME, nNatNum );
+ (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ?
+ CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME :
+ CalendarDisplayCode::SHORT_MONTH_NAME), nNatNum );
break;
case NF_KEY_MMMM: // MMMM
OutString += rCal.getDisplayString(
- CalendarDisplayCode::LONG_MONTH_NAME, nNatNum );
+ (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ?
+ CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME :
+ CalendarDisplayCode::LONG_MONTH_NAME), nNatNum );
break;
case NF_KEY_MMMMM: // MMMMM
OutString += rCal.getDisplayString(
commit 29e4c61d9dbcb75a608e090e0703ed996cfa060a
Author: Eike Rathke <erack at redhat.com>
Date: Fri Nov 18 21:26:39 2011 +0100
use new possessive genitive case month names locale data API
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index a7dc091..fed58ca 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -221,7 +221,7 @@ ScUserList::ScUserList()
sal_Unicode cDelimiter = ScGlobal::cListDelimiter;
uno::Sequence< i18n::CalendarItem > xCal;
- uno::Sequence< i18n::Calendar > xCalendars(
+ uno::Sequence< i18n::Calendar2 > xCalendars(
ScGlobal::pLocaleData->getAllCalendars() );
for ( sal_Int32 j = 0; j < xCalendars.getLength(); ++j )
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index f241f79..36d6903 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -58,7 +58,7 @@
#endif
#if NF_TEST_CALENDAR
#include <comphelper/processfactory.hxx>
-#include <com/sun/star/i18n/XExtendedCalendar.hpp>
+#include <com/sun/star/i18n/XCalendar3.hpp>
#endif
@@ -1379,7 +1379,7 @@ input for the following reasons:
sal_Int32 nZoneInMillis, nDST1InMillis, nDST2InMillis;
uno::Reference< lang::XMultiServiceFactory > xSMgr =
::comphelper::getProcessServiceFactory();
- uno::Reference< ::com::sun::star::i18n::XExtendedCalendar > xCal(
+ uno::Reference< ::com::sun::star::i18n::XCalendar3 > xCal(
xSMgr->createInstance( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.i18n.LocaleCalendar" ) ) ),
diff --git a/unotools/inc/unotools/calendarwrapper.hxx b/unotools/inc/unotools/calendarwrapper.hxx
index 7d0ffd3..e278539 100644
--- a/unotools/inc/unotools/calendarwrapper.hxx
+++ b/unotools/inc/unotools/calendarwrapper.hxx
@@ -33,7 +33,7 @@
#include <tools/string.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/i18n/Calendar.hpp>
+#include <com/sun/star/i18n/Calendar2.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include "unotools/unotoolsdllapi.h"
@@ -45,7 +45,7 @@ namespace com { namespace sun { namespace star {
namespace com { namespace sun { namespace star {
namespace i18n {
- class XExtendedCalendar;
+ class XCalendar3;
}
}}}
@@ -53,7 +53,7 @@ namespace com { namespace sun { namespace star {
class UNOTOOLS_DLLPUBLIC CalendarWrapper
{
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
- ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedCalendar > xC;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar3 > xC;
DateTime aEpochStart; // 1Jan1970
@@ -68,7 +68,6 @@ public:
void loadDefaultCalendar( const ::com::sun::star::lang::Locale& rLocale );
void loadCalendar( const ::rtl::OUString& rUniqueID, const ::com::sun::star::lang::Locale& rLocale );
- ::com::sun::star::i18n::Calendar getLoadedCalendar() const;
::com::sun::star::uno::Sequence< ::rtl::OUString > getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const;
::rtl::OUString getUniqueID() const;
/// set UTC date/time
@@ -80,6 +79,7 @@ public:
/// convenience method to get local date/time
double getLocalDateTime() const;
+
// wrapper implementations of XCalendar
void setValue( sal_Int16 nFieldIndex, sal_Int16 nValue );
@@ -102,11 +102,18 @@ public:
fields DST_OFFSET and DST_OFFSET_SECOND_MILLIS into account. */
sal_Int32 getDSTOffsetInMillis() const;
+
// wrapper implementations of XExtendedCalendar
String getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const;
+ // wrapper implementations of XCalendar3
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getGenitiveMonths() const;
+ ::com::sun::star::i18n::Calendar2 getLoadedCalendar() const;
+
+
// convenience methods
/// get epoch start (should be 01Jan1970)
diff --git a/unotools/inc/unotools/localedatawrapper.hxx b/unotools/inc/unotools/localedatawrapper.hxx
index 8ff4e46..8564bfa 100644
--- a/unotools/inc/unotools/localedatawrapper.hxx
+++ b/unotools/inc/unotools/localedatawrapper.hxx
@@ -30,7 +30,7 @@
#define _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <tools/string.hxx>
-#include <com/sun/star/i18n/XLocaleData2.hpp>
+#include <com/sun/star/i18n/XLocaleData3.hpp>
#include <com/sun/star/i18n/LocaleItem.hpp>
#include <com/sun/star/i18n/reservedWords.hpp>
#include <unotools/readwritemutexguard.hxx>
@@ -67,9 +67,9 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper
static sal_uInt8 nLocaleDataChecking; // 0:=dontknow, 1:=yes, 2:=no
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
- ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData2 > xLD;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData3 > xLD;
::com::sun::star::lang::Locale aLocale;
- ::boost::shared_ptr< ::com::sun::star::i18n::Calendar > xDefaultCalendar;
+ ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > xDefaultCalendar;
::com::sun::star::i18n::LocaleDataItem aLocaleDataItem;
::com::sun::star::uno::Sequence< ::rtl::OUString > aReservedWordSeq;
::com::sun::star::uno::Sequence< sal_Int32 > aGrouping;
@@ -153,7 +153,8 @@ public:
::com::sun::star::i18n::LanguageCountryInfo getLanguageCountryInfo() const;
::com::sun::star::i18n::LocaleDataItem getLocaleItem() const;
- ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar > getAllCalendars() const;
+ /// NOTE: this wraps XLocaleData3::getAllCalendars2() in fact.
+ ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 > getAllCalendars() const;
/// NOTE: this wraps XLocaleData2::getAllCurrencies2() in fact.
::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 > getAllCurrencies() const;
::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > getAllFormats() const;
@@ -179,7 +180,7 @@ public:
MeasurementSystem mapMeasurementStringToEnum( const String& rMS ) const;
/// Convenience method to obtain the default calendar.
- const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar > getDefaultCalendar() const;
+ const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > getDefaultCalendar() const;
/// Convenience method to obtain the day names of the default calendar.
const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getDefaultCalendarDays() const;
diff --git a/unotools/source/i18n/calendarwrapper.cxx b/unotools/source/i18n/calendarwrapper.cxx
index 67e6e24..5b7f415 100644
--- a/unotools/source/i18n/calendarwrapper.cxx
+++ b/unotools/source/i18n/calendarwrapper.cxx
@@ -34,7 +34,7 @@
#include <tools/debug.hxx>
#include <instance.hxx>
#include <com/sun/star/i18n/CalendarFieldIndex.hpp>
-#include <com/sun/star/i18n/XExtendedCalendar.hpp>
+#include <com/sun/star/i18n/XCalendar3.hpp>
#define CALENDAR_LIBRARYNAME "i18n"
#define CALENDAR_SERVICENAME "com.sun.star.i18n.LocaleCalendar"
@@ -54,7 +54,7 @@ CalendarWrapper::CalendarWrapper(
xSMgr( xSF ),
aEpochStart( Date( 1, 1, 1970 ) )
{
- xC = Reference< XExtendedCalendar >( intl_createInstance( xSMgr, CALENDAR_SERVICENAME, "CalendarWrapper" ), uno::UNO_QUERY );
+ xC = Reference< XCalendar3 >( intl_createInstance( xSMgr, CALENDAR_SERVICENAME, "CalendarWrapper" ), uno::UNO_QUERY );
}
CalendarWrapper::~CalendarWrapper()
@@ -107,27 +107,6 @@ void CalendarWrapper::loadCalendar( const ::rtl::OUString& rUniqueID, const ::co
}
-::com::sun::star::i18n::Calendar CalendarWrapper::getLoadedCalendar() const
-{
- try
- {
- if ( xC.is() )
- return xC->getLoadedCalendar();
- }
- catch ( Exception& e )
- {
-#ifdef DBG_UTIL
- ByteString aMsg( "getLoadedCalendar: Exception caught\n" );
- aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
- DBG_ERRORFILE( aMsg.GetBuffer() );
-#else
- (void)e;
-#endif
- }
- return ::com::sun::star::i18n::Calendar();
-}
-
-
::com::sun::star::uno::Sequence< ::rtl::OUString > CalendarWrapper::getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const
{
try
@@ -609,4 +588,48 @@ String CalendarWrapper::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_In
return String();
}
+
+// --- XCalendar3 ------------------------------------------------------------
+
+::com::sun::star::i18n::Calendar2 CalendarWrapper::getLoadedCalendar() const
+{
+ try
+ {
+ if ( xC.is() )
+ return xC->getLoadedCalendar2();
+ }
+ catch ( Exception& e )
+ {
+#ifdef DBG_UTIL
+ ByteString aMsg( "getLoadedCalendar2: Exception caught\n" );
+ aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
+ DBG_ERRORFILE( aMsg.GetBuffer() );
+#else
+ (void)e;
+#endif
+ }
+ return ::com::sun::star::i18n::Calendar2();
+}
+
+
+::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > CalendarWrapper::getGenitiveMonths() const
+{
+ try
+ {
+ if ( xC.is() )
+ return xC->getGenitiveMonths();
+ }
+ catch ( Exception& e )
+ {
+#ifdef DBG_UTIL
+ ByteString aMsg( "getGenitiveMonths: Exception caught\n" );
+ aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
+ DBG_ERRORFILE( aMsg.GetBuffer() );
+#else
+ (void)e;
+#endif
+ }
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > (0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index 6bb166f..81960aa 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -84,7 +84,7 @@ LocaleDataWrapper::LocaleDataWrapper(
bReservedWordValid( sal_False )
{
setLocale( rLocale );
- xLD = Reference< XLocaleData2 > (
+ xLD = Reference< XLocaleData3 > (
intl_createInstance( xSMgr, "com.sun.star.i18n.LocaleData",
"LocaleDataWrapper" ), uno::UNO_QUERY );
}
@@ -182,27 +182,6 @@ void LocaleDataWrapper::invalidateData()
}
-::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar > LocaleDataWrapper::getAllCalendars() const
-{
- try
- {
- if ( xLD.is() )
- return xLD->getAllCalendars( getLocale() );
- }
- catch ( Exception& e )
- {
-#ifdef DBG_UTIL
- ByteString aMsg( "getAllCalendars: Exception caught\n" );
- aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
- DBG_ERRORFILE( aMsg.GetBuffer() );
-#else
- (void)e;
-#endif
- }
- return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar >(0);
-}
-
-
::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 > LocaleDataWrapper::getAllCurrencies() const
{
try
@@ -603,12 +582,12 @@ void LocaleDataWrapper::getDefaultCalendarImpl()
{
if (!xDefaultCalendar)
{
- Sequence< Calendar > xCals = getAllCalendars();
+ Sequence< Calendar2 > xCals = getAllCalendars();
sal_Int32 nCount = xCals.getLength();
sal_Int32 nDef = 0;
if (nCount > 1)
{
- const Calendar* pArr = xCals.getArray();
+ const Calendar2* pArr = xCals.getArray();
for (sal_Int32 i=0; i<nCount; ++i)
{
if (pArr[i].Default)
@@ -618,12 +597,12 @@ void LocaleDataWrapper::getDefaultCalendarImpl()
}
}
}
- xDefaultCalendar.reset( new Calendar( xCals[nDef]));
+ xDefaultCalendar.reset( new Calendar2( xCals[nDef]));
}
}
-const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar > LocaleDataWrapper::getDefaultCalendar() const
+const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > LocaleDataWrapper::getDefaultCalendar() const
{
::utl::ReadWriteGuard aGuard( aMutex );
if (!xDefaultCalendar)
@@ -1950,4 +1929,27 @@ void LocaleDataWrapper::evaluateLocaleDataChecking()
}
}
+
+// --- XLocaleData3 ----------------------------------------------------------
+
+::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 > LocaleDataWrapper::getAllCalendars() const
+{
+ try
+ {
+ if ( xLD.is() )
+ return xLD->getAllCalendars2( getLocale() );
+ }
+ catch ( Exception& e )
+ {
+#ifdef DBG_UTIL
+ ByteString aMsg( "getAllCalendars: Exception caught\n" );
+ aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
+ DBG_ERRORFILE( aMsg.GetBuffer() );
+#else
+ (void)e;
+#endif
+ }
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 >(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a7dbdbf820cdc86f5e4f2d9f49ff3aa320890f78
Author: Eike Rathke <erack at redhat.com>
Date: Fri Nov 18 21:26:39 2011 +0100
implement possessive genitive case month names locale data API
diff --git a/i18npool/inc/calendarImpl.hxx b/i18npool/inc/calendarImpl.hxx
index 7923fae..d117e53 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 1f9cdc8..b95ab22 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 55d9a03..dfdb826 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 787f0ae..52eea4f 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 7c1e15c..21a6b12 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 49ded22..c859da5 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
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list