Bump version to 6.4-15
[LibreOffice.git] / i18npool / inc / calendar_gregorian.hxx
blobaa9a02965d79b74e8402ece22d9cf7478312bd6f
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; }
33 // class Calendar_gregorian
36 namespace i18npool {
38 const sal_uInt8 kDisplayEraForcedLongYear = 0x01;
40 struct Era {
41 sal_Int32 year;
42 sal_Int32 month;
43 sal_Int32 day;
44 sal_uInt8 flags;
47 const sal_Int16 FIELD_INDEX_COUNT = css::i18n::CalendarFieldIndex::FIELD_COUNT2;
49 class Calendar_gregorian : public CalendarImpl
51 public:
53 // Constructors
54 Calendar_gregorian();
55 Calendar_gregorian(const Era *_eraArray);
56 void init(const Era *_eraArray);
57 bool setTimeZone( const OUString& rTimeZone );
59 /**
60 * Destructor
62 virtual ~Calendar_gregorian() override;
64 // Methods in XCalendar
65 virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const css::lang::Locale& rLocale) override;
66 virtual void SAL_CALL setDateTime(double fTimeInDays) override;
67 virtual double SAL_CALL getDateTime() override;
68 virtual void SAL_CALL setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ) override;
69 virtual sal_Int16 SAL_CALL getValue(sal_Int16 nFieldIndex) override;
70 virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) override;
71 virtual sal_Bool SAL_CALL isValid() override;
72 virtual css::i18n:: Calendar SAL_CALL getLoadedCalendar() override;
73 virtual OUString SAL_CALL getUniqueID() override;
74 virtual sal_Int16 SAL_CALL getFirstDayOfWeek() override;
75 virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) override;
76 virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) override;
77 virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() override;
78 virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() override;
79 virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() override;
80 virtual css::uno::Sequence < css::i18n::CalendarItem > SAL_CALL getMonths() override;
81 virtual css::uno::Sequence < css::i18n::CalendarItem > SAL_CALL getDays() override;
82 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
84 // Methods in XExtendedCalendar
85 virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
87 // XCalendar3
88 virtual css::i18n::Calendar2 SAL_CALL getLoadedCalendar2() override;
89 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getDays2() override;
90 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getMonths2() override;
91 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getGenitiveMonths2() override;
92 virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getPartitiveMonths2() override;
94 // XCalendar4
95 virtual void SAL_CALL setLocalDateTime(double TimeInDays) override;
96 virtual double SAL_CALL getLocalDateTime() override;
98 //XServiceInfo
99 virtual OUString SAL_CALL getImplementationName() override;
100 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
101 virtual css::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() override;
103 protected:
104 const Era *eraArray;
105 std::unique_ptr<icu::Calendar> body;
106 rtl::Reference<NativeNumberSupplierService> mxNatNum;
107 const sal_Char* cCalendar;
108 css::lang::Locale aLocale;
109 sal_uInt32 fieldSet;
110 sal_Int16 fieldValue[FIELD_INDEX_COUNT];
111 sal_Int16 fieldSetValue[FIELD_INDEX_COUNT];
113 /// @throws css::uno::RuntimeException
114 virtual void mapToGregorian();
115 /// @throws css::uno::RuntimeException
116 virtual void mapFromGregorian();
117 /// @throws css::uno::RuntimeException
118 void getValue();
120 /// @throws css::uno::RuntimeException
121 OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode );
123 private:
124 css::i18n::Calendar2 aCalendar;
126 /** Submit fieldSetValue array according to fieldSet.
128 @throws css::uno::RuntimeException
130 void submitFields();
131 /** Set fields internally.
133 @throws css::uno::RuntimeException
135 void setValue();
136 /** Obtain combined field values for timezone offset (minutes+secondmillis)
137 in milliseconds and whether fields were set. */
138 bool getZoneOffset( sal_Int32 & o_nOffset ) const;
139 /** Obtain combined field values for DST offset (minutes+secondmillis) in
140 milliseconds and whether fields were set. */
141 bool getDSTOffset( sal_Int32 & o_nOffset ) const;
142 /** Used by getZoneOffset() and getDSTOffset(). Parent is
143 CalendarFieldIndex for offset in minutes, child is CalendarFieldIndex
144 for offset in milliseconds. */
145 bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
149 // class Calendar_hanja
151 class Calendar_hanja : public Calendar_gregorian
153 public:
154 // Constructors
155 Calendar_hanja();
156 virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const css::lang::Locale& rLocale) override;
157 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
161 // class Calendar_gengou
163 class Calendar_gengou : public Calendar_gregorian
165 public:
166 // Constructors
167 Calendar_gengou();
171 // class Calendar_ROC
173 class Calendar_ROC : public Calendar_gregorian
175 public:
176 // Constructors
177 Calendar_ROC();
181 // class Calendar_dangi
183 class Calendar_dangi : public Calendar_gregorian
185 public:
186 // Constructors
187 Calendar_dangi();
191 // class Calendar_buddhist
193 class Calendar_buddhist : 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: */