LCOV - code coverage report
Current view: top level - chart2/source/view/axes - MinimumAndMaximumSupplier.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 102 82.4 %
Date: 2012-08-25 Functions: 15 19 78.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 58 92 63.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                 :            : 
      21                 :            : #include "MinimumAndMaximumSupplier.hxx"
      22                 :            : 
      23                 :            : #include <com/sun/star/chart/TimeUnit.hpp>
      24                 :            : 
      25                 :            : #include <rtl/math.hxx>
      26                 :            : #include <com/sun/star/awt/Size.hpp>
      27                 :            : 
      28                 :            : //.............................................................................
      29                 :            : namespace chart
      30                 :            : {
      31                 :            : //.............................................................................
      32                 :            : using namespace ::com::sun::star;
      33                 :            : 
      34         [ +  - ]:        984 : MergedMinimumAndMaximumSupplier::MergedMinimumAndMaximumSupplier()
      35                 :            : {
      36                 :        984 : }
      37                 :            : 
      38                 :        984 : MergedMinimumAndMaximumSupplier::~MergedMinimumAndMaximumSupplier()
      39                 :            : {
      40         [ -  + ]:        984 : }
      41                 :            : 
      42                 :        983 : void MergedMinimumAndMaximumSupplier::addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
      43                 :            : {
      44                 :        983 :     m_aMinimumAndMaximumSupplierList.insert( pMinimumAndMaximumSupplier );
      45                 :        983 : }
      46                 :            : 
      47                 :       3932 : bool MergedMinimumAndMaximumSupplier::hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
      48                 :            : {
      49                 :       3932 :     return m_aMinimumAndMaximumSupplierList.count( pMinimumAndMaximumSupplier ) != 0;
      50                 :            : }
      51                 :            : 
      52                 :       1962 : double MergedMinimumAndMaximumSupplier::getMinimumX()
      53                 :            : {
      54                 :            :     double fGlobalExtremum;
      55                 :       1962 :     ::rtl::math::setInf(&fGlobalExtremum, false);
      56         [ +  + ]:       3923 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
      57                 :            :     {
      58         [ +  - ]:       1961 :         double fLocalExtremum = (*aIt)->getMinimumX();
      59         [ +  - ]:       1961 :         if(fLocalExtremum<fGlobalExtremum)
      60                 :       1961 :             fGlobalExtremum=fLocalExtremum;
      61                 :            :     }
      62         [ +  + ]:       1962 :     if(::rtl::math::isInf(fGlobalExtremum))
      63                 :          1 :         ::rtl::math::setNan(&fGlobalExtremum);
      64                 :       1962 :     return fGlobalExtremum;
      65                 :            : }
      66                 :            : 
      67                 :       1962 : double MergedMinimumAndMaximumSupplier::getMaximumX()
      68                 :            : {
      69                 :            :     double fGlobalExtremum;
      70                 :       1962 :     ::rtl::math::setInf(&fGlobalExtremum, true);
      71         [ +  + ]:       3923 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
      72                 :            :     {
      73         [ +  - ]:       1961 :         double fLocalExtremum = (*aIt)->getMaximumX();
      74         [ +  - ]:       1961 :         if(fLocalExtremum>fGlobalExtremum)
      75                 :       1961 :             fGlobalExtremum=fLocalExtremum;
      76                 :            :     }
      77         [ +  + ]:       1962 :     if(::rtl::math::isInf(fGlobalExtremum))
      78                 :          1 :         ::rtl::math::setNan(&fGlobalExtremum);
      79                 :       1962 :     return fGlobalExtremum;
      80                 :            : }
      81                 :            : 
      82                 :       1976 : double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
      83                 :            : {
      84                 :            :     double fGlobalExtremum;
      85                 :       1976 :     ::rtl::math::setInf(&fGlobalExtremum, false);
      86         [ +  + ]:       3951 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
      87                 :            :     {
      88         [ +  - ]:       1975 :         double fLocalExtremum = (*aIt)->getMinimumYInRange( fMinimumX, fMaximumX, nAxisIndex );
      89         [ +  + ]:       1975 :         if(fLocalExtremum<fGlobalExtremum)
      90                 :       1961 :             fGlobalExtremum=fLocalExtremum;
      91                 :            :     }
      92         [ +  + ]:       1976 :     if(::rtl::math::isInf(fGlobalExtremum))
      93                 :         15 :         ::rtl::math::setNan(&fGlobalExtremum);
      94                 :       1976 :     return fGlobalExtremum;
      95                 :            : }
      96                 :            : 
      97                 :       1976 : double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
      98                 :            : {
      99                 :            :     double fGlobalExtremum;
     100                 :       1976 :     ::rtl::math::setInf(&fGlobalExtremum, true);
     101         [ +  + ]:       3951 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     102                 :            :     {
     103         [ +  - ]:       1975 :         double fLocalExtremum = (*aIt)->getMaximumYInRange( fMinimumX, fMaximumX, nAxisIndex );
     104         [ +  + ]:       1975 :         if(fLocalExtremum>fGlobalExtremum)
     105                 :       1961 :             fGlobalExtremum=fLocalExtremum;
     106                 :            :     }
     107         [ +  + ]:       1976 :     if(::rtl::math::isInf(fGlobalExtremum))
     108                 :         15 :         ::rtl::math::setNan(&fGlobalExtremum);
     109                 :       1976 :     return fGlobalExtremum;
     110                 :            : }
     111                 :            : 
     112                 :         28 : double MergedMinimumAndMaximumSupplier::getMinimumZ()
     113                 :            : {
     114                 :            :     double fGlobalExtremum;
     115                 :         28 :     ::rtl::math::setInf(&fGlobalExtremum, false);
     116         [ +  + ]:         56 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     117                 :            :     {
     118         [ +  - ]:         28 :         double fLocalExtremum = (*aIt)->getMinimumZ();
     119         [ +  - ]:         28 :         if(fLocalExtremum<fGlobalExtremum)
     120                 :         28 :             fGlobalExtremum=fLocalExtremum;
     121                 :            :     }
     122         [ -  + ]:         28 :     if(::rtl::math::isInf(fGlobalExtremum))
     123                 :          0 :         ::rtl::math::setNan(&fGlobalExtremum);
     124                 :         28 :     return fGlobalExtremum;
     125                 :            : }
     126                 :            : 
     127                 :         28 : double MergedMinimumAndMaximumSupplier::getMaximumZ()
     128                 :            : {
     129                 :            :     double fGlobalExtremum;
     130                 :         28 :     ::rtl::math::setInf(&fGlobalExtremum, true);
     131         [ +  + ]:         56 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     132                 :            :     {
     133         [ +  - ]:         28 :         double fLocalExtremum = (*aIt)->getMaximumZ();
     134         [ +  - ]:         28 :         if(fLocalExtremum>fGlobalExtremum)
     135                 :         28 :             fGlobalExtremum=fLocalExtremum;
     136                 :            :     }
     137         [ -  + ]:         28 :     if(::rtl::math::isInf(fGlobalExtremum))
     138                 :          0 :         ::rtl::math::setNan(&fGlobalExtremum);
     139                 :         28 :     return fGlobalExtremum;
     140                 :            : }
     141                 :            : 
     142                 :       3966 : bool MergedMinimumAndMaximumSupplier::isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex )
     143                 :            : {
     144                 :            :     // only return true, if *all* suppliers want to scale to the main tick marks
     145         [ +  + ]:       5922 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     146 [ +  - ][ +  + ]:       3964 :         if( !(*aIt)->isExpandBorderToIncrementRhythm( nDimensionIndex ) )
     147                 :       2008 :             return false;
     148                 :       3966 :     return true;
     149                 :            : }
     150                 :            : 
     151                 :       3966 : bool MergedMinimumAndMaximumSupplier::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex )
     152                 :            : {
     153                 :            :     // only return true, if *all* suppliers want to expand the range
     154         [ +  + ]:       5866 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     155 [ +  - ][ +  + ]:       3964 :         if( !(*aIt)->isExpandIfValuesCloseToBorder( nDimensionIndex ) )
     156                 :       2064 :             return false;
     157                 :       3966 :     return true;
     158                 :            : }
     159                 :            : 
     160                 :       3966 : bool MergedMinimumAndMaximumSupplier::isExpandWideValuesToZero( sal_Int32 nDimensionIndex )
     161                 :            : {
     162                 :            :     // already return true, if at least one supplier wants to expand the range
     163         [ +  + ]:       5974 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     164 [ +  - ][ +  + ]:       3964 :         if( (*aIt)->isExpandWideValuesToZero( nDimensionIndex ) )
     165                 :       1956 :             return true;
     166                 :       3966 :     return false;
     167                 :            : }
     168                 :            : 
     169                 :       3966 : bool MergedMinimumAndMaximumSupplier::isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex )
     170                 :            : {
     171                 :            :     // already return true, if at least one supplier wants to expand the range
     172         [ +  + ]:       5974 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     173 [ +  - ][ +  + ]:       3964 :         if( (*aIt)->isExpandNarrowValuesTowardZero( nDimensionIndex ) )
     174                 :       1956 :             return true;
     175                 :       3966 :     return false;
     176                 :            : }
     177                 :            : 
     178                 :          0 : bool MergedMinimumAndMaximumSupplier::isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex )
     179                 :            : {
     180                 :            :     // should not be called
     181         [ #  # ]:          0 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     182 [ #  # ][ #  # ]:          0 :         if( (*aIt)->isSeperateStackingForDifferentSigns( nDimensionIndex ) )
     183                 :          0 :             return true;
     184                 :          0 :     return false;
     185                 :            : }
     186                 :            : 
     187                 :        984 : void MergedMinimumAndMaximumSupplier::clearMinimumAndMaximumSupplierList()
     188                 :            : {
     189                 :        984 :     m_aMinimumAndMaximumSupplierList.clear();
     190                 :        984 : }
     191                 :            : 
     192                 :          0 : long MergedMinimumAndMaximumSupplier::calculateTimeResolutionOnXAxis()
     193                 :            : {
     194                 :          0 :     long nRet = ::com::sun::star::chart::TimeUnit::YEAR;
     195         [ #  # ]:          0 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     196                 :            :     {
     197         [ #  # ]:          0 :         long nCurrent = (*aIt)->calculateTimeResolutionOnXAxis();
     198         [ #  # ]:          0 :         if(nRet>nCurrent)
     199                 :          0 :             nRet=nCurrent;
     200                 :            :     }
     201                 :          0 :     return nRet;
     202                 :            : }
     203                 :            : 
     204                 :          0 : void MergedMinimumAndMaximumSupplier::setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate )
     205                 :            : {
     206         [ #  # ]:          0 :     for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
     207         [ #  # ]:          0 :         (*aIt)->setTimeResolutionOnXAxis( nTimeResolution, rNullDate );
     208                 :          0 : }
     209                 :            : 
     210                 :            : //.............................................................................
     211                 :            : } //namespace chart
     212                 :            : //.............................................................................
     213                 :            : 
     214                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10