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
30namespace i18npool { class NativeNumberSupplierService; }
31
32
33
34namespace i18npool {
35
37
38struct Era {
39 sal_Int32 year;
40 sal_Int32 month;
41 sal_Int32 day;
43};
44
45const sal_Int16 FIELD_INDEX_COUNT = css::i18n::CalendarFieldIndex::FIELD_COUNT2;
46
48{
49public:
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
101protected:
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
121private:
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
149{
150public:
151 // Constructors
153 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
154};
155
157{
158public:
159 // Constructors
161 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override;
162};
163
164
166{
167public:
168 // Constructors
170};
171
172
173
175{
176public:
177 // Constructors
178 Calendar_ROC();
179};
180
181
182
184{
185public:
186 // Constructors
188};
189
190
191
193{
194public:
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 OUString SAL_CALL getDisplayString(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode) override
std::unique_ptr< icu::Calendar > body
sal_Int16 fieldSetValue[FIELD_INDEX_COUNT]
virtual double SAL_CALL getDateTime() override
void submitFields()
Submit fieldSetValue array according to fieldSet.
virtual void SAL_CALL loadCalendar(const OUString &uniqueID, const css::lang::Locale &rLocale) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getDays2() override
void init(const Era *_eraArray)
virtual void SAL_CALL setLocalDateTime(double TimeInDays) override
virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() override
virtual sal_Int16 SAL_CALL getFirstDayOfWeek() override
OUString getDisplayStringImpl(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode)
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getGenitiveMonths2() override
rtl::Reference< NativeNumberSupplierService > mxNatNum
virtual double SAL_CALL getLocalDateTime() override
virtual css::uno::Sequence< css::i18n::CalendarItem > SAL_CALL getMonths() override
virtual OUString SAL_CALL getDisplayString(sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode) override
virtual OUString SAL_CALL getUniqueID() override
virtual css::uno::Sequence< css::i18n::CalendarItem2 > SAL_CALL getMonths2() override
virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) override
virtual void SAL_CALL setDateTime(double fTimeInDays) override
bool getZoneOffset(sal_Int32 &o_nOffset) const
Obtain combined field values for timezone offset (minutes+secondmillis) in milliseconds and whether f...
virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) override
virtual ~Calendar_gregorian() override
Destructor.
void setValue()
Set fields internally.
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::CalendarItem2 > SAL_CALL getPartitiveMonths2() override
virtual css::i18n::Calendar2 SAL_CALL getLoadedCalendar2() override
virtual css::uno::Sequence< css::i18n::CalendarItem > SAL_CALL getDays() override
virtual sal_Bool SAL_CALL isValid() override
virtual css::i18n::Calendar SAL_CALL getLoadedCalendar() override
virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) override
bool setTimeZone(const OUString &rTimeZone)
sal_Int16 fieldValue[FIELD_INDEX_COUNT]
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_Int16 SAL_CALL getNumberOfDaysInWeek() override
bool getCombinedOffset(sal_Int32 &o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex) const
Used by getZoneOffset() and getDSTOffset().
virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) override
sal_Int16 nValue
Constant values shared between i18npool and, for example, the number formatter.
const sal_Int16 FIELD_INDEX_COUNT
const sal_uInt8 kDisplayEraForcedLongYear
unsigned char sal_uInt8
unsigned char sal_Bool