LCOV - code coverage report
Current view: top level - chart2/source/view/axes - Tickmarks_Dates.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 65 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 116 0.0 %

           Branch data     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                 :            : #include "Tickmarks_Dates.hxx"
      21                 :            : #include "DateScaling.hxx"
      22                 :            : #include <rtl/math.hxx>
      23                 :            : #include "DateHelper.hxx"
      24                 :            : 
      25                 :            : //.............................................................................
      26                 :            : namespace chart
      27                 :            : {
      28                 :            : //.............................................................................
      29                 :            : using namespace ::com::sun::star;
      30                 :            : using namespace ::com::sun::star::chart2;
      31                 :            : using namespace ::rtl::math;
      32                 :            : using ::basegfx::B2DVector;
      33                 :            : using ::com::sun::star::chart::TimeUnit::DAY;
      34                 :            : using ::com::sun::star::chart::TimeUnit::MONTH;
      35                 :            : using ::com::sun::star::chart::TimeUnit::YEAR;
      36                 :            : 
      37                 :          0 : DateTickFactory::DateTickFactory(
      38                 :            :           const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement )
      39                 :            :             : m_aScale( rScale )
      40                 :            :             , m_aIncrement( rIncrement )
      41 [ #  # ][ #  # ]:          0 :             , m_xInverseScaling(NULL)
      42                 :            : {
      43                 :            :     //@todo: make sure that the scale is valid for the scaling
      44                 :            : 
      45         [ #  # ]:          0 :     if( m_aScale.Scaling.is() )
      46                 :            :     {
      47 [ #  # ][ #  # ]:          0 :         m_xInverseScaling = m_aScale.Scaling->getInverseScaling();
                 [ #  # ]
      48                 :            :         OSL_ENSURE( m_xInverseScaling.is(), "each Scaling needs to return a inverse Scaling" );
      49                 :            :     }
      50                 :            : 
      51                 :          0 :     m_fScaledVisibleMin = m_aScale.Minimum;
      52         [ #  # ]:          0 :     if( m_xInverseScaling.is() )
      53 [ #  # ][ #  # ]:          0 :         m_fScaledVisibleMin = m_aScale.Scaling->doScaling(m_fScaledVisibleMin);
      54                 :            : 
      55                 :          0 :     m_fScaledVisibleMax = m_aScale.Maximum;
      56         [ #  # ]:          0 :     if( m_xInverseScaling.is() )
      57 [ #  # ][ #  # ]:          0 :         m_fScaledVisibleMax = m_aScale.Scaling->doScaling(m_fScaledVisibleMax);
      58                 :          0 : }
      59                 :            : 
      60                 :          0 : DateTickFactory::~DateTickFactory()
      61                 :            : {
      62                 :          0 : }
      63                 :            : 
      64                 :          0 : void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShifted ) const
      65                 :            : {
      66         [ #  # ]:          0 :     rAllTickInfos.resize(2);
      67                 :          0 :     ::std::vector< TickInfo >& rMajorTicks = rAllTickInfos[0];
      68                 :          0 :     ::std::vector< TickInfo >& rMinorTicks = rAllTickInfos[1];
      69                 :          0 :     rMajorTicks.clear();
      70                 :          0 :     rMinorTicks.clear();
      71                 :            : 
      72                 :          0 :     Date aNull(m_aScale.NullDate);
      73                 :            : 
      74         [ #  # ]:          0 :     Date aDate = aNull + static_cast<long>(::rtl::math::approxFloor(m_aScale.Minimum));
      75         [ #  # ]:          0 :     Date aMaxDate = aNull + static_cast<long>(::rtl::math::approxFloor(m_aScale.Maximum));
      76                 :            : 
      77                 :          0 :     uno::Reference< chart2::XScaling > xScaling(m_aScale.Scaling);
      78                 :          0 :     uno::Reference< chart2::XScaling > xInverseScaling(m_xInverseScaling);
      79         [ #  # ]:          0 :     if( bShifted )
      80                 :            :     {
      81 [ #  # ][ #  # ]:          0 :         xScaling = new DateScaling(aNull,m_aScale.TimeResolution,true/*bShifted*/);
                 [ #  # ]
      82 [ #  # ][ #  # ]:          0 :         xInverseScaling = xScaling->getInverseScaling();
                 [ #  # ]
      83                 :            :     }
      84                 :            : 
      85                 :            :     //create major date tickinfos
      86         [ #  # ]:          0 :     while( aDate<= aMaxDate )
      87                 :            :     {
      88 [ #  # ][ #  # ]:          0 :         if( bShifted && aDate==aMaxDate )
                 [ #  # ]
      89                 :            :             break;
      90                 :            : 
      91 [ #  # ][ #  # ]:          0 :         TickInfo aNewTick(xInverseScaling); aNewTick.fScaledTickValue = aDate - aNull;
      92                 :            : 
      93         [ #  # ]:          0 :         if( xInverseScaling.is() )
      94 [ #  # ][ #  # ]:          0 :             aNewTick.fScaledTickValue = xScaling->doScaling(aNewTick.fScaledTickValue);
      95         [ #  # ]:          0 :         rMajorTicks.push_back( aNewTick );
      96                 :            : 
      97         [ #  # ]:          0 :         if(m_aIncrement.MajorTimeInterval.Number<=0)
      98                 :            :             break;
      99                 :            : 
     100                 :            :         //find next major date
     101      [ #  #  # ]:          0 :         switch( m_aIncrement.MajorTimeInterval.TimeUnit )
     102                 :            :         {
     103                 :            :         case DAY:
     104         [ #  # ]:          0 :             aDate += m_aIncrement.MajorTimeInterval.Number;
     105                 :          0 :             break;
     106                 :            :         case YEAR:
     107         [ #  # ]:          0 :             aDate = DateHelper::GetDateSomeYearsAway( aDate, m_aIncrement.MajorTimeInterval.Number );
     108                 :          0 :             break;
     109                 :            :         case MONTH:
     110                 :            :         default:
     111         [ #  # ]:          0 :             aDate = DateHelper::GetDateSomeMonthsAway( aDate, m_aIncrement.MajorTimeInterval.Number );
     112                 :          0 :             break;
     113                 :            :         }
     114 [ #  # ][ #  # ]:          0 :     }
     115                 :            : 
     116                 :            :     //create minor date tickinfos
     117         [ #  # ]:          0 :     aDate = aNull + static_cast<long>(::rtl::math::approxFloor(m_aScale.Minimum));
     118         [ #  # ]:          0 :     while( aDate<= aMaxDate )
     119                 :            :     {
     120 [ #  # ][ #  # ]:          0 :         if( bShifted && aDate==aMaxDate )
                 [ #  # ]
     121                 :            :             break;
     122                 :            : 
     123 [ #  # ][ #  # ]:          0 :         TickInfo aNewTick(xInverseScaling); aNewTick.fScaledTickValue = aDate - aNull;
     124         [ #  # ]:          0 :         if( xInverseScaling.is() )
     125 [ #  # ][ #  # ]:          0 :             aNewTick.fScaledTickValue = xScaling->doScaling(aNewTick.fScaledTickValue);
     126         [ #  # ]:          0 :         rMinorTicks.push_back( aNewTick );
     127                 :            : 
     128         [ #  # ]:          0 :         if(m_aIncrement.MinorTimeInterval.Number<=0)
     129                 :            :             break;
     130                 :            : 
     131                 :            :         //find next minor date
     132      [ #  #  # ]:          0 :         switch( m_aIncrement.MinorTimeInterval.TimeUnit )
     133                 :            :         {
     134                 :            :         case DAY:
     135         [ #  # ]:          0 :             aDate += m_aIncrement.MinorTimeInterval.Number;
     136                 :          0 :             break;
     137                 :            :         case YEAR:
     138         [ #  # ]:          0 :             aDate = DateHelper::GetDateSomeYearsAway( aDate, m_aIncrement.MinorTimeInterval.Number );
     139                 :          0 :             break;
     140                 :            :         case MONTH:
     141                 :            :         default:
     142         [ #  # ]:          0 :             aDate = DateHelper::GetDateSomeMonthsAway( aDate, m_aIncrement.MinorTimeInterval.Number );
     143                 :          0 :             break;
     144                 :            :         }
     145 [ #  # ][ #  # ]:          0 :     }
     146                 :          0 : }
     147                 :            : 
     148                 :          0 : void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
     149                 :            : {
     150                 :          0 :     getAllTicks( rAllTickInfos, false );
     151                 :          0 : }
     152                 :            : 
     153                 :          0 : void DateTickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
     154                 :            : {
     155                 :          0 :     getAllTicks( rAllTickInfos, true );
     156                 :          0 : }
     157                 :            : 
     158                 :            : //.............................................................................
     159                 :            : } //namespace chart
     160                 :            : //.............................................................................
     161                 :            : 
     162                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10