LCOV - code coverage report
Current view: top level - include/unotools - calendarwrapper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 4 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          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             : 
      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>
      27             : #include <com/sun/star/lang/Locale.hpp>
      28             : #include <unotools/unotoolsdllapi.h>
      29             : 
      30             : namespace com { namespace sun { namespace star {
      31             :     namespace uno {
      32             :         class XComponentContext;
      33             :     }
      34             : }}}
      35             : 
      36             : namespace com { namespace sun { namespace star {
      37             :     namespace i18n {
      38             :         class XCalendar4;
      39             :     }
      40             : }}}
      41             : 
      42             : class UNOTOOLS_DLLPUBLIC CalendarWrapper
      43             : {
      44             :     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar4 >   xC;
      45             : 
      46             :             DateTime            aEpochStart;        // 1Jan1970
      47             : 
      48             : public:
      49             :                                 CalendarWrapper(
      50             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext
      51             :                                     );
      52             :                                 ~CalendarWrapper();
      53             : 
      54             :     // wrapper implementations of XCalendar
      55             : 
      56             :     void loadDefaultCalendar( const ::com::sun::star::lang::Locale& rLocale );
      57             :     void loadCalendar( const OUString& rUniqueID, const ::com::sun::star::lang::Locale& rLocale );
      58             :     ::com::sun::star::uno::Sequence< OUString > getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const;
      59             :     OUString getUniqueID() const;
      60             :     /// set UTC date/time
      61             :     void setDateTime( double fTimeInDays );
      62             :     /// get UTC date/time
      63             :     double getDateTime() const;
      64             : 
      65             :     // For local setDateTime() and getDateTime() see further down at wrapper
      66             :     // implementations of XCalendar4.
      67             : 
      68             :     // wrapper implementations of XCalendar
      69             : 
      70             :     void setValue( sal_Int16 nFieldIndex, sal_Int16 nValue );
      71             :     bool isValid() const;
      72             :     sal_Int16 getValue( sal_Int16 nFieldIndex ) const;
      73             :     void addValue( sal_Int16 nFieldIndex, sal_Int32 nAmount );
      74             :     sal_Int16 getFirstDayOfWeek() const;
      75             :     sal_Int16 getNumberOfMonthsInYear() const;
      76             :     sal_Int16 getNumberOfDaysInWeek() const;
      77             :     OUString getDisplayName( sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType ) const;
      78             : 
      79             :     // wrapper implementations of XExtendedCalendar
      80             : 
      81             :     OUString getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const;
      82             : 
      83             :     // wrapper implementations of XCalendar3
      84             : 
      85             :     ::com::sun::star::i18n::Calendar2 getLoadedCalendar() const;
      86             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDays() const;
      87             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getMonths() const;
      88             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getGenitiveMonths() const;
      89             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getPartitiveMonths() const;
      90             : 
      91             :     // wrapper implementations of XCalendar4
      92             : 
      93             :     /// set local date/time
      94             :     void setLocalDateTime( double fTimeInDays );
      95             :     /// get local date/time
      96             :     double getLocalDateTime() const;
      97             : 
      98             :     // convenience methods
      99             : 
     100             :     /// get epoch start (should be 01Jan1970)
     101        2507 :     inline  const DateTime&     getEpochStart() const
     102        2507 :                                     { return aEpochStart; }
     103             : 
     104             :     /// set a local (!) Gregorian DateTime
     105         691 :     inline  void                setGregorianDateTime( const DateTime& rDateTime )
     106         691 :                                     { setLocalDateTime( rDateTime - aEpochStart ); }
     107             : 
     108             :     /// get the DateTime as a local (!) Gregorian DateTime
     109             :     inline  DateTime            getGregorianDateTime() const
     110             :                                     { return aEpochStart + getLocalDateTime(); }
     111             : };
     112             : 
     113             : #endif
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11