LCOV - code coverage report
Current view: top level - chart2/source/view/inc - ScaleAutomatism.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 3 66.7 %
Date: 2014-11-03 Functions: 2 3 66.7 %
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             : #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_SCALEAUTOMATISM_HXX
      20             : #define INCLUDED_CHART2_SOURCE_VIEW_INC_SCALEAUTOMATISM_HXX
      21             : 
      22             : #include "chartview/ExplicitScaleValues.hxx"
      23             : #include <com/sun/star/chart2/ScaleData.hpp>
      24             : 
      25             : #include <tools/date.hxx>
      26             : 
      27             : namespace chart
      28             : {
      29             : 
      30             : /** This class implements the calculation of automatic axis limits.
      31             : */
      32        1151 : class ScaleAutomatism
      33             : {
      34             : public:
      35             :     explicit            ScaleAutomatism(
      36             :                             const ::com::sun::star::chart2::ScaleData& rSourceScale, const Date& rNullDate );
      37             :     virtual             ~ScaleAutomatism();
      38             : 
      39             :     /** Expands own value range with the passed minimum and maximum. */
      40             :     void                expandValueRange( double fMinimum, double fMaximum );
      41             : 
      42             :     /** Sets additional auto scaling options.
      43             :         @param bExpandBorderToIncrementRhythm  If true, expands automatic
      44             :             borders to the fixed or calculated increment rhythm.
      45             :         @param bExpandIfValuesCloseToBorder  If true, expands automatic borders
      46             :             if values are too close (closer than 1/21 of visible area).
      47             :         @param bExpandWideValuesToZero  If true, expands automatic border to
      48             :             zero, if source values are positive only or negative only, and if
      49             :             the absolute values are wide spread (at least one value is less
      50             :             than 5/6 of absolute maximum), or if all values are equal.
      51             :         @param bExpandNarrowValuesTowardZero  If true, expands automatic border
      52             :             toward zero (50% of the visible range), if source values are
      53             :             positive only or negative only, and if the absolute values are
      54             :             close to the absolute maximum (no value is less than 5/6 of
      55             :             absolute maximum). */
      56             :     void                setAutoScalingOptions(
      57             :                             bool bExpandBorderToIncrementRhythm,
      58             :                             bool bExpandIfValuesCloseToBorder,
      59             :                             bool bExpandWideValuesToZero,
      60             :                             bool bExpandNarrowValuesTowardZero );
      61             : 
      62             :     /** Sets the maximum allowed number of automatic main increments.
      63             :         @descr  The number of main increments may be limited e.g. by the length
      64             :                 of the axis and the font size of the axis caption text. */
      65             :     void                setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount );
      66             : 
      67             :     /** Sets the time resolution to be used in case it is not set explicitly within the scale
      68             :     */
      69             :     void setAutomaticTimeResolution( sal_Int32 nTimeResolution );
      70             : 
      71             :     /** Fills the passed scale data and increment data according to the own settings. */
      72             :     void                calculateExplicitScaleAndIncrement(
      73             :                             ExplicitScaleData& rExplicitScale,
      74             :                             ExplicitIncrementData& rExplicitIncrement ) const;
      75             : 
      76        2276 :     ::com::sun::star::chart2::ScaleData getScale() const { return m_aSourceScale;}
      77           0 :     Date getNullDate() const { return m_aNullDate;}
      78             : 
      79             : private:
      80             :     /** Fills the passed scale data and increment data for category scaling. */
      81             :     void                calculateExplicitIncrementAndScaleForCategory(
      82             :                             ExplicitScaleData& rExplicitScale,
      83             :                             ExplicitIncrementData& rExplicitIncrement,
      84             :                             bool bAutoMinimum, bool bAutoMaximum ) const;
      85             : 
      86             :     /** Fills the passed scale data and increment data for logarithmic scaling. */
      87             :     void                calculateExplicitIncrementAndScaleForLogarithmic(
      88             :                             ExplicitScaleData& rExplicitScale,
      89             :                             ExplicitIncrementData& rExplicitIncrement,
      90             :                             bool bAutoMinimum, bool bAutoMaximum ) const;
      91             : 
      92             :     /** Fills the passed scale data and increment data for linear scaling. */
      93             :     void                calculateExplicitIncrementAndScaleForLinear(
      94             :                             ExplicitScaleData& rExplicitScale,
      95             :                             ExplicitIncrementData& rExplicitIncrement,
      96             :                             bool bAutoMinimum, bool bAutoMaximum ) const;
      97             : 
      98             :     /** Fills the passed scale data and increment data for date-time axis. */
      99             :     void                calculateExplicitIncrementAndScaleForDateTimeAxis(
     100             :                             ExplicitScaleData& rExplicitScale,
     101             :                             ExplicitIncrementData& rExplicitIncrement,
     102             :                             bool bAutoMinimum, bool bAutoMaximum ) const;
     103             : 
     104             : private:
     105             :     ::com::sun::star::chart2::ScaleData             m_aSourceScale;
     106             : 
     107             :     double              m_fValueMinimum;                    /// Minimum of all source values.
     108             :     double              m_fValueMaximum;                    /// Maximum of all source values.
     109             :     sal_Int32           m_nMaximumAutoMainIncrementCount;   /// Maximum number of automatic main increments.
     110             :     bool                m_bExpandBorderToIncrementRhythm;   /// true = Expand to main increments.
     111             :     bool                m_bExpandIfValuesCloseToBorder;     /// true = Expand if values are too close to the borders.
     112             :     bool                m_bExpandWideValuesToZero;          /// true = Expand wide spread values to zero.
     113             :     bool                m_bExpandNarrowValuesTowardZero;    /// true = Expand narrow range toward zero (add half of range).
     114             :     sal_Int32           m_nTimeResolution;// a constant out of ::com::sun::star::chart::TimeUnit
     115             : 
     116             :     Date                m_aNullDate;
     117             : };
     118             : 
     119             : } //namespace chart
     120             : #endif
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10