Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / i18npool / inc / calendar_gregorian.hxx
blob4a2569f1392a8aecdb28d3812314d148bf7deafe
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"
23 #include "nativenumbersupplier.hxx"
25 #include <unicode/calendar.h>
28 // class Calendar_gregorian
31 namespace com { namespace sun { namespace star { namespace i18n {
33 const sal_uInt8 kDisplayEraForcedLongYear = 0x01;
35 struct Era {
36 sal_Int32 year;
37 sal_Int32 month;
38 sal_Int32 day;
39 sal_uInt8 flags;
42 const sal_Int16 FIELD_INDEX_COUNT = CalendarFieldIndex::FIELD_COUNT2;
44 class Calendar_gregorian : public CalendarImpl
46 public:
48 // Constructors
49 Calendar_gregorian();
50 Calendar_gregorian(const Era *_eraArray);
51 void SAL_CALL init(const Era *_eraArray);
53 /**
54 * Destructor
56 virtual ~Calendar_gregorian();
58 // Methods in XCalendar
59 virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const css::lang::Locale& rLocale) throw(css::uno::RuntimeException, std::exception) override;
60 virtual void SAL_CALL setDateTime(double fTimeInDays) throw(css::uno::RuntimeException, std::exception) override;
61 virtual double SAL_CALL getDateTime() throw(css::uno::RuntimeException, std::exception) override;
62 virtual void SAL_CALL setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ) throw(css::uno::RuntimeException, std::exception) override;
63 virtual sal_Int16 SAL_CALL getValue(sal_Int16 nFieldIndex) throw(css::uno::RuntimeException, std::exception) override;
64 virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) throw(css::uno::RuntimeException, std::exception) override;
65 virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException, std::exception) override;
66 virtual Calendar SAL_CALL getLoadedCalendar() throw(css::uno::RuntimeException, std::exception) override;
67 virtual OUString SAL_CALL getUniqueID() throw(css::uno::RuntimeException, std::exception) override;
68 virtual sal_Int16 SAL_CALL getFirstDayOfWeek() throw(css::uno::RuntimeException, std::exception) override;
69 virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) throw(css::uno::RuntimeException, std::exception) override;
70 virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) throw(css::uno::RuntimeException, std::exception) override;
71 virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() throw(css::uno::RuntimeException, std::exception) override;
72 virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() throw(css::uno::RuntimeException, std::exception) override;
73 virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() throw(css::uno::RuntimeException, std::exception) override;
74 virtual css::uno::Sequence < CalendarItem > SAL_CALL getMonths() throw(css::uno::RuntimeException, std::exception) override;
75 virtual css::uno::Sequence < CalendarItem > SAL_CALL getDays() throw(css::uno::RuntimeException, std::exception) override;
76 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) throw(css::uno::RuntimeException, std::exception) override;
78 // Methods in XExtendedCalendar
79 virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (css::uno::RuntimeException, std::exception) override;
81 // XCalendar3
82 virtual Calendar2 SAL_CALL getLoadedCalendar2() throw(css::uno::RuntimeException, std::exception) override;
83 virtual css::uno::Sequence < CalendarItem2 > SAL_CALL getDays2() throw(css::uno::RuntimeException, std::exception) override;
84 virtual css::uno::Sequence < CalendarItem2 > SAL_CALL getMonths2() throw(css::uno::RuntimeException, std::exception) override;
85 virtual css::uno::Sequence < CalendarItem2 > SAL_CALL getGenitiveMonths2() throw(css::uno::RuntimeException, std::exception) override;
86 virtual css::uno::Sequence < CalendarItem2 > SAL_CALL getPartitiveMonths2() throw(css::uno::RuntimeException, std::exception) override;
88 // XCalendar4
89 virtual void SAL_CALL setLocalDateTime(double TimeInDays) throw(css::uno::RuntimeException, std::exception) override;
90 virtual double SAL_CALL getLocalDateTime() throw(css::uno::RuntimeException, std::exception) override;
92 //XServiceInfo
93 virtual OUString SAL_CALL getImplementationName() throw(css::uno::RuntimeException, std::exception) override;
94 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(css::uno::RuntimeException, std::exception) override;
95 virtual css::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
97 protected:
98 const Era *eraArray;
99 icu::Calendar *body;
100 css::uno::Reference<NativeNumberSupplierService> mxNatNum;
101 const sal_Char* cCalendar;
102 css::lang::Locale aLocale;
103 sal_uInt32 fieldSet;
104 sal_Int16 fieldValue[FIELD_INDEX_COUNT];
105 sal_Int16 fieldSetValue[FIELD_INDEX_COUNT];
107 virtual void mapToGregorian() throw(css::uno::RuntimeException);
108 virtual void mapFromGregorian() throw(css::uno::RuntimeException);
109 void getValue() throw(css::uno::RuntimeException);
111 OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode ) throw (css::uno::RuntimeException);
113 private:
114 Calendar2 aCalendar;
116 /** Submit fieldSetValue array according to fieldSet. */
117 void submitFields() throw(css::uno::RuntimeException);
118 /** Set fields internally. */
119 void setValue() throw(css::uno::RuntimeException);
120 /** Obtain combined field values for timezone offset (minutes+secondmillis)
121 in milliseconds and whether fields were set. */
122 bool getZoneOffset( sal_Int32 & o_nOffset ) const;
123 /** Obtain combined field values for DST offset (minutes+secondmillis) in
124 milliseconds and whether fields were set. */
125 bool getDSTOffset( sal_Int32 & o_nOffset ) const;
126 /** Used by getZoneOffset() and getDSTOffset(). Parent is
127 CalendarFieldIndex for offset in minutes, child is CalendarFieldIndex
128 for offset in milliseconds. */
129 bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
133 // class Calendar_hanja
135 class Calendar_hanja : public Calendar_gregorian
137 public:
138 // Constructors
139 Calendar_hanja();
140 virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const css::lang::Locale& rLocale) throw(css::uno::RuntimeException, std::exception) override;
141 virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) throw(css::uno::RuntimeException, std::exception) override;
145 // class Calendar_gengou
147 class Calendar_gengou : public Calendar_gregorian
149 public:
150 // Constructors
151 Calendar_gengou();
155 // class Calendar_ROC
157 class Calendar_ROC : public Calendar_gregorian
159 public:
160 // Constructors
161 Calendar_ROC();
165 // class Calendar_buddhist
167 class Calendar_buddhist : public Calendar_gregorian
169 public:
170 // Constructors
171 Calendar_buddhist();
173 // Methods in XExtendedCalendar
174 virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (css::uno::RuntimeException, std::exception) override;
177 } } } }
179 #endif
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */