LibreOffice Module i18npool (master) 1
calendar_gregorian.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <algorithm>
21
23#include <localedata.hxx>
25#include <com/sun/star/i18n/CalendarDisplayCode.hpp>
26#include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
27#include <com/sun/star/i18n/NativeNumberMode.hpp>
28#include <com/sun/star/i18n/reservedWords.hpp>
30#include <rtl/math.hxx>
31#include <sal/log.hxx>
32
33#include <stdio.h>
34#include <string.h>
35
36#define erDUMP_ICU_CALENDAR 0
37#define erDUMP_I18N_CALENDAR 0
38#if erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR
39// If both are used, DUMP_ICU_CAL_MSG() must be used before DUMP_I18N_CAL_MSG()
40// to obtain internally set values from ICU, else Calendar::get() calls in
41// DUMP_I18N_CAL_MSG() recalculate!
42
43// These pieces of macro are shamelessly borrowed from icu's olsontz.cpp, the
44// double parens'ed approach to pass multiple parameters as one macro parameter
45// is appealing.
46static void debug_cal_loc(const char *f, int32_t l)
47{
48 fprintf(stderr, "%s:%d: ", f, l);
49}
50# include <stdarg.h>
51static void debug_cal_msg(const char *pat, ...)
52{
53 va_list ap;
54 va_start(ap, pat);
55 vfprintf(stderr, pat, ap);
56 va_end(ap);
57}
58
59#if erDUMP_ICU_CALENDAR
60// Make icu with
61// DEFS = -DU_DEBUG_CALSVC -DUCAL_DEBUG_DUMP
62// in workdir/UnpackedTarball/icu/source/icudefs.mk
63// May need some patches to fix unmaintained things there.
64extern void ucal_dump( const icu::Calendar & );
65static void debug_icu_cal_dump( const ::icu::Calendar & r )
66{
67 ucal_dump(r);
68 fflush(stderr);
69 // set a breakpoint here to pause display between dumps
70}
71// must use double parens, i.e.: DUMP_ICU_CAL_MSG(("four is: %d",4));
72#define DUMP_ICU_CAL_MSG(x) {debug_cal_loc(__FILE__,__LINE__);debug_cal_msg x;debug_icu_cal_dump(*body);}
73#else // erDUMP_ICU_CALENDAR
74#define DUMP_ICU_CAL_MSG(x)
75#endif // erDUMP_ICU_CALENDAR
76
77#if erDUMP_I18N_CALENDAR
78static void debug_cal_millis_to_time( long nMillis, long & h, long & m, long & s, long & f )
79{
80 int sign = (nMillis < 0 ? -1 : 1);
81 nMillis = ::std::abs(nMillis);
82 h = sign * nMillis / (60 * 60 * 1000);
83 nMillis -= sign * h * (60 * 60 * 1000);
84 m = nMillis / (60 * 1000);
85 nMillis -= m * (60 * 1000);
86 s = nMillis / (1000);
87 nMillis -= s * (1000);
88 f = nMillis;
89}
90static void debug_i18n_cal_dump( const ::icu::Calendar & r )
91{
92 UErrorCode status;
93 long nMillis, h, m, s, f;
94 fprintf( stderr, " %04ld", (long)r.get( UCAL_YEAR, status = U_ZERO_ERROR));
95 fprintf( stderr, "-%02ld", (long)r.get( UCAL_MONTH, status = U_ZERO_ERROR)+1);
96 fprintf( stderr, "-%02ld", (long)r.get( UCAL_DATE, status = U_ZERO_ERROR));
97 fprintf( stderr, " %02ld", (long)r.get( UCAL_HOUR_OF_DAY, status = U_ZERO_ERROR));
98 fprintf( stderr, ":%02ld", (long)r.get( UCAL_MINUTE, status = U_ZERO_ERROR));
99 fprintf( stderr, ":%02ld", (long)r.get( UCAL_SECOND, status = U_ZERO_ERROR));
100 fprintf( stderr, " zone: %ld", (long)(nMillis = r.get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR)));
101 fprintf( stderr, " (%f min)", (double)nMillis / 60000);
102 debug_cal_millis_to_time( nMillis, h, m, s, f);
103 fprintf( stderr, " (%ld:%02ld:%02ld.%ld)", h, m, s, f);
104 fprintf( stderr, " DST: %ld", (long)(nMillis = r.get( UCAL_DST_OFFSET, status = U_ZERO_ERROR)));
105 fprintf( stderr, " (%f min)", (double)nMillis / 60000);
106 debug_cal_millis_to_time( nMillis, h, m, s, f);
107 fprintf( stderr, " (%ld:%02ld:%02ld.%ld)", h, m, s, f);
108 fprintf( stderr, "\n");
109 fflush(stderr);
110}
111// must use double parens, i.e.: DUMP_I18N_CAL_MSG(("four is: %d",4));
112#define DUMP_I18N_CAL_MSG(x) {debug_cal_loc(__FILE__,__LINE__);debug_cal_msg x;debug_i18n_cal_dump(*body);}
113#else // erDUMP_I18N_CALENDAR
114#define DUMP_I18N_CAL_MSG(x)
115#endif // erDUMP_I18N_CALENDAR
116
117#else // erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR
118#define DUMP_ICU_CAL_MSG(x)
119#define DUMP_I18N_CAL_MSG(x)
120#endif // erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR
121
122
123using namespace ::com::sun::star::uno;
124using namespace ::com::sun::star::i18n;
125using namespace ::com::sun::star::lang;
126
127
128namespace i18npool {
129
130// Cast positive int32 values to signed int16, needed for
131// fieldValue[CalendarFieldIndex::YEAR] where absolute value of an era year may
132// be 32768 that with static_cast<sal_Int16> becomes -32768, which we also
133// do here but indicating places in a controlled way to map back.
134static inline sal_Int16 cast32To16( sal_Int32 a )
135{
136 // More than uint16 can't be handled, should not occur.
137 assert(a >= 0 && a < static_cast<sal_Int32>(SAL_MAX_INT16) - static_cast<sal_Int32>(SAL_MIN_INT16));
138 return static_cast<sal_Int16>(a);
139}
140// And back.
141static inline sal_Int32 cast16To32( sal_Int16 i )
142{
143 return static_cast<sal_Int32>(static_cast<sal_uInt16>(i));
144}
145
147 : mxNatNum(new NativeNumberSupplierService)
148{
149 init(nullptr);
150}
152 : mxNatNum(new NativeNumberSupplierService)
153{
154 init(_earArray);
155}
156void
158{
159 cCalendar = "com.sun.star.i18n.Calendar_gregorian";
160
161 fieldSet = 0;
162
163 // #i102356# With icu::Calendar::createInstance(UErrorCode) in a Thai
164 // th_TH system locale we accidentally used a Buddhist calendar. Though
165 // the ICU documentation says that should be the case only for
166 // th_TH_TRADITIONAL (and ja_JP_TRADITIONAL Gengou), a plain th_TH
167 // already triggers that behavior, ja_JP does not. Strange enough,
168 // passing a th_TH locale to the calendar creation doesn't trigger
169 // this.
170 // See also http://userguide.icu-project.org/datetime/calendar
171
172 // Whatever ICU offers as the default calendar for a locale, ensure we
173 // have a Gregorian calendar as requested.
174
175 /* XXX: with the current implementation the aLocale member variable is
176 * not set prior to loading a calendar from locale data. This
177 * creates an empty (root) locale for ICU, but at least the correct
178 * calendar is used. The language part must not be NULL (respectively
179 * not all, language and country and variant), otherwise the current
180 * default locale would be used again and the calendar keyword ignored.
181 * */
182 icu::Locale aIcuLocale( "", nullptr, nullptr, "calendar=gregorian");
183
184 /* XXX: not specifying a timezone when creating a calendar assigns the
185 * system's timezone with all DST quirks, invalid times when switching
186 * to/from DST and so on. The XCalendar* interfaces are defined to support
187 * local time and UTC time so we can not override that here.
188 */
189 UErrorCode status = U_ZERO_ERROR;
190 body.reset( icu::Calendar::createInstance( aIcuLocale, status) );
191 if (!body || !U_SUCCESS(status)) throw RuntimeException();
192 eraArray=_eraArray;
193}
194
196{
197}
198
200{
201 cCalendar = "com.sun.star.i18n.Calendar_hanja";
202}
203
204OUString SAL_CALL
205Calendar_hanja::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType )
206{
207 if ( displayIndex == CalendarDisplayIndex::AM_PM ) {
208 // Am/Pm string for Korean Hanja calendar will refer to Japanese locale
209 css::lang::Locale jaLocale("ja", OUString(), OUString());
210 if (idx == 0) return LocaleDataImpl::get()->getLocaleItem(jaLocale).timeAM;
211 else if (idx == 1) return LocaleDataImpl::get()->getLocaleItem(jaLocale).timePM;
212 else throw RuntimeException();
213 }
214 else
215 return Calendar_gregorian::getDisplayName( displayIndex, idx, nameType );
216}
217
218
220{
221 cCalendar = "com.sun.star.i18n.Calendar_Calendar_hanja_yoil";
222}
223
224OUString SAL_CALL
225Calendar_hanja_yoil::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType )
226{
227 if ( displayIndex == CalendarDisplayIndex::AM_PM ) {
228 // Am/Pm string for Korean Hanja calendar will refer to Japanese locale
229 css::lang::Locale jaLocale("ja", OUString(), OUString());
230 if (idx == 0) return LocaleDataImpl::get()->getLocaleItem(jaLocale).timeAM;
231 else if (idx == 1) return LocaleDataImpl::get()->getLocaleItem(jaLocale).timePM;
232 else throw RuntimeException();
233 }
234 else
235 return Calendar_gregorian::getDisplayName( displayIndex, idx, nameType );
236}
237
238
240 {1868, 1, 1, 0}, // Meiji
241 {1912, 7, 30, 0}, // Taisho
242 {1926, 12, 25, 0}, // Showa
243 {1989, 1, 8, 0}, // Heisei
244 {2019, 5, 1, 0}, // Reiwa
245 {0, 0, 0, 0}
246};
248{
249 cCalendar = "com.sun.star.i18n.Calendar_gengou";
250}
251
252const Era ROC_eraArray[] = {
253 {1912, 1, 1, kDisplayEraForcedLongYear}, // #i116701#
254 {0, 0, 0, 0}
255};
257{
258 cCalendar = "com.sun.star.i18n.Calendar_ROC";
259}
260
266 {-2332, 1, 1, 0},
267 {0, 0, 0, 0}
268};
270{
271 cCalendar = "com.sun.star.i18n.Calendar_dangi";
272}
273
275 {-542, 1, 1, 0},
276 {0, 0, 0, 0}
277};
279{
280 cCalendar = "com.sun.star.i18n.Calendar_buddhist";
281}
282
283void SAL_CALL
284Calendar_gregorian::loadCalendar( const OUString& uniqueID, const css::lang::Locale& rLocale )
285{
286 // init. fieldValue[]
287 getValue();
288
289 aLocale = rLocale;
290 const Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale);
291 for (const auto& rCal : xC)
292 {
293 if (uniqueID == rCal.Name)
294 {
295 aCalendar = rCal;
296 // setup minimalDaysInFirstWeek
298 aCalendar.MinimumNumberOfDaysForFirstWeek);
299 // setup first day of week
300 for (sal_Int16 day = sal::static_int_cast<sal_Int16>(
301 aCalendar.Days.getLength()-1); day>=0; day--)
302 {
303 if (aCalendar.StartOfWeek == aCalendar.Days[day].ID)
304 {
306 return;
307 }
308 }
309 }
310 }
311 // Calendar is not for the locale
312 throw RuntimeException();
313}
314
315
316css::i18n::Calendar2 SAL_CALL
318{
319 return aCalendar;
320}
321
322css::i18n::Calendar SAL_CALL
324{
326}
327
328OUString SAL_CALL
330{
331 return aCalendar.Name;
332}
333
334void SAL_CALL
336{
337 // ICU handles dates in milliseconds as double values and uses floor()
338 // to obtain integer values, which may yield a date decremented by one
339 // for odd (historical) timezone values where the computed value due to
340 // rounding errors has a fractional part in milliseconds. Ensure we
341 // pass a value without fraction here. If not, that may lead to
342 // fdo#44286 or fdo#52619 and the like, e.g. when passing
343 // -2136315212000.000244 instead of -2136315212000.000000
344 double fM = fTimeInDays * U_MILLIS_PER_DAY;
345 double fR = rtl::math::round( fM );
346 SAL_INFO_IF( fM != fR, "i18npool",
347 "Calendar_gregorian::setDateTime: " << std::fixed << fM << " rounded to " << fR);
348 UErrorCode status = U_ZERO_ERROR;
349 body->setTime( fR, status);
350 if ( !U_SUCCESS(status) ) throw RuntimeException();
351 getValue();
352}
353
354double SAL_CALL
356{
357 if (fieldSet) {
358 setValue();
359 getValue();
360 }
361 UErrorCode status = U_ZERO_ERROR;
362 double fR = body->getTime(status);
363 if ( !U_SUCCESS(status) ) throw RuntimeException();
364 return fR / U_MILLIS_PER_DAY;
365}
366
367void SAL_CALL
369{
370 // See setDateTime() for why the rounding.
371 double fM = fTimeInDays * U_MILLIS_PER_DAY;
372 double fR = rtl::math::round( fM );
373 SAL_INFO_IF( fM != fR, "i18npool",
374 "Calendar_gregorian::setLocalDateTime: " << std::fixed << fM << " rounded to " << fR);
375 int32_t nZoneOffset, nDSTOffset;
376 UErrorCode status = U_ZERO_ERROR;
377 body->getTimeZone().getOffset( fR, true, nZoneOffset, nDSTOffset, status );
378
379 if ( !U_SUCCESS(status) ) throw RuntimeException();
380 status = U_ZERO_ERROR;
381 body->setTime( fR - (nZoneOffset + nDSTOffset), status );
382 if ( !U_SUCCESS(status) ) throw RuntimeException();
383 getValue();
384}
385
386double SAL_CALL
388{
389 if (fieldSet) {
390 setValue();
391 getValue();
392 }
393 UErrorCode status = U_ZERO_ERROR;
394 double fTime = body->getTime( status );
395 if ( !U_SUCCESS(status) ) throw RuntimeException();
396 status = U_ZERO_ERROR;
397 int32_t nZoneOffset = body->get( UCAL_ZONE_OFFSET, status );
398 if ( !U_SUCCESS(status) ) throw RuntimeException();
399 status = U_ZERO_ERROR;
400 int32_t nDSTOffset = body->get( UCAL_DST_OFFSET, status );
401 if ( !U_SUCCESS(status) ) throw RuntimeException();
402 return (fTime + (nZoneOffset + nDSTOffset)) / U_MILLIS_PER_DAY;
403}
404
405bool Calendar_gregorian::setTimeZone( const OUString& rTimeZone )
406{
407 if (fieldSet)
408 {
409 setValue();
410 getValue();
411 }
412 const icu::UnicodeString aID( reinterpret_cast<const UChar*>(rTimeZone.getStr()), rTimeZone.getLength());
413 const std::unique_ptr<const icu::TimeZone> pTZ( icu::TimeZone::createTimeZone(aID));
414 if (!pTZ)
415 return false;
416
417 body->setTimeZone(*pTZ);
418 return true;
419}
420
421// map field value from gregorian calendar to other calendar, it can be overwritten by derived class.
422// By using eraArray, it can take care Japanese and Taiwan ROC calendar.
424{
425 if (!eraArray)
426 return;
427
428 sal_Int16 e, m, d;
429 sal_Int32 y;
430
431 e = fieldValue[CalendarFieldIndex::ERA];
432 y = cast16To32(fieldValue[CalendarFieldIndex::YEAR]);
433 m = fieldValue[CalendarFieldIndex::MONTH] + 1;
434 d = fieldValue[CalendarFieldIndex::DAY_OF_MONTH];
435
436 // since the year is reversed for first era, it is reversed again here for Era compare.
437 if (e == 0)
438 y = 1 - y;
439
440 for (e = 0; eraArray[e].year; e++)
441 if ((y != eraArray[e].year) ? y < eraArray[e].year :
442 (m != eraArray[e].month) ? m < eraArray[e].month : d < eraArray[e].day)
443 break;
444
445 fieldValue[CalendarFieldIndex::ERA] = e;
446 fieldValue[CalendarFieldIndex::YEAR] =
447 cast32To16( (e == 0) ? (eraArray[0].year - y) : (y - eraArray[e-1].year + 1) );
448}
449
450#define FIELDS ((1 << CalendarFieldIndex::ERA) | (1 << CalendarFieldIndex::YEAR))
451// map field value from other calendar to gregorian calendar, it can be overwritten by derived class.
452// By using eraArray, it can take care Japanese and Taiwan ROC calendar.
454{
455 if (!eraArray || !(fieldSet & FIELDS))
456 return;
457
458 sal_Int16 e = fieldValue[CalendarFieldIndex::ERA];
459 sal_Int32 y;
460 if (e == 0)
461 y = eraArray[0].year - cast16To32(fieldValue[CalendarFieldIndex::YEAR]);
462 else
463 y = eraArray[e-1].year + cast16To32(fieldValue[CalendarFieldIndex::YEAR] - 1);
464
465 fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1;
466 fieldSetValue[CalendarFieldIndex::YEAR] = cast32To16(y <= 0 ? 1 - y : y);
467 fieldSet |= FIELDS;
468}
469
471static UCalendarDateFields fieldNameConverter(sal_Int16 fieldIndex)
472{
473 UCalendarDateFields f;
474
475 switch (fieldIndex) {
476 case CalendarFieldIndex::AM_PM: f = UCAL_AM_PM; break;
477 case CalendarFieldIndex::DAY_OF_MONTH: f = UCAL_DATE; break;
478 case CalendarFieldIndex::DAY_OF_WEEK: f = UCAL_DAY_OF_WEEK; break;
479 case CalendarFieldIndex::DAY_OF_YEAR: f = UCAL_DAY_OF_YEAR; break;
480 case CalendarFieldIndex::DST_OFFSET: f = UCAL_DST_OFFSET; break;
481 case CalendarFieldIndex::ZONE_OFFSET: f = UCAL_ZONE_OFFSET; break;
482 case CalendarFieldIndex::HOUR: f = UCAL_HOUR_OF_DAY; break;
483 case CalendarFieldIndex::MINUTE: f = UCAL_MINUTE; break;
484 case CalendarFieldIndex::SECOND: f = UCAL_SECOND; break;
485 case CalendarFieldIndex::MILLISECOND: f = UCAL_MILLISECOND; break;
486 case CalendarFieldIndex::WEEK_OF_MONTH: f = UCAL_WEEK_OF_MONTH; break;
487 case CalendarFieldIndex::WEEK_OF_YEAR: f = UCAL_WEEK_OF_YEAR; break;
488 case CalendarFieldIndex::YEAR: f = UCAL_YEAR; break;
489 case CalendarFieldIndex::MONTH: f = UCAL_MONTH; break;
490 case CalendarFieldIndex::ERA: f = UCAL_ERA; break;
491 default: throw RuntimeException();
492 }
493 return f;
494}
495
496void SAL_CALL
497Calendar_gregorian::setValue( sal_Int16 fieldIndex, sal_Int16 value )
498{
499 if (fieldIndex < 0 || FIELD_INDEX_COUNT <= fieldIndex)
500 throw RuntimeException();
501 fieldSet |= (1 << fieldIndex);
502 fieldValue[fieldIndex] = value;
503}
504
505bool Calendar_gregorian::getCombinedOffset( sal_Int32 & o_nOffset,
506 sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const
507{
508 o_nOffset = 0;
509 bool bFieldsSet = false;
510 if (fieldSet & (1 << nParentFieldIndex))
511 {
512 bFieldsSet = true;
513 o_nOffset = static_cast<sal_Int32>( fieldValue[nParentFieldIndex]) * 60000;
514 }
515 if (fieldSet & (1 << nChildFieldIndex))
516 {
517 bFieldsSet = true;
518 if (o_nOffset < 0)
519 o_nOffset -= static_cast<sal_uInt16>( fieldValue[nChildFieldIndex]);
520 else
521 o_nOffset += static_cast<sal_uInt16>( fieldValue[nChildFieldIndex]);
522 }
523 return bFieldsSet;
524}
525
526bool Calendar_gregorian::getZoneOffset( sal_Int32 & o_nOffset ) const
527{
528 return getCombinedOffset( o_nOffset, CalendarFieldIndex::ZONE_OFFSET,
529 CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
530}
531
532bool Calendar_gregorian::getDSTOffset( sal_Int32 & o_nOffset ) const
533{
534 return getCombinedOffset( o_nOffset, CalendarFieldIndex::DST_OFFSET,
535 CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS);
536}
537
539{
540 for (sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++)
541 {
542 if (fieldSet & (1 << fieldIndex))
543 {
544 switch (fieldIndex)
545 {
546 default:
547 body->set(fieldNameConverter(fieldIndex), fieldSetValue[fieldIndex]);
548 break;
549 case CalendarFieldIndex::ZONE_OFFSET:
550 case CalendarFieldIndex::DST_OFFSET:
551 case CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS:
552 case CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS:
553 break; // nothing, extra handling
554 }
555 }
556 }
557 sal_Int32 nZoneOffset, nDSTOffset;
558 if (getZoneOffset( nZoneOffset))
559 body->set( fieldNameConverter( CalendarFieldIndex::ZONE_OFFSET), nZoneOffset);
560 if (getDSTOffset( nDSTOffset))
561 body->set( fieldNameConverter( CalendarFieldIndex::DST_OFFSET), nDSTOffset);
562}
563
565{
566 // Copy fields before calling submitFields() directly or indirectly below.
567 memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
568 // Possibly setup ERA and YEAR in fieldSetValue.
570
571 DUMP_ICU_CAL_MSG(("%s\n","setValue() before submission"));
572 DUMP_I18N_CAL_MSG(("%s\n","setValue() before submission"));
573
574 submitFields();
575
576 DUMP_ICU_CAL_MSG(("%s\n","setValue() after submission"));
577 DUMP_I18N_CAL_MSG(("%s\n","setValue() after submission"));
578
579#if erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR
580 {
581 // force icu::Calendar to recalculate
582 UErrorCode status;
583 sal_Int32 nTmp = body->get( UCAL_DATE, status = U_ZERO_ERROR);
584 DUMP_ICU_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
585 DUMP_I18N_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
586 }
587#endif
588}
589
591{
592 DUMP_ICU_CAL_MSG(("%s\n","getValue()"));
593 DUMP_I18N_CAL_MSG(("%s\n","getValue()"));
594 for (sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++)
595 {
596 if (fieldIndex == CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS ||
597 fieldIndex == CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS)
598 continue; // not ICU fields
599
600 UErrorCode status = U_ZERO_ERROR;
601 sal_Int32 value = body->get( fieldNameConverter(
602 fieldIndex), status);
603 if ( !U_SUCCESS(status) ) throw RuntimeException();
604
605 // Convert millisecond to minute for ZONE and DST and set remainder in
606 // second field.
607 if (fieldIndex == CalendarFieldIndex::ZONE_OFFSET)
608 {
609 sal_Int32 nMinutes = value / 60000;
610 sal_Int16 nMillis = static_cast<sal_Int16>( static_cast<sal_uInt16>(
611 abs( value - nMinutes * 60000)));
612 fieldValue[CalendarFieldIndex::ZONE_OFFSET] = static_cast<sal_Int16>( nMinutes);
613 fieldValue[CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS] = nMillis;
614 }
615 else if (fieldIndex == CalendarFieldIndex::DST_OFFSET)
616 {
617 sal_Int32 nMinutes = value / 60000;
618 sal_Int16 nMillis = static_cast<sal_Int16>( static_cast<sal_uInt16>(
619 abs( value - nMinutes * 60000)));
620 fieldValue[CalendarFieldIndex::DST_OFFSET] = static_cast<sal_Int16>( nMinutes);
621 fieldValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] = nMillis;
622 }
623 else
624 fieldValue[fieldIndex] = static_cast<sal_Int16>(value);
625
626 // offset 1 since the value for week start day SunDay is different between Calendar and Weekdays.
627 if ( fieldIndex == CalendarFieldIndex::DAY_OF_WEEK )
628 fieldValue[fieldIndex]--; // UCAL_SUNDAY:/* == 1 */ ==> Weekdays::SUNDAY /* ==0 */
629 }
631 fieldSet = 0;
632}
633
634sal_Int16 SAL_CALL
635Calendar_gregorian::getValue( sal_Int16 fieldIndex )
636{
637 if (fieldIndex < 0 || FIELD_INDEX_COUNT <= fieldIndex)
638 throw RuntimeException();
639
640 if (fieldSet) {
641 setValue();
642 getValue();
643 }
644
645 return fieldValue[fieldIndex];
646}
647
648void SAL_CALL
649Calendar_gregorian::addValue( sal_Int16 fieldIndex, sal_Int32 value )
650{
651 // since ZONE and DST could not be add, we don't need to convert value here
652 UErrorCode status = U_ZERO_ERROR;
653 body->add(fieldNameConverter(fieldIndex), value, status);
654 if ( !U_SUCCESS(status) ) throw RuntimeException();
655 getValue();
656}
657
658sal_Bool SAL_CALL
660{
661 if (fieldSet) {
662 sal_Int32 tmp = fieldSet;
663 setValue();
664 memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
665 getValue();
666 for ( sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++ ) {
667 // compare only with fields that are set and reset fieldSet[]
668 if (tmp & (1 << fieldIndex)) {
669 if (fieldSetValue[fieldIndex] != fieldValue[fieldIndex])
670 return false;
671 }
672 }
673 }
674 return true;
675}
676
677// NativeNumberMode has different meaning between Number and Calendar for Asian locales.
678// Here is the mapping table
679// calendar(q/y/m/d) zh_CN zh_TW ja ko
680// NatNum1 NatNum1/1/7/7 NatNum1/1/7/7 NatNum1/1/4/4 NatNum1/1/7/7
681// NatNum2 NatNum2/2/8/8 NatNum2/2/8/8 NatNum2/2/5/5 NatNum2/2/8/8
682// NatNum3 NatNum3/3/3/3 NatNum3/3/3/3 NatNum3/3/3/3 NatNum3/3/3/3
683// NatNum4 NatNum9/9/11/11
684
685static sal_Int16 NatNumForCalendar(const css::lang::Locale& aLocale,
686 sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, sal_Int32 value )
687{
688 bool isShort = ((nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR ||
689 nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR) && value >= 100) ||
690 nCalendarDisplayCode == CalendarDisplayCode::SHORT_QUARTER ||
691 nCalendarDisplayCode == CalendarDisplayCode::LONG_QUARTER;
692 bool isChinese = aLocale.Language == "zh";
693 bool isJapanese = aLocale.Language == "ja";
694 bool isKorean = aLocale.Language == "ko";
695
696 if (isChinese || isJapanese || isKorean) {
697 switch (nNativeNumberMode) {
698 case NativeNumberMode::NATNUM1:
699 if (!isShort)
700 nNativeNumberMode = isJapanese ? NativeNumberMode::NATNUM4 : NativeNumberMode::NATNUM7;
701 break;
702 case NativeNumberMode::NATNUM2:
703 if (!isShort)
704 nNativeNumberMode = isJapanese ? NativeNumberMode::NATNUM5 : NativeNumberMode::NATNUM8;
705 break;
706 case NativeNumberMode::NATNUM3:
707 break;
708 case NativeNumberMode::NATNUM4:
709 if (isKorean)
710 return isShort ? NativeNumberMode::NATNUM9 : NativeNumberMode::NATNUM11;
711 [[fallthrough]];
712 default: return 0;
713 }
714 }
715 return nNativeNumberMode;
716}
717
718static sal_Int32 DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
719{
720 switch( nCalendarDisplayCode ) {
721 case CalendarDisplayCode::SHORT_DAY:
722 case CalendarDisplayCode::LONG_DAY:
723 return CalendarFieldIndex::DAY_OF_MONTH;
724 case CalendarDisplayCode::SHORT_DAY_NAME:
725 case CalendarDisplayCode::LONG_DAY_NAME:
726 case CalendarDisplayCode::NARROW_DAY_NAME:
727 return CalendarFieldIndex::DAY_OF_WEEK;
728 case CalendarDisplayCode::SHORT_QUARTER:
729 case CalendarDisplayCode::LONG_QUARTER:
730 case CalendarDisplayCode::SHORT_MONTH:
731 case CalendarDisplayCode::LONG_MONTH:
732 case CalendarDisplayCode::SHORT_MONTH_NAME:
733 case CalendarDisplayCode::LONG_MONTH_NAME:
734 case CalendarDisplayCode::NARROW_MONTH_NAME:
735 case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
736 case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
737 case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
738 case CalendarDisplayCode::SHORT_PARTITIVE_MONTH_NAME:
739 case CalendarDisplayCode::LONG_PARTITIVE_MONTH_NAME:
740 case CalendarDisplayCode::NARROW_PARTITIVE_MONTH_NAME:
741 return CalendarFieldIndex::MONTH;
742 case CalendarDisplayCode::SHORT_YEAR:
743 case CalendarDisplayCode::LONG_YEAR:
744 return CalendarFieldIndex::YEAR;
745 case CalendarDisplayCode::SHORT_ERA:
746 case CalendarDisplayCode::LONG_ERA:
747 return CalendarFieldIndex::ERA;
748 case CalendarDisplayCode::SHORT_YEAR_AND_ERA:
749 case CalendarDisplayCode::LONG_YEAR_AND_ERA:
750 return CalendarFieldIndex::YEAR;
751 default:
752 return 0;
753 }
754}
755
756sal_Int16 SAL_CALL
758{
759 // UCAL_SUNDAY == 1, Weekdays::SUNDAY == 0 => offset -1
760 // Check for underflow just in case we're called "out of sync".
761 return ::std::max( sal::static_int_cast<sal_Int16>(0),
762 sal::static_int_cast<sal_Int16>( static_cast<sal_Int16>(
763 body->getFirstDayOfWeek()) - 1));
764}
765
766void SAL_CALL
768{
769 // Weekdays::SUNDAY == 0, UCAL_SUNDAY == 1 => offset +1
770 body->setFirstDayOfWeek( static_cast<UCalendarDaysOfWeek>( day + 1));
771}
772
773void SAL_CALL
775{
776 aCalendar.MinimumNumberOfDaysForFirstWeek = days;
777 body->setMinimalDaysInFirstWeek( static_cast<uint8_t>( days));
778}
779
780sal_Int16 SAL_CALL
782{
783 return aCalendar.MinimumNumberOfDaysForFirstWeek;
784}
785
786sal_Int16 SAL_CALL
788{
789 return static_cast<sal_Int16>(aCalendar.Months.getLength());
790}
791
792
793sal_Int16 SAL_CALL
795{
796 return static_cast<sal_Int16>(aCalendar.Days.getLength());
797}
798
799
800Sequence< CalendarItem > SAL_CALL
802{
804}
805
806
807Sequence< CalendarItem > SAL_CALL
809{
811}
812
813
814Sequence< CalendarItem2 > SAL_CALL
816{
817 return aCalendar.Days;
818}
819
820
821Sequence< CalendarItem2 > SAL_CALL
823{
824 return aCalendar.Months;
825}
826
827
828Sequence< CalendarItem2 > SAL_CALL
830{
831 return aCalendar.GenitiveMonths;
832}
833
834
835Sequence< CalendarItem2 > SAL_CALL
837{
838 return aCalendar.PartitiveMonths;
839}
840
841
842OUString SAL_CALL
843Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType )
844{
845 OUString aStr;
846
847 switch( displayIndex ) {
848 case CalendarDisplayIndex::AM_PM:/* ==0 */
849 if (idx == 0) aStr = LocaleDataImpl::get()->getLocaleItem(aLocale).timeAM;
850 else if (idx == 1) aStr = LocaleDataImpl::get()->getLocaleItem(aLocale).timePM;
851 else throw RuntimeException();
852 break;
853 case CalendarDisplayIndex::DAY:
854 if( idx >= aCalendar.Days.getLength() ) throw RuntimeException();
855 if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
856 else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
857 else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
858 else throw RuntimeException();
859 break;
860 case CalendarDisplayIndex::MONTH:
861 if( idx >= aCalendar.Months.getLength() ) throw RuntimeException();
862 if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
863 else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
864 else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
865 else throw RuntimeException();
866 break;
867 case CalendarDisplayIndex::GENITIVE_MONTH:
868 if( idx >= aCalendar.GenitiveMonths.getLength() ) throw RuntimeException();
869 if (nameType == 0) aStr = aCalendar.GenitiveMonths[idx].AbbrevName;
870 else if (nameType == 1) aStr = aCalendar.GenitiveMonths[idx].FullName;
871 else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
872 else throw RuntimeException();
873 break;
874 case CalendarDisplayIndex::PARTITIVE_MONTH:
875 if( idx >= aCalendar.PartitiveMonths.getLength() ) throw RuntimeException();
876 if (nameType == 0) aStr = aCalendar.PartitiveMonths[idx].AbbrevName;
877 else if (nameType == 1) aStr = aCalendar.PartitiveMonths[idx].FullName;
878 else if (nameType == 2) aStr = aCalendar.PartitiveMonths[idx].NarrowName;
879 else throw RuntimeException();
880 break;
881 case CalendarDisplayIndex::ERA:
882 if( idx >= aCalendar.Eras.getLength() ) throw RuntimeException();
883 if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
884 else if (nameType == 1) aStr = aCalendar.Eras[idx].FullName;
885 else throw RuntimeException();
886 break;
887 case CalendarDisplayIndex::YEAR:
888 break;
889 default:
890 throw RuntimeException();
891 }
892 return aStr;
893}
894
895// Methods in XExtendedCalendar
896OUString SAL_CALL
897Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode )
898{
899 return getDisplayStringImpl( nCalendarDisplayCode, nNativeNumberMode, false);
900}
901
902OUString
903Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode )
904{
905 sal_Int32 value = cast16To32( getValue( sal::static_int_cast<sal_Int16>(
906 DisplayCode2FieldIndex(nCalendarDisplayCode))));
907 OUString aOUStr;
908
909 if (nCalendarDisplayCode == CalendarDisplayCode::SHORT_QUARTER ||
910 nCalendarDisplayCode == CalendarDisplayCode::LONG_QUARTER) {
911 Sequence< OUString> xR = LocaleDataImpl::get()->getReservedWord(aLocale);
912 sal_Int16 quarter = value / 3;
913 // Since this base class method may be called by derived calendar
914 // classes where a year consists of more than 12 months we need a check
915 // to not run out of bounds of reserved quarter words. Perhaps a more
916 // clean way (instead of dividing by 3) would be to first get the
917 // number of months, divide by 4 and then use that result to divide the
918 // actual month value.
919 if ( quarter > 3 )
920 quarter = 3;
921 quarter = sal::static_int_cast<sal_Int16>( quarter +
922 ((nCalendarDisplayCode == CalendarDisplayCode::SHORT_QUARTER) ?
923 reservedWords::QUARTER1_ABBREVIATION : reservedWords::QUARTER1_WORD) );
924 aOUStr = xR[quarter];
925 } else {
926 // The "#100211# - checked" comments serve for detection of "use of
927 // sprintf is safe here" conditions. An sprintf encountered without
928 // having that comment triggers alarm ;-)
929 char aStr[12]; // "-2147483648" and \0
930 switch( nCalendarDisplayCode ) {
931 case CalendarDisplayCode::SHORT_MONTH:
932 value += 1; // month is zero based
933 [[fallthrough]];
934 case CalendarDisplayCode::SHORT_DAY:
935 sprintf(aStr, "%" SAL_PRIdINT32, value); // #100211# - checked
936 break;
937 case CalendarDisplayCode::LONG_YEAR:
938 if ( aCalendar.Name == "gengou" )
939 sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked
940 else
941 sprintf(aStr, "%" SAL_PRIdINT32, value); // #100211# - checked
942 break;
943 case CalendarDisplayCode::LONG_MONTH:
944 value += 1; // month is zero based
945 sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked
946 break;
947 case CalendarDisplayCode::SHORT_YEAR:
948 // Take last 2 digits, or only one if value<10, for example,
949 // in case of the Gengou calendar. For combined era+year always
950 // the full year is displayed, without leading 0.
951 // Workaround for non-combined calls in certain calendars is
952 // the kDisplayEraForcedLongYear flag, but this also could get
953 // called for YY not only E format codes, no differentiation
954 // possible here; the good news is that usually the Gregorian
955 // calendar is the default and hence YY calls for Gregorian and
956 // E for the other calendar and currently (2013-02-28) ROC is
957 // the only calendar using this.
958 // See i#116701 and fdo#60915
959 if (value < 100 || bEraMode || (eraArray && (eraArray[0].flags & kDisplayEraForcedLongYear)))
960 sprintf(aStr, "%" SAL_PRIdINT32, value); // #100211# - checked
961 else
962 sprintf(aStr, "%02" SAL_PRIdINT32, value % 100); // #100211# - checked
963 break;
964 case CalendarDisplayCode::LONG_DAY:
965 sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked
966 break;
967
968 case CalendarDisplayCode::SHORT_DAY_NAME:
969 return getDisplayName(CalendarDisplayIndex::DAY, value, 0);
970 case CalendarDisplayCode::LONG_DAY_NAME:
971 return getDisplayName(CalendarDisplayIndex::DAY, value, 1);
972 case CalendarDisplayCode::NARROW_DAY_NAME:
973 return getDisplayName(CalendarDisplayIndex::DAY, value, 2);
974 case CalendarDisplayCode::SHORT_MONTH_NAME:
975 return getDisplayName(CalendarDisplayIndex::MONTH, value, 0);
976 case CalendarDisplayCode::LONG_MONTH_NAME:
977 return getDisplayName(CalendarDisplayIndex::MONTH, value, 1);
978 case CalendarDisplayCode::NARROW_MONTH_NAME:
979 return getDisplayName(CalendarDisplayIndex::MONTH, value, 2);
980 case CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME:
981 return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 0);
982 case CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME:
983 return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 1);
984 case CalendarDisplayCode::NARROW_GENITIVE_MONTH_NAME:
985 return getDisplayName(CalendarDisplayIndex::GENITIVE_MONTH, value, 2);
986 case CalendarDisplayCode::SHORT_PARTITIVE_MONTH_NAME:
987 return getDisplayName(CalendarDisplayIndex::PARTITIVE_MONTH, value, 0);
988 case CalendarDisplayCode::LONG_PARTITIVE_MONTH_NAME:
989 return getDisplayName(CalendarDisplayIndex::PARTITIVE_MONTH, value, 1);
990 case CalendarDisplayCode::NARROW_PARTITIVE_MONTH_NAME:
991 return getDisplayName(CalendarDisplayIndex::PARTITIVE_MONTH, value, 2);
992 case CalendarDisplayCode::SHORT_ERA:
993 return getDisplayName(CalendarDisplayIndex::ERA, value, 0);
994 case CalendarDisplayCode::LONG_ERA:
995 return getDisplayName(CalendarDisplayIndex::ERA, value, 1);
996
997 case CalendarDisplayCode::SHORT_YEAR_AND_ERA:
998 return getDisplayStringImpl( CalendarDisplayCode::SHORT_ERA, nNativeNumberMode, true ) +
999 getDisplayStringImpl( CalendarDisplayCode::SHORT_YEAR, nNativeNumberMode, true );
1000
1001 case CalendarDisplayCode::LONG_YEAR_AND_ERA:
1002 return getDisplayStringImpl( CalendarDisplayCode::LONG_ERA, nNativeNumberMode, true ) +
1003 getDisplayStringImpl( CalendarDisplayCode::LONG_YEAR, nNativeNumberMode, true );
1004
1005 default:
1006 throw RuntimeException();
1007 }
1008 aOUStr = OUString::createFromAscii(aStr);
1009 }
1010 // NatNum12 used only for selected parts
1011 if (nNativeNumberMode > 0 && nNativeNumberMode != 12) {
1012 // For Japanese calendar, first year calls GAN, see bug 111668 for detail.
1013 if (eraArray == gengou_eraArray && value == 1
1014 && (nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR ||
1015 nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR)
1016 && (nNativeNumberMode == NativeNumberMode::NATNUM1 ||
1017 nNativeNumberMode == NativeNumberMode::NATNUM2)) {
1018 static sal_Unicode gan = 0x5143;
1019 return OUString(&gan, 1);
1020 }
1021 sal_Int16 nNatNum = NatNumForCalendar(aLocale, nCalendarDisplayCode, nNativeNumberMode, value);
1022 if (nNatNum > 0)
1023 return mxNatNum->getNativeNumberString(aOUStr, aLocale, nNatNum);
1024 }
1025 return aOUStr;
1026}
1027
1028// Methods in XExtendedCalendar
1029OUString SAL_CALL
1030Calendar_buddhist::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode )
1031{
1032 // make year and era in different order for year before and after 0.
1033 if ((nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR_AND_ERA ||
1034 nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR_AND_ERA) &&
1035 getValue(CalendarFieldIndex::ERA) == 0) {
1036 if (nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR_AND_ERA)
1037 return getDisplayStringImpl( CalendarDisplayCode::SHORT_YEAR, nNativeNumberMode, true ) +
1038 getDisplayStringImpl( CalendarDisplayCode::SHORT_ERA, nNativeNumberMode, true );
1039 else
1040 return getDisplayStringImpl( CalendarDisplayCode::LONG_YEAR, nNativeNumberMode, true ) +
1041 getDisplayStringImpl( CalendarDisplayCode::LONG_ERA, nNativeNumberMode, true );
1042 }
1043 return Calendar_gregorian::getDisplayString(nCalendarDisplayCode, nNativeNumberMode);
1044}
1045
1046OUString SAL_CALL
1048{
1049 return OUString::createFromAscii(cCalendar);
1050}
1051
1052sal_Bool SAL_CALL
1053Calendar_gregorian::supportsService(const OUString& rServiceName)
1054{
1055 return cppu::supportsService(this, rServiceName);
1056}
1057
1058Sequence< OUString > SAL_CALL
1060{
1061 Sequence< OUString > aRet { OUString::createFromAscii(cCalendar) };
1062 return aRet;
1063}
1064
1065}
1066
1067/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double d
#define FIELDS
#define DUMP_ICU_CAL_MSG(x)
#define DUMP_I18N_CAL_MSG(x)
sal_Int32 day
sal_Int32 year
sal_Int32 month
virtual OUString SAL_CALL getDisplayString(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode) override
std::unique_ptr< icu::Calendar > body
sal_Int16 fieldSetValue[FIELD_INDEX_COUNT]
virtual double SAL_CALL getDateTime() override
void submitFields()
Submit fieldSetValue array according to fieldSet.
virtual void SAL_CALL loadCalendar(const OUString &uniqueID, const css::lang::Locale &rLocale) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getDays2() override
void init(const Era *_eraArray)
virtual void SAL_CALL setLocalDateTime(double TimeInDays) override
virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() override
virtual sal_Int16 SAL_CALL getFirstDayOfWeek() override
OUString getDisplayStringImpl(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode)
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getGenitiveMonths2() override
rtl::Reference< NativeNumberSupplierService > mxNatNum
virtual double SAL_CALL getLocalDateTime() override
virtual css::uno::Sequence< css::i18n::CalendarItem > SAL_CALL getMonths() override
virtual OUString SAL_CALL getDisplayString(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode) override
virtual OUString SAL_CALL getUniqueID() override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getMonths2() override
virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) override
virtual void SAL_CALL setDateTime(double fTimeInDays) override
bool getZoneOffset(sal_Int32 &o_nOffset) const
Obtain combined field values for timezone offset (minutes+secondmillis) in milliseconds and whether f...
virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) override
virtual ~Calendar_gregorian() override
Destructor.
void setValue()
Set fields internally.
bool getDSTOffset(sal_Int32 &o_nOffset) const
Obtain combined field values for DST offset (minutes+secondmillis) in milliseconds and whether fields...
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getPartitiveMonths2() override
virtual css::i18n::Calendar2 SAL_CALL getLoadedCalendar2() override
virtual css::uno::Sequence< css::i18n::CalendarItem > SAL_CALL getDays() override
virtual sal_Bool SAL_CALL isValid() override
virtual css::i18n::Calendar SAL_CALL getLoadedCalendar() override
virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) override
bool setTimeZone(const OUString &rTimeZone)
sal_Int16 fieldValue[FIELD_INDEX_COUNT]
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() override
bool getCombinedOffset(sal_Int32 &o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex) const
Used by getZoneOffset() and getDSTOffset().
virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
static rtl::Reference< LocaleDataImpl > get()
Definition: localedata.hxx:77
static css::uno::Sequence< css::i18n::CalendarItem > downcastCalendarItems(const css::uno::Sequence< css::i18n::CalendarItem2 > &rCi)
Definition: localedata.cxx:355
static css::i18n::Calendar downcastCalendar(const css::i18n::Calendar2 &rC)
Definition: localedata.cxx:362
Any value
float y
const sal_uInt16 idx[]
uno_Any a
sal_Int32 nNatNum
#define SAL_INFO_IF(condition, area, stream)
aStr
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
Constant values shared between i18npool and, for example, the number formatter.
static sal_Int32 DisplayCode2FieldIndex(sal_Int32 nCalendarDisplayCode)
static UCalendarDateFields fieldNameConverter(sal_Int16 fieldIndex)
static sal_Int32 cast16To32(sal_Int16 i)
const Era ROC_eraArray[]
const Era buddhist_eraArray[]
const sal_Int16 FIELD_INDEX_COUNT
const Era gengou_eraArray[]
static sal_Int16 cast32To16(sal_Int32 a)
const Era dangi_eraArray[]
The start year of the Korean traditional calendar (Dan-gi) is the inaugural year of Dan-gun (BC 2333)...
const sal_uInt8 kDisplayEraForcedLongYear
static sal_Int16 NatNumForCalendar(const css::lang::Locale &aLocale, sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, sal_Int32 value)
m
void(* f)(TrueTypeTable *)
sal_Int32 h
SwNodeOffset abs(const SwNodeOffset &a)
unsigned char sal_Bool
#define SAL_MIN_INT16
#define SAL_MAX_INT16
sal_uInt16 sal_Unicode