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

Generated by: LCOV version 1.10