LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/unotools - calendarwrapper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 4 100.0 %
Date: 2013-07-09 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 _UNOTOOLS_CALENDARWRAPPER_HXX
      21             : #define _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 XCalendar3;
      39             :     }
      40             : }}}
      41             : 
      42             : 
      43             : class UNOTOOLS_DLLPUBLIC CalendarWrapper
      44             : {
      45             :     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar3 >   xC;
      46             : 
      47             :             DateTime            aEpochStart;        // 1Jan1970
      48             : 
      49             : public:
      50             :                                 CalendarWrapper(
      51             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext
      52             :                                     );
      53             :                                 ~CalendarWrapper();
      54             : 
      55             : 
      56             :     // wrapper implementations of XCalendar
      57             : 
      58             :     void loadDefaultCalendar( const ::com::sun::star::lang::Locale& rLocale );
      59             :     void loadCalendar( const OUString& rUniqueID, const ::com::sun::star::lang::Locale& rLocale );
      60             :     ::com::sun::star::uno::Sequence< OUString > getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const;
      61             :     OUString getUniqueID() const;
      62             :     /// set UTC date/time
      63             :     void setDateTime( double nTimeInDays );
      64             :     /// get UTC date/time
      65             :     double getDateTime() const;
      66             :     /// convenience method to set local date/time
      67             :     void setLocalDateTime( double nTimeInDays );
      68             :     /// convenience method to get local date/time
      69             :     double getLocalDateTime() const;
      70             : 
      71             : 
      72             :     // wrapper implementations of XCalendar
      73             : 
      74             :     void setValue( sal_Int16 nFieldIndex, sal_Int16 nValue );
      75             :     bool isValid() const;
      76             :     sal_Int16 getValue( sal_Int16 nFieldIndex ) const;
      77             :     void addValue( sal_Int16 nFieldIndex, sal_Int32 nAmount );
      78             :     sal_Int16 getFirstDayOfWeek() const;
      79             :     sal_Int16 getNumberOfMonthsInYear() const;
      80             :     sal_Int16 getNumberOfDaysInWeek() const;
      81             :     OUString getDisplayName( sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType ) const;
      82             : 
      83             :     /** Convenience method to get timezone offset in milliseconds, taking both
      84             :         fields ZONE_OFFSET and ZONE_OFFSET_SECOND_MILLIS into account. */
      85             :     sal_Int32 getZoneOffsetInMillis() const;
      86             :     /** Convenience method to get DST offset in milliseconds, taking both
      87             :         fields DST_OFFSET and DST_OFFSET_SECOND_MILLIS into account. */
      88             :     sal_Int32 getDSTOffsetInMillis() const;
      89             : 
      90             : 
      91             :     // wrapper implementations of XExtendedCalendar
      92             : 
      93             :     OUString getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const;
      94             : 
      95             : 
      96             :     // wrapper implementations of XCalendar3
      97             : 
      98             :     ::com::sun::star::i18n::Calendar2 getLoadedCalendar() const;
      99             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDays() const;
     100             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getMonths() const;
     101             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getGenitiveMonths() const;
     102             :     ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getPartitiveMonths() const;
     103             : 
     104             : 
     105             :     // convenience methods
     106             : 
     107             :     /// get epoch start (should be 01Jan1970)
     108         361 :     inline  const DateTime&     getEpochStart() const
     109         361 :                                     { return aEpochStart; }
     110             : 
     111             :     /// set a local (!) Gregorian DateTime
     112         123 :     inline  void                setGregorianDateTime( const DateTime& rDateTime )
     113         123 :                                     { setLocalDateTime( rDateTime - aEpochStart ); }
     114             : 
     115             :     /// get the DateTime as a local (!) Gregorian DateTime
     116             :     inline  DateTime            getGregorianDateTime() const
     117             :                                     { return aEpochStart + getLocalDateTime(); }
     118             : 
     119             : private:
     120             : 
     121             :     /** get timezone or DST offset in milliseconds, fields are
     122             :         CalendarFieldIndex ZONE_OFFSET and ZONE_OFFSET_SECOND_MILLIS
     123             :         respectively DST_OFFSET and DST_OFFSET_SECOND_MILLIS.
     124             :      */
     125             :     sal_Int32 getCombinedOffsetInMillis( sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const;
     126             : };
     127             : 
     128             : #endif
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10