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