summaryrefslogtreecommitdiff
path: root/i18npool/source/calendar
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2006-10-06 08:09:02 +0000
committerKurt Zenker <kz@openoffice.org>2006-10-06 08:09:02 +0000
commit77185a75e5747dff59898414fdd4a6e9db9e2122 (patch)
tree0e38d8dce80c662069babbdb283955a684bcb5e3 /i18npool/source/calendar
parent97d880ace36b426db092198fc105fa30165cb992 (diff)
INTEGRATION: CWS locales21 (1.29.20); FILE MERGED
2006/09/29 14:54:41 er 1.29.20.3: MSVC likes to have its head banged against a wall 2006/09/28 22:32:26 er 1.29.20.2: RESYNC: (1.29-1.30); FILE MERGED 2006/09/04 16:59:45 er 1.29.20.1: #i68956# propagate FirstDayOfWeek and MinimalDaysInFirstWeek to calendar routines; don't keep aStartOfWeek as duplicated value
Diffstat (limited to 'i18npool/source/calendar')
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx34
1 files changed, 25 insertions, 9 deletions
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index c0c1731a33e2..f88c49189746 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: calendar_gregorian.cxx,v $
*
- * $Revision: 1.30 $
+ * $Revision: 1.31 $
*
- * last change: $Author: obo $ $Date: 2006-09-17 09:15:11 $
+ * last change: $Author: kz $ $Date: 2006-10-06 09:09:02 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -144,14 +144,24 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star
{
aLocale = rLocale;
Sequence< Calendar> xC = LocaleData().getAllCalendars(rLocale);
- for (sal_Int32 i = 0; i < xC.getLength(); i++) {
- if (uniqueID == xC[i].Name) {
+ for (sal_Int32 i = 0; i < xC.getLength(); i++)
+ {
+ if (uniqueID == xC[i].Name)
+ {
aCalendar = xC[i];
+ // setup minimalDaysInFirstWeek
+ setMinimumNumberOfDaysForFirstWeek(
+ aCalendar.MinimumNumberOfDaysForFirstWeek);
// setup first day of week
- for (aStartOfWeek = sal::static_int_cast<sal_Int16>(aCalendar.Days.getLength()-1);
- aStartOfWeek>=0; aStartOfWeek-- )
- if (aCalendar.StartOfWeek == aCalendar.Days[aStartOfWeek].ID)
+ for (sal_Int16 day = sal::static_int_cast<sal_Int16>(
+ aCalendar.Days.getLength()-1); day>=0; day--)
+ {
+ if (aCalendar.StartOfWeek == aCalendar.Days[day].ID)
+ {
+ setFirstDayOfWeek( day);
return;
+ }
+ }
}
}
// Calendar is not for the locale
@@ -566,20 +576,26 @@ static sal_Int32 SAL_CALL DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
sal_Int16 SAL_CALL
Calendar_gregorian::getFirstDayOfWeek() throw(RuntimeException)
{
- return aStartOfWeek;
+ // UCAL_SUNDAY == 1, Weekdays::SUNDAY == 0 => offset -1
+ // Check for underflow just in case we're called "out of sync".
+ return ::std::max( sal::static_int_cast<sal_Int16>(0),
+ sal::static_int_cast<sal_Int16>( static_cast<sal_Int16>(
+ body->getFirstDayOfWeek()) - 1));
}
void SAL_CALL
Calendar_gregorian::setFirstDayOfWeek( sal_Int16 day )
throw(RuntimeException)
{
- aStartOfWeek = day;
+ // Weekdays::SUNDAY == 0, UCAL_SUNDAY == 1 => offset +1
+ body->setFirstDayOfWeek( static_cast<UCalendarDaysOfWeek>( day + 1));
}
void SAL_CALL
Calendar_gregorian::setMinimumNumberOfDaysForFirstWeek( sal_Int16 days ) throw(RuntimeException)
{
aCalendar.MinimumNumberOfDaysForFirstWeek = days;
+ body->setMinimalDaysInFirstWeek( static_cast<uint8_t>( days));
}
sal_Int16 SAL_CALL