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