nss: upgrade to release 3.73
[LibreOffice.git] / i18npool / inc / calendar_gregorian.hxx
blobf66300d42e0a681ae103563dc9abb2654d50b7c6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
24 #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
26 #include <unicode/calendar.h>
27 #include <rtl/ref.hxx>
29 #include <memory>
31 namespace i18npool { class NativeNumberSupplierService; }
35 namespace i18npool {
37 const sal_uInt8 kDisplayEraForcedLongYear = 0x01;
39 struct Era {
40 sal_Int32 year;
41 sal_Int32 month;
42 sal_Int32 day;
43 sal_uInt8 flags;
46 const sal_Int16 FIELD_INDEX_COUNT = css::i18n::CalendarFieldIndex::FIELD_COUNT2;
48 class Calendar_gregorian : public CalendarImpl
50 public:
52 // Constructors
53 Calendar_gregorian();
54 Calendar_gregorian(const Era *_eraArray);
55 void init(const Era *_eraArray);
56 bool setTimeZone( const OUString& rTimeZone );
58 /**
59 * Destructor
61 virtual ~Calendar_gregorian() override;
63 // Methods in XCalendar
64 virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const css::lang::Locale& rLocale) override;
65 virtual void SAL_CALL setDateTime(double fTimeInDays) override;
66 virtual double SAL_CALL getDateTime() override;
67 virtual void SAL_CALL setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ) override;
68 virtual sal_Int16 SAL_CALL getValue(sal_Int16 nFieldIndex) override;
69 virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) override;
70 virtual sal_Bool SAL_CALL isValid() override;
71 virtual css::i18n:: Calendar SAL_CALL getLoadedCalendar() override;
72 virtual OUString SAL_CALL getUniqueID() override;
73 virtual sal_Int16 SAL_CALL getFirstDayOfWeek() override;
74 virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) override;
75 virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) override;
76 virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() override;
77 virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() override;
78 virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() override;
79 virtual css::uno::Sequence < css::i18n::CalendarItem > SAL_CALL getMonths() override;
80 virtual css::uno::Sequence < css::i18n::CalendarItem > SAL_CALL getDays() override;
81 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
83 // Methods in XExtendedCalendar
84 virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
86 // XCalendar3
87 virtual css::i18n::Calendar2 SAL_CALL getLoadedCalendar2() override;
88 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getDays2() override;
89 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getMonths2() override;
90 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getGenitiveMonths2() override;
91 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getPartitiveMonths2() override;
93 // XCalendar4
94 virtual void SAL_CALL setLocalDateTime(double TimeInDays) override;
95 virtual double SAL_CALL getLocalDateTime() override;
97 //XServiceInfo
98 virtual OUString SAL_CALL getImplementationName() override;
99 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
100 virtual css::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() override;
102 protected:
103 const Era *eraArray;
104 std::unique_ptr<icu::Calendar> body;
105 rtl::Reference<NativeNumberSupplierService> mxNatNum;
106 const char* cCalendar;
107 css::lang::Locale aLocale;
108 sal_uInt32 fieldSet;
109 sal_Int16 fieldValue[FIELD_INDEX_COUNT];
110 sal_Int16 fieldSetValue[FIELD_INDEX_COUNT];
112 /// @throws css::uno::RuntimeException
113 virtual void mapToGregorian();
114 /// @throws css::uno::RuntimeException
115 virtual void mapFromGregorian();
116 /// @throws css::uno::RuntimeException
117 void getValue();
119 /// @throws css::uno::RuntimeException
120 OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode );
122 private:
123 css::i18n::Calendar2 aCalendar;
125 /** Submit fieldSetValue array according to fieldSet.
127 @throws css::uno::RuntimeException
129 void submitFields();
130 /** Set fields internally.
132 @throws css::uno::RuntimeException
134 void setValue();
135 /** Obtain combined field values for timezone offset (minutes+secondmillis)
136 in milliseconds and whether fields were set. */
137 bool getZoneOffset( sal_Int32 & o_nOffset ) const;
138 /** Obtain combined field values for DST offset (minutes+secondmillis) in
139 milliseconds and whether fields were set. */
140 bool getDSTOffset( sal_Int32 & o_nOffset ) const;
141 /** Used by getZoneOffset() and getDSTOffset(). Parent is
142 CalendarFieldIndex for offset in minutes, child is CalendarFieldIndex
143 for offset in milliseconds. */
144 bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
149 class Calendar_hanja final : public Calendar_gregorian
151 public:
152 // Constructors
153 Calendar_hanja();
154 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
157 class Calendar_hanja_yoil final : public Calendar_gregorian
159 public:
160 // Constructors
161 Calendar_hanja_yoil();
162 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
166 class Calendar_gengou final : public Calendar_gregorian
168 public:
169 // Constructors
170 Calendar_gengou();
175 class Calendar_ROC final : public Calendar_gregorian
177 public:
178 // Constructors
179 Calendar_ROC();
184 class Calendar_dangi final : public Calendar_gregorian
186 public:
187 // Constructors
188 Calendar_dangi();
193 class Calendar_buddhist final : public Calendar_gregorian
195 public:
196 // Constructors
197 Calendar_buddhist();
199 // Methods in XExtendedCalendar
200 virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
205 #endif
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */