Bump version to 21.06.18.1
[LibreOffice.git] / include / unotools / calendarwrapper.hxx
blobaa0bb345c95b26e8bc638b27aff7c97fc9f136f9
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 .
20 #ifndef INCLUDED_UNOTOOLS_CALENDARWRAPPER_HXX
21 #define INCLUDED_UNOTOOLS_CALENDARWRAPPER_HXX
23 #include <tools/datetime.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/i18n/Calendar2.hpp>
27 #include <unotools/unotoolsdllapi.h>
29 namespace com::sun::star::uno { class XComponentContext; }
30 namespace com::sun::star::i18n { class XCalendar4; }
31 namespace com::sun::star::lang { struct Locale; }
33 class UNOTOOLS_DLLPUBLIC CalendarWrapper
35 css::uno::Reference< css::i18n::XCalendar4 > xC;
37 const DateTime aEpochStart; // 1Jan1970
39 public:
40 CalendarWrapper(
41 const css::uno::Reference< css::uno::XComponentContext > & rxContext
43 ~CalendarWrapper();
45 // wrapper implementations of XCalendar
47 /** Load the default calendar of a locale.
49 This adds a bool bTimeZoneUTC parameter which is not part of the UNO API to
50 facilitate handling of non time zone aware data.
52 @param bTimeZoneUTC
53 Default <TRUE/>. If <FALSE/>, the system's timezone is assigned
54 to the calendar, including all DST quirks like not existing
55 times on DST transition dates when switching to/from DST. As
56 current implementations and number parser/formatter don't store
57 or convert or calculate with time zones it is safer to use UTC,
58 which is not DST afflicted, otherwise surprises are lurking
59 (for example tdf#92503).
61 void loadDefaultCalendar( const css::lang::Locale& rLocale, bool bTimeZoneUTC = true );
62 /// This adds a bTimeZoneUTC parameter which is not part of the API.
63 void loadCalendar( const OUString& rUniqueID, const css::lang::Locale& rLocale, bool bTimeZoneUTC = true );
65 /* XXX NOTE: the time zone taking UNO API functions are not implemented as
66 * wrapper interface as they are not necessary/used so far. These are:
67 void loadDefaultCalendarTZ( const css::lang::Locale& rLocale, const OUString& rTimeZone );
68 void loadCalendarTZ( const OUString& rUniqueID, const css::lang::Locale& rLocale, const OUString& rTimeZone );
71 css::uno::Sequence< OUString > getAllCalendars( const css::lang::Locale& rLocale ) const;
72 OUString getUniqueID() const;
73 /// set UTC date/time
74 void setDateTime( double fTimeInDays );
75 /// get UTC date/time
76 double getDateTime() const;
78 // For local setDateTime() and getDateTime() see further down at wrapper
79 // implementations of XCalendar4.
81 // wrapper implementations of XCalendar
83 void setValue( sal_Int16 nFieldIndex, sal_Int16 nValue );
84 bool isValid() const;
85 sal_Int16 getValue( sal_Int16 nFieldIndex ) const;
86 sal_Int16 getFirstDayOfWeek() const;
87 sal_Int16 getNumberOfMonthsInYear() const;
88 sal_Int16 getNumberOfDaysInWeek() const;
89 OUString getDisplayName( sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType ) const;
91 // wrapper implementations of XExtendedCalendar
93 OUString getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const;
95 // wrapper implementations of XCalendar3
97 css::i18n::Calendar2 getLoadedCalendar() const;
98 css::uno::Sequence< css::i18n::CalendarItem2 > getDays() const;
99 css::uno::Sequence< css::i18n::CalendarItem2 > getMonths() const;
100 css::uno::Sequence< css::i18n::CalendarItem2 > getGenitiveMonths() const;
101 css::uno::Sequence< css::i18n::CalendarItem2 > getPartitiveMonths() const;
103 // wrapper implementations of XCalendar4
105 /// set local date/time
106 void setLocalDateTime( double fTimeInDays );
107 /// get local date/time
108 double getLocalDateTime() const;
110 // convenience methods
112 /// get epoch start (should be 01Jan1970)
113 const DateTime& getEpochStart() const
114 { return aEpochStart; }
116 /// set a local (!) Gregorian DateTime
117 void setGregorianDateTime( const DateTime& rDateTime )
118 { setLocalDateTime( rDateTime - aEpochStart ); }
122 #endif
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */