LibreOffice Module unotools (master) 1
calendarwrapper.hxx
Go to the documentation of this file.
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
20#ifndef INCLUDED_UNOTOOLS_CALENDARWRAPPER_HXX
21#define INCLUDED_UNOTOOLS_CALENDARWRAPPER_HXX
22
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>
28
29namespace com::sun::star::uno { class XComponentContext; }
30namespace com::sun::star::i18n { class XCalendar4; }
31namespace com::sun::star::lang { struct Locale; }
32
34{
35 css::uno::Reference< css::i18n::XCalendar4 > xC;
36
37 const DateTime aEpochStart; // 1Jan1970
38
39public:
41 const css::uno::Reference< css::uno::XComponentContext > & rxContext
42 );
44
45 // wrapper implementations of XCalendar
46
61 void loadDefaultCalendar( const css::lang::Locale& rLocale, bool bTimeZoneUTC = true );
63 void loadCalendar( const OUString& rUniqueID, const css::lang::Locale& rLocale, bool bTimeZoneUTC = true );
64
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 );
69 */
70
71 css::uno::Sequence< OUString > getAllCalendars( const css::lang::Locale& rLocale ) const;
72 OUString getUniqueID() const;
74 void setDateTime( double fTimeInDays );
76 double getDateTime() const;
77
78 // For local setDateTime() and getDateTime() see further down at wrapper
79 // implementations of XCalendar4.
80
81 // wrapper implementations of XCalendar
82
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;
90
91 // wrapper implementations of XExtendedCalendar
92
93 OUString getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const;
94
95 // wrapper implementations of XCalendar3
96
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;
102
103 // wrapper implementations of XCalendar4
104
106 void setLocalDateTime( double fTimeInDays );
108 double getLocalDateTime() const;
109
110 // convenience methods
111
113 const DateTime& getEpochStart() const
114 { return aEpochStart; }
115
117 void setGregorianDateTime( const DateTime& rDateTime )
118 { setLocalDateTime( DateTime::Sub( rDateTime, aEpochStart)); }
119
120};
121
122#endif
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::i18n::XCalendar4 > xC
const DateTime aEpochStart
void setGregorianDateTime(const DateTime &rDateTime)
set a local (!) Gregorian DateTime
const DateTime & getEpochStart() const
get epoch start (should be 01Jan1970)
static double Sub(const DateTime &rDateTime1, const DateTime &rDateTime2)
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
#define UNOTOOLS_DLLPUBLIC