Line data Source code
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 : #include "nativenumbersupplier.hxx"
24 :
25 : #include <unicode/calendar.h>
26 :
27 :
28 : // class Calendar_gregorian
29 :
30 :
31 : namespace com { namespace sun { namespace star { namespace i18n {
32 :
33 : const sal_uInt8 kDisplayEraForcedLongYear = 0x01;
34 :
35 : struct Era {
36 : sal_Int32 year;
37 : sal_Int32 month;
38 : sal_Int32 day;
39 : sal_uInt8 flags;
40 : };
41 :
42 : const sal_Int16 FIELD_INDEX_COUNT = CalendarFieldIndex::FIELD_COUNT2;
43 :
44 : class Calendar_gregorian : public CalendarImpl
45 : {
46 : public:
47 :
48 : // Constructors
49 : Calendar_gregorian();
50 : Calendar_gregorian(const Era *_eraArray);
51 : void SAL_CALL init(const Era *_eraArray);
52 :
53 : /**
54 : * Destructor
55 : */
56 : virtual ~Calendar_gregorian();
57 :
58 : // Methods in XCalendar
59 : virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
60 : virtual void SAL_CALL setDateTime(double fTimeInDays) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
61 : virtual double SAL_CALL getDateTime() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
62 : virtual void SAL_CALL setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 : virtual sal_Int16 SAL_CALL getValue(sal_Int16 nFieldIndex) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 : virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
65 : virtual sal_Bool SAL_CALL isValid() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : virtual Calendar SAL_CALL getLoadedCalendar() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 : virtual OUString SAL_CALL getUniqueID() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
68 : virtual sal_Int16 SAL_CALL getFirstDayOfWeek() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 : virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
70 : virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 : virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 : virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 : virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : virtual com::sun::star::uno::Sequence < CalendarItem > SAL_CALL getMonths() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
75 : virtual com::sun::star::uno::Sequence < CalendarItem > SAL_CALL getDays() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 : virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 :
78 : // Methods in XExtendedCalendar
79 : virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : // XCalendar3
82 : virtual Calendar2 SAL_CALL getLoadedCalendar2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getDays2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 : virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getGenitiveMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getPartitiveMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 :
88 : // XCalendar4
89 : virtual void SAL_CALL setLocalDateTime(double TimeInDays) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual double SAL_CALL getLocalDateTime() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 :
92 : //XServiceInfo
93 : virtual OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 : virtual com::sun::star::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 :
97 : protected:
98 : const Era *eraArray;
99 : icu::Calendar *body;
100 : NativeNumberSupplierService aNatNum;
101 : const sal_Char* cCalendar;
102 : com::sun::star::lang::Locale aLocale;
103 : sal_uInt32 fieldSet;
104 : sal_Int16 fieldValue[FIELD_INDEX_COUNT];
105 : sal_Int16 fieldSetValue[FIELD_INDEX_COUNT];
106 :
107 : virtual void mapToGregorian() throw(com::sun::star::uno::RuntimeException);
108 : virtual void mapFromGregorian() throw(com::sun::star::uno::RuntimeException);
109 : void getValue() throw(com::sun::star::uno::RuntimeException);
110 :
111 : OUString getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, bool bEraMode ) throw (com::sun::star::uno::RuntimeException);
112 :
113 : private:
114 : Calendar2 aCalendar;
115 :
116 : /** Submit fieldSetValue array according to fieldSet. */
117 : void submitFields() throw(com::sun::star::uno::RuntimeException);
118 : /** Submit fieldSetValue array according to fieldSet, plus YMDhms if >=0,
119 : plus zone and DST if != 0 */
120 : void submitValues( sal_Int32 nYear, sal_Int32 nMonth, sal_Int32 nDay, sal_Int32 nHour, sal_Int32 nMinute, sal_Int32 nSecond, sal_Int32 nMilliSecond, sal_Int32 nZone, sal_Int32 nDST) throw(com::sun::star::uno::RuntimeException);
121 : /** Set fields internally. */
122 : void setValue() throw(com::sun::star::uno::RuntimeException);
123 : /** Obtain combined field values for timezone offset (minutes+secondmillis)
124 : in milliseconds and whether fields were set. */
125 : bool getZoneOffset( sal_Int32 & o_nOffset ) const;
126 : /** Obtain combined field values for DST offset (minutes+secondmillis) in
127 : milliseconds and whether fields were set. */
128 : bool getDSTOffset( sal_Int32 & o_nOffset ) const;
129 : /** Used by getZoneOffset() and getDSTOffset(). Parent is
130 : CalendarFieldIndex for offset in minutes, child is CalendarFieldIndex
131 : for offset in milliseconds. */
132 : bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
133 : };
134 :
135 :
136 : // class Calendar_hanja
137 :
138 0 : class Calendar_hanja : public Calendar_gregorian
139 : {
140 : public:
141 : // Constructors
142 : Calendar_hanja();
143 : virtual void SAL_CALL loadCalendar(const OUString& uniqueID, const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 : virtual OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 : };
146 :
147 :
148 : // class Calendar_gengou
149 :
150 0 : class Calendar_gengou : public Calendar_gregorian
151 : {
152 : public:
153 : // Constructors
154 : Calendar_gengou();
155 : };
156 :
157 :
158 : // class Calendar_ROC
159 :
160 2 : class Calendar_ROC : public Calendar_gregorian
161 : {
162 : public:
163 : // Constructors
164 : Calendar_ROC();
165 : };
166 :
167 :
168 : // class Calendar_buddhist
169 :
170 2 : class Calendar_buddhist : public Calendar_gregorian
171 : {
172 : public:
173 : // Constructors
174 : Calendar_buddhist();
175 :
176 : // Methods in XExtendedCalendar
177 : virtual OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 : };
179 :
180 : } } } }
181 :
182 : #endif
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|