1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_I18NPOOL_INC_CALENDAR_GREGORIAN_HXX
20 #define INCLUDED_I18NPOOL_INC_CALENDAR_GREGORIAN_HXX
22 #include "calendarImpl.hxx"
23 #include "nativenumbersupplier.hxx"
25 #include <unicode/calendar.h>
26 #include <rtl/ref.hxx>
31 // class Calendar_gregorian
36 const sal_uInt8 kDisplayEraForcedLongYear
= 0x01;
45 const sal_Int16 FIELD_INDEX_COUNT
= css::i18n::CalendarFieldIndex::FIELD_COUNT2
;
47 class Calendar_gregorian
: public CalendarImpl
53 Calendar_gregorian(const Era
*_eraArray
);
54 void init(const Era
*_eraArray
);
59 virtual ~Calendar_gregorian() override
;
61 // Methods in XCalendar
62 virtual void SAL_CALL
loadCalendar(const OUString
& uniqueID
, const css::lang::Locale
& rLocale
) override
;
63 virtual void SAL_CALL
setDateTime(double fTimeInDays
) override
;
64 virtual double SAL_CALL
getDateTime() override
;
65 virtual void SAL_CALL
setValue( sal_Int16 nFieldIndex
, sal_Int16 nValue
) override
;
66 virtual sal_Int16 SAL_CALL
getValue(sal_Int16 nFieldIndex
) override
;
67 virtual void SAL_CALL
addValue(sal_Int16 nFieldIndex
, sal_Int32 nAmount
) override
;
68 virtual sal_Bool SAL_CALL
isValid() override
;
69 virtual css::i18n:: Calendar SAL_CALL
getLoadedCalendar() override
;
70 virtual OUString SAL_CALL
getUniqueID() override
;
71 virtual sal_Int16 SAL_CALL
getFirstDayOfWeek() override
;
72 virtual void SAL_CALL
setFirstDayOfWeek(sal_Int16 nDay
) override
;
73 virtual void SAL_CALL
setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays
) override
;
74 virtual sal_Int16 SAL_CALL
getMinimumNumberOfDaysForFirstWeek() override
;
75 virtual sal_Int16 SAL_CALL
getNumberOfMonthsInYear() override
;
76 virtual sal_Int16 SAL_CALL
getNumberOfDaysInWeek() override
;
77 virtual css::uno::Sequence
< css::i18n::CalendarItem
> SAL_CALL
getMonths() override
;
78 virtual css::uno::Sequence
< css::i18n::CalendarItem
> SAL_CALL
getDays() override
;
79 virtual OUString SAL_CALL
getDisplayName(sal_Int16 nCalendarDisplayIndex
, sal_Int16 nIdx
, sal_Int16 nNameType
) override
;
81 // Methods in XExtendedCalendar
82 virtual OUString SAL_CALL
getDisplayString( sal_Int32 nCalendarDisplayCode
, sal_Int16 nNativeNumberMode
) override
;
85 virtual css::i18n::Calendar2 SAL_CALL
getLoadedCalendar2() override
;
86 virtual css::uno::Sequence
< css::i18n::CalendarItem2
> SAL_CALL
getDays2() override
;
87 virtual css::uno::Sequence
< css::i18n::CalendarItem2
> SAL_CALL
getMonths2() override
;
88 virtual css::uno::Sequence
< css::i18n::CalendarItem2
> SAL_CALL
getGenitiveMonths2() override
;
89 virtual css::uno::Sequence
< css::i18n::CalendarItem2
> SAL_CALL
getPartitiveMonths2() override
;
92 virtual void SAL_CALL
setLocalDateTime(double TimeInDays
) override
;
93 virtual double SAL_CALL
getLocalDateTime() override
;
96 virtual OUString SAL_CALL
getImplementationName() override
;
97 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
98 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
102 std::unique_ptr
<icu::Calendar
> body
;
103 rtl::Reference
<NativeNumberSupplierService
> mxNatNum
;
104 const sal_Char
* cCalendar
;
105 css::lang::Locale aLocale
;
107 sal_Int16 fieldValue
[FIELD_INDEX_COUNT
];
108 sal_Int16 fieldSetValue
[FIELD_INDEX_COUNT
];
110 /// @throws css::uno::RuntimeException
111 virtual void mapToGregorian();
112 /// @throws css::uno::RuntimeException
113 virtual void mapFromGregorian();
114 /// @throws css::uno::RuntimeException
117 /// @throws css::uno::RuntimeException
118 OUString
getDisplayStringImpl( sal_Int32 nCalendarDisplayCode
, sal_Int16 nNativeNumberMode
, bool bEraMode
);
121 css::i18n::Calendar2 aCalendar
;
123 /** Submit fieldSetValue array according to fieldSet.
125 @throws css::uno::RuntimeException
128 /** Set fields internally.
130 @throws css::uno::RuntimeException
133 /** Obtain combined field values for timezone offset (minutes+secondmillis)
134 in milliseconds and whether fields were set. */
135 bool getZoneOffset( sal_Int32
& o_nOffset
) const;
136 /** Obtain combined field values for DST offset (minutes+secondmillis) in
137 milliseconds and whether fields were set. */
138 bool getDSTOffset( sal_Int32
& o_nOffset
) const;
139 /** Used by getZoneOffset() and getDSTOffset(). Parent is
140 CalendarFieldIndex for offset in minutes, child is CalendarFieldIndex
141 for offset in milliseconds. */
142 bool getCombinedOffset( sal_Int32
& o_nOffset
, sal_Int16 nParentFieldIndex
, sal_Int16 nChildFieldIndex
) const;
146 // class Calendar_hanja
148 class Calendar_hanja
: public Calendar_gregorian
153 virtual void SAL_CALL
loadCalendar(const OUString
& uniqueID
, const css::lang::Locale
& rLocale
) override
;
154 virtual OUString SAL_CALL
getDisplayName(sal_Int16 nCalendarDisplayIndex
, sal_Int16 nIdx
, sal_Int16 nNameType
) override
;
158 // class Calendar_gengou
160 class Calendar_gengou
: public Calendar_gregorian
168 // class Calendar_ROC
170 class Calendar_ROC
: public Calendar_gregorian
178 // class Calendar_buddhist
180 class Calendar_buddhist
: public Calendar_gregorian
186 // Methods in XExtendedCalendar
187 virtual OUString SAL_CALL
getDisplayString( sal_Int32 nCalendarDisplayCode
, sal_Int16 nNativeNumberMode
) override
;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */