merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / view / inc / ScaleAutomatism.hxx
blob151e13dc157290ef677f75ba927738c0b5c20c94
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScaleAutomatism.hxx,v $
10 * $Revision: 1.3.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _CHART2_SCALEAUTOMATISM_HXX
31 #define _CHART2_SCALEAUTOMATISM_HXX
33 #include <com/sun/star/chart2/ExplicitIncrementData.hpp>
34 #include <com/sun/star/chart2/ExplicitScaleData.hpp>
35 #include <com/sun/star/chart2/ScaleData.hpp>
37 //.............................................................................
38 namespace chart
40 //.............................................................................
42 //-----------------------------------------------------------------------------
44 /** This class implements the calculation of automatic axis limits.
46 class ScaleAutomatism
48 public:
49 explicit ScaleAutomatism(
50 const ::com::sun::star::chart2::ScaleData& rSourceScale );
51 virtual ~ScaleAutomatism();
53 /** Expands own value range with the passed minimum and maximum. */
54 void expandValueRange( double fMinimum, double fMaximum );
56 /** Sets additional auto scaling options.
57 @param bExpandBorderToIncrementRhythm If true, expands automatic
58 borders to the fixed or calculated increment rhythm.
59 @param bExpandIfValuesCloseToBorder If true, expands automatic borders
60 if values are too close (closer than 1/21 of visible area).
61 @param bExpandWideValuesToZero If true, expands automatic border to
62 zero, if source values are positive only or negative only, and if
63 the absolute values are wide spread (at least one value is less
64 than 5/6 of absolute maximum), or if all values are equal.
65 @param bExpandNarrowValuesTowardZero If true, expands automatic border
66 toward zero (50% of the visible range), if source values are
67 positive only or negative only, and if the absolute values are
68 close to the absolute maximum (no value is less than 5/6 of
69 absolute maximum). */
70 void setAutoScalingOptions(
71 bool bExpandBorderToIncrementRhythm,
72 bool bExpandIfValuesCloseToBorder,
73 bool bExpandWideValuesToZero,
74 bool bExpandNarrowValuesTowardZero );
76 /** Sets the maximum allowed number of automatic main increments.
77 @descr The number of main increments may be limited e.g. by the length
78 of the axis and the font size of the axis caption text. */
79 void setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount );
81 /** Fills the passed scale data and increment data according to the own settings. */
82 void calculateExplicitScaleAndIncrement(
83 ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
84 ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ) const;
86 ::com::sun::star::chart2::ScaleData getScale() const;
88 private:
89 /** Fills the passed scale data and increment data for category scaling. */
90 void calculateExplicitIncrementAndScaleForCategory(
91 ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
92 ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement,
93 bool bAutoMinimum, bool bAutoMaximum ) const;
95 /** Fills the passed scale data and increment data for logarithmic scaling. */
96 void calculateExplicitIncrementAndScaleForLogarithmic(
97 ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
98 ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement,
99 bool bAutoMinimum, bool bAutoMaximum ) const;
101 /** Fills the passed scale data and increment data for linear scaling. */
102 void calculateExplicitIncrementAndScaleForLinear(
103 ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
104 ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement,
105 bool bAutoMinimum, bool bAutoMaximum ) const;
107 private:
108 ::com::sun::star::chart2::ScaleData m_aSourceScale;
110 double m_fValueMinimum; /// Minimum of all source values.
111 double m_fValueMaximum; /// Maximum of all source values.
112 sal_Int32 m_nMaximumAutoMainIncrementCount; /// Maximum number of automatic main increments.
113 bool m_bExpandBorderToIncrementRhythm; /// true = Expand to main increments.
114 bool m_bExpandIfValuesCloseToBorder; /// true = Expand if values are too close to the borders.
115 bool m_bExpandWideValuesToZero; /// true = Expand wide spread values to zero.
116 bool m_bExpandNarrowValuesTowardZero; /// true = Expand narrow range toward zero (add half of range).
119 //.............................................................................
120 } //namespace chart
121 //.............................................................................
122 #endif