LibreOffice Module i18npool (master)  1
calendar_gregorian.hxx
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 #ifndef INCLUDED_I18NPOOL_INC_CALENDAR_GREGORIAN_HXX
20 #define INCLUDED_I18NPOOL_INC_CALENDAR_GREGORIAN_HXX
21 
22 #include "calendarImpl.hxx"
23 
24 #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
25 
26 #include <unicode/calendar.h>
27 #include <rtl/ref.hxx>
28 
29 #include <memory>
30 
31 namespace i18npool { class NativeNumberSupplierService; }
32 
33 
34 
35 namespace i18npool {
36 
38 
39 struct Era {
40  sal_Int32 year;
41  sal_Int32 month;
42  sal_Int32 day;
44 };
45 
46 const sal_Int16 FIELD_INDEX_COUNT = css::i18n::CalendarFieldIndex::FIELD_COUNT2;
47 
49 {
50 public:
51 
52  // Constructors
54  Calendar_gregorian(const Era *_eraArray);
55  void init(const Era *_eraArray);
56  bool setTimeZone( const OUString& rTimeZone );
57 
61  virtual ~Calendar_gregorian() override;
62 
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;
82 
83  // Methods in XExtendedCalendar
84  virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
85 
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;
92 
93  // XCalendar4
94  virtual void SAL_CALL setLocalDateTime(double TimeInDays) override;
95  virtual double SAL_CALL getLocalDateTime() override;
96 
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;
101 
102 protected:
103  const Era *eraArray;
104  std::unique_ptr<icu::Calendar> body;
106  const char* cCalendar;
107  css::lang::Locale aLocale;
108  sal_uInt32 fieldSet;
111 
113  virtual void mapToGregorian();
115  virtual void mapFromGregorian();
117  void getValue();
118 
120  OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode );
121 
122 private:
123  css::i18n::Calendar2 aCalendar;
124 
129  void submitFields();
134  void setValue();
137  bool getZoneOffset( sal_Int32 & o_nOffset ) const;
140  bool getDSTOffset( sal_Int32 & o_nOffset ) const;
144  bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
145 };
146 
147 
148 
149 class Calendar_hanja final : public Calendar_gregorian
150 {
151 public:
152  // Constructors
153  Calendar_hanja();
154  virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
155 };
156 
158 {
159 public:
160  // Constructors
162  virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
163 };
164 
165 
167 {
168 public:
169  // Constructors
170  Calendar_gengou();
171 };
172 
173 
174 
175 class Calendar_ROC final : public Calendar_gregorian
176 {
177 public:
178  // Constructors
179  Calendar_ROC();
180 };
181 
182 
183 
184 class Calendar_dangi final : public Calendar_gregorian
185 {
186 public:
187  // Constructors
188  Calendar_dangi();
189 };
190 
191 
192 
194 {
195 public:
196  // Constructors
198 
199  // Methods in XExtendedCalendar
200  virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
201 };
202 
203 }
204 
205 #endif
206 
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual double SAL_CALL getDateTime() override
virtual double SAL_CALL getLocalDateTime() override
void init(const Era *_eraArray)
virtual ~Calendar_gregorian() override
Destructor.
virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) override
virtual css::uno::Sequence< css::i18n::CalendarItem > SAL_CALL getMonths() override
void setValue()
Set fields internally.
virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() override
OUString getDisplayStringImpl(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode)
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getPartitiveMonths2() override
const sal_Int16 FIELD_INDEX_COUNT
virtual css::i18n::Calendar SAL_CALL getLoadedCalendar() override
virtual OUString SAL_CALL getUniqueID() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getGenitiveMonths2() override
virtual void SAL_CALL setDateTime(double fTimeInDays) override
virtual OUString SAL_CALL getDisplayString(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode) override
void submitFields()
Submit fieldSetValue array according to fieldSet.
virtual sal_Bool SAL_CALL isValid() override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getMonths2() override
bool getCombinedOffset(sal_Int32 &o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex) const
Used by getZoneOffset() and getDSTOffset().
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::CalendarItem > SAL_CALL getDays() override
const sal_uInt8 kDisplayEraForcedLongYear
unsigned char sal_Bool
sal_Int16 fieldValue[FIELD_INDEX_COUNT]
Constant values shared between i18npool and, for example, the number formatter.
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_Bool SAL_CALL supportsService(const OUString &ServiceName) override
bool getZoneOffset(sal_Int32 &o_nOffset) const
Obtain combined field values for timezone offset (minutes+secondmillis) in milliseconds and whether f...
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) override
sal_Int16 fieldSetValue[FIELD_INDEX_COUNT]
virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getDays2() override
unsigned char sal_uInt8
rtl::Reference< NativeNumberSupplierService > mxNatNum
virtual OUString SAL_CALL getDisplayString(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode) override
virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() override
virtual sal_Int16 SAL_CALL getFirstDayOfWeek() override
virtual void SAL_CALL setLocalDateTime(double TimeInDays) override
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) override
std::unique_ptr< icu::Calendar > body
virtual void SAL_CALL loadCalendar(const OUString &uniqueID, const css::lang::Locale &rLocale) override
virtual css::i18n::Calendar2 SAL_CALL getLoadedCalendar2() override
bool setTimeZone(const OUString &rTimeZone)
sal_Int16 nValue