1*f7bd9df4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f7bd9df4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f7bd9df4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f7bd9df4SAndrew Rist * distributed with this work for additional information 6*f7bd9df4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f7bd9df4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f7bd9df4SAndrew Rist * "License"); you may not use this file except in compliance 9*f7bd9df4SAndrew Rist * with the License. You may obtain a copy of the License at 10*f7bd9df4SAndrew Rist * 11*f7bd9df4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f7bd9df4SAndrew Rist * 13*f7bd9df4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f7bd9df4SAndrew Rist * software distributed under the License is distributed on an 15*f7bd9df4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f7bd9df4SAndrew Rist * KIND, either express or implied. See the License for the 17*f7bd9df4SAndrew Rist * specific language governing permissions and limitations 18*f7bd9df4SAndrew Rist * under the License. 19*f7bd9df4SAndrew Rist * 20*f7bd9df4SAndrew Rist *************************************************************/ 21*f7bd9df4SAndrew Rist 22*f7bd9df4SAndrew Rist 23cdf0e10cSrcweir #ifndef _I18N_CALENDAR_GREGORIAN_HXX_ 24cdf0e10cSrcweir #define _I18N_CALENDAR_GREGORIAN_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "calendarImpl.hxx" 27cdf0e10cSrcweir #include "nativenumbersupplier.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "warnings_guard_unicode_calendar.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir // ---------------------------------------------------- 32cdf0e10cSrcweir // class Calendar_gregorian 33cdf0e10cSrcweir // ---------------------------------------------------- 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n { 36cdf0e10cSrcweir 37cdf0e10cSrcweir struct Era { 38cdf0e10cSrcweir sal_Int32 year; 39cdf0e10cSrcweir sal_Int32 month; 40cdf0e10cSrcweir sal_Int32 day; 41cdf0e10cSrcweir }; 42cdf0e10cSrcweir 43cdf0e10cSrcweir const sal_Int16 FIELD_INDEX_COUNT = CalendarFieldIndex::FIELD_COUNT2; 44cdf0e10cSrcweir 45cdf0e10cSrcweir class Calendar_gregorian : public CalendarImpl 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir 49cdf0e10cSrcweir // Constructors 50cdf0e10cSrcweir Calendar_gregorian(); 51cdf0e10cSrcweir Calendar_gregorian(Era *_eraArray); 52cdf0e10cSrcweir void SAL_CALL init(Era *_eraArray); 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** 55cdf0e10cSrcweir * Destructor 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir ~Calendar_gregorian(); 58cdf0e10cSrcweir 59cdf0e10cSrcweir // Methods in XCalendar 60cdf0e10cSrcweir virtual void SAL_CALL loadCalendar(const rtl::OUString& uniqueID, const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException); 61cdf0e10cSrcweir virtual void SAL_CALL setDateTime(double nTimeInDays) throw(com::sun::star::uno::RuntimeException); 62cdf0e10cSrcweir virtual double SAL_CALL getDateTime() throw(com::sun::star::uno::RuntimeException); 63cdf0e10cSrcweir virtual void SAL_CALL setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ) throw(com::sun::star::uno::RuntimeException); 64cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getValue(sal_Int16 nFieldIndex) throw(com::sun::star::uno::RuntimeException); 65cdf0e10cSrcweir virtual void SAL_CALL addValue(sal_Int16 nFieldIndex, sal_Int32 nAmount) throw(com::sun::star::uno::RuntimeException); 66cdf0e10cSrcweir virtual sal_Bool SAL_CALL isValid() throw (com::sun::star::uno::RuntimeException); 67cdf0e10cSrcweir virtual Calendar SAL_CALL getLoadedCalendar() throw(com::sun::star::uno::RuntimeException); 68cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getUniqueID() throw(com::sun::star::uno::RuntimeException); 69cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getFirstDayOfWeek() throw(com::sun::star::uno::RuntimeException); 70cdf0e10cSrcweir virtual void SAL_CALL setFirstDayOfWeek(sal_Int16 nDay) throw(com::sun::star::uno::RuntimeException); 71cdf0e10cSrcweir virtual void SAL_CALL setMinimumNumberOfDaysForFirstWeek(sal_Int16 nDays) throw(com::sun::star::uno::RuntimeException); 72cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getMinimumNumberOfDaysForFirstWeek() throw(com::sun::star::uno::RuntimeException); 73cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getNumberOfMonthsInYear() throw(com::sun::star::uno::RuntimeException); 74cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getNumberOfDaysInWeek() throw(com::sun::star::uno::RuntimeException); 75cdf0e10cSrcweir virtual com::sun::star::uno::Sequence < CalendarItem > SAL_CALL getMonths() throw(com::sun::star::uno::RuntimeException); 76cdf0e10cSrcweir virtual com::sun::star::uno::Sequence < CalendarItem > SAL_CALL getDays() throw(com::sun::star::uno::RuntimeException); 77cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) throw(com::sun::star::uno::RuntimeException); 78cdf0e10cSrcweir 79cdf0e10cSrcweir // Methods in XExtendedCalendar 80cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException); 81cdf0e10cSrcweir 82cdf0e10cSrcweir //XServiceInfo 83cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException); 84cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw(com::sun::star::uno::RuntimeException); 85cdf0e10cSrcweir virtual com::sun::star::uno::Sequence < rtl::OUString > SAL_CALL getSupportedServiceNames() throw(com::sun::star::uno::RuntimeException); 86cdf0e10cSrcweir 87cdf0e10cSrcweir protected: 88cdf0e10cSrcweir Era *eraArray; 89cdf0e10cSrcweir icu::Calendar *body; 90cdf0e10cSrcweir NativeNumberSupplier aNatNum; 91cdf0e10cSrcweir const sal_Char* cCalendar; 92cdf0e10cSrcweir com::sun::star::lang::Locale aLocale; 93cdf0e10cSrcweir sal_uInt32 fieldSet; 94cdf0e10cSrcweir sal_Int16 fieldValue[FIELD_INDEX_COUNT]; 95cdf0e10cSrcweir sal_Int16 fieldSetValue[FIELD_INDEX_COUNT]; 96cdf0e10cSrcweir 97cdf0e10cSrcweir virtual void mapToGregorian() throw(com::sun::star::uno::RuntimeException); 98cdf0e10cSrcweir virtual void mapFromGregorian() throw(com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir void getValue() throw(com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir 101cdf0e10cSrcweir private: 102cdf0e10cSrcweir Calendar aCalendar; 103cdf0e10cSrcweir 104cdf0e10cSrcweir /** Submit fieldSetValue array according to fieldSet. */ 105cdf0e10cSrcweir void submitFields() throw(com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir /** Submit fieldSetValue array according to fieldSet, plus YMDhms if >=0, 107cdf0e10cSrcweir plus zone and DST if != 0 */ 108cdf0e10cSrcweir 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); 109cdf0e10cSrcweir /** Set fields internally. */ 110cdf0e10cSrcweir void setValue() throw(com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir /** Obtain combined field values for timezone offset (minutes+secondmillis) 112cdf0e10cSrcweir in milliseconds and whether fields were set. */ 113cdf0e10cSrcweir bool getZoneOffset( sal_Int32 & o_nOffset ) const; 114cdf0e10cSrcweir /** Obtain combined field values for DST offset (minutes+secondmillis) in 115cdf0e10cSrcweir milliseconds and whether fields were set. */ 116cdf0e10cSrcweir bool getDSTOffset( sal_Int32 & o_nOffset ) const; 117cdf0e10cSrcweir /** Used by getZoneOffset() and getDSTOffset(). Parent is 118cdf0e10cSrcweir CalendarFieldIndex for offset in minutes, child is CalendarFieldIndex 119cdf0e10cSrcweir for offset in milliseconds. */ 120cdf0e10cSrcweir bool getCombinedOffset( sal_Int32 & o_nOffset, sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const; 121cdf0e10cSrcweir }; 122cdf0e10cSrcweir 123cdf0e10cSrcweir // ---------------------------------------------------- 124cdf0e10cSrcweir // class Calendar_hanja 125cdf0e10cSrcweir // ---------------------------------------------------- 126cdf0e10cSrcweir class Calendar_hanja : public Calendar_gregorian 127cdf0e10cSrcweir { 128cdf0e10cSrcweir public: 129cdf0e10cSrcweir // Constructors 130cdf0e10cSrcweir Calendar_hanja(); 131cdf0e10cSrcweir virtual void SAL_CALL loadCalendar(const rtl::OUString& uniqueID, const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException); 132cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getDisplayName(sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType) throw(com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir }; 134cdf0e10cSrcweir 135cdf0e10cSrcweir // ---------------------------------------------------- 136cdf0e10cSrcweir // class Calendar_gengou 137cdf0e10cSrcweir // ---------------------------------------------------- 138cdf0e10cSrcweir class Calendar_gengou : public Calendar_gregorian 139cdf0e10cSrcweir { 140cdf0e10cSrcweir public: 141cdf0e10cSrcweir // Constructors 142cdf0e10cSrcweir Calendar_gengou(); 143cdf0e10cSrcweir }; 144cdf0e10cSrcweir 145cdf0e10cSrcweir // ---------------------------------------------------- 146cdf0e10cSrcweir // class Calendar_ROC 147cdf0e10cSrcweir // ---------------------------------------------------- 148cdf0e10cSrcweir class Calendar_ROC : public Calendar_gregorian 149cdf0e10cSrcweir { 150cdf0e10cSrcweir public: 151cdf0e10cSrcweir // Constructors 152cdf0e10cSrcweir Calendar_ROC(); 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir 155cdf0e10cSrcweir // ---------------------------------------------------- 156cdf0e10cSrcweir // class Calendar_buddhist 157cdf0e10cSrcweir // ---------------------------------------------------- 158cdf0e10cSrcweir class Calendar_buddhist : public Calendar_gregorian 159cdf0e10cSrcweir { 160cdf0e10cSrcweir public: 161cdf0e10cSrcweir // Constructors 162cdf0e10cSrcweir Calendar_buddhist(); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // Methods in XExtendedCalendar 165cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) throw (com::sun::star::uno::RuntimeException); 166cdf0e10cSrcweir }; 167cdf0e10cSrcweir 168cdf0e10cSrcweir } } } } 169cdf0e10cSrcweir 170cdf0e10cSrcweir #endif 171