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 #pragma once
20 
21 #include "calendarImpl.hxx"
22 
23 #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
24 
25 #include <unicode/calendar.h>
26 #include <rtl/ref.hxx>
27 
28 #include <memory>
29 
30 namespace i18npool { class NativeNumberSupplierService; }
31 
32 
33 
34 namespace i18npool {
35 
37 
38 struct Era {
39  sal_Int32 year;
40  sal_Int32 month;
41  sal_Int32 day;
43 };
44 
45 const sal_Int16 FIELD_INDEX_COUNT = css::i18n::CalendarFieldIndex::FIELD_COUNT2;
46 
48 {
49 public:
50 
51  // Constructors
53  Calendar_gregorian(const Era *_eraArray);
54  void init(const Era *_eraArray);
55  bool setTimeZone( const OUString& rTimeZone );
56 
60  virtual ~Calendar_gregorian() override;
61 
62  // Methods in XCalendar
63  virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const css::lang::Locale& rLocale) override;
64  virtual void SAL_CALL setDateTime(double fTimeInDays) override;
65  virtual double SAL_CALL getDateTime() override;
66  virtual void SAL_CALL setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ) override;
67  virtual sal_Int16 SAL_CALL getValue(sal_Int16 nFieldIndex) override;
68  virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) override;
69  virtual sal_Bool SAL_CALL isValid() override;
70  virtual css::i18n:: Calendar SAL_CALL getLoadedCalendar() override;
71  virtual OUString SAL_CALL getUniqueID() override;
72  virtual sal_Int16 SAL_CALL getFirstDayOfWeek() override;
73  virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) override;
74  virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) override;
75  virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() override;
76  virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() override;
77  virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() override;
78  virtual css::uno::Sequence < css::i18n::CalendarItem > SAL_CALL getMonths() override;
79  virtual css::uno::Sequence < css::i18n::CalendarItem > SAL_CALL getDays() override;
80  virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
81 
82  // Methods in XExtendedCalendar
83  virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
84 
85  // XCalendar3
86  virtual css::i18n::Calendar2 SAL_CALL getLoadedCalendar2() override;
87  virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getDays2() override;
88  virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getMonths2() override;
89  virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getGenitiveMonths2() override;
90  virtual css::uno::Sequence < css::i18n::CalendarItem2 > SAL_CALL getPartitiveMonths2() override;
91 
92  // XCalendar4
93  virtual void SAL_CALL setLocalDateTime(double TimeInDays) override;
94  virtual double SAL_CALL getLocalDateTime() override;
95 
96  //XServiceInfo
97  virtual OUString SAL_CALL getImplementationName() override;
98  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
99  virtual css::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() override;
100 
101 protected:
102  const Era *eraArray;
103  std::unique_ptr<icu::Calendar> body;
105  const char* cCalendar;
106  css::lang::Locale aLocale;
107  sal_uInt32 fieldSet;
110 
112  virtual void mapToGregorian();
114  virtual void mapFromGregorian();
116  void getValue();
117 
119  OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode );
120 
121 private:
122  css::i18n::Calendar2 aCalendar;
123 
128  void submitFields();
133  void setValue();
136  bool getZoneOffset( sal_Int32 & o_nOffset ) const;
139  bool getDSTOffset( sal_Int32 & o_nOffset ) const;
143  bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
144 };
145 
146 
147 
148 class Calendar_hanja final : public Calendar_gregorian
149 {
150 public:
151  // Constructors
152  Calendar_hanja();
153  virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
154 };
155 
157 {
158 public:
159  // Constructors
161  virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
162 };
163 
164 
166 {
167 public:
168  // Constructors
169  Calendar_gengou();
170 };
171 
172 
173 
174 class Calendar_ROC final : public Calendar_gregorian
175 {
176 public:
177  // Constructors
178  Calendar_ROC();
179 };
180 
181 
182 
183 class Calendar_dangi final : public Calendar_gregorian
184 {
185 public:
186  // Constructors
187  Calendar_dangi();
188 };
189 
190 
191 
193 {
194 public:
195  // Constructors
197 
198  // Methods in XExtendedCalendar
199  virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) override;
200 };
201 
202 }
203 
204 /* 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