diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-29 15:26:37 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-29 15:26:37 +0000 |
commit | f851cc84497986e5af50a102e504270d5f2fbd70 (patch) | |
tree | 3070653a41da8947d92b6d802c526978701700db /chart2/source/view/axes/ScaleAutomatism.cxx | |
parent | 179cb343c8534c04b4d53b01290cb93395893133 (diff) | |
parent | 211dce571775ee68aa32a74a92645fc6caf148fb (diff) |
ab71: merge with DEV300_m54
Diffstat (limited to 'chart2/source/view/axes/ScaleAutomatism.cxx')
-rw-r--r-- | chart2/source/view/axes/ScaleAutomatism.cxx | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 29e4fc0d06da..5287ecbcdc13 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -33,7 +33,6 @@ #include "ScaleAutomatism.hxx" #include "macros.hxx" #include "TickmarkHelper.hxx" -#include "Scaling.hxx" #include "AxisHelper.hxx" #include <rtl/math.hxx> #include <tools/debug.hxx> @@ -134,7 +133,7 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( if( m_aSourceScale.AxisType==AxisType::PERCENT ) rExplicitScale.Minimum = 0.0; else if( ::rtl::math::isNan( m_fValueMinimum ) ) - rExplicitScale.Minimum = 0.0; //@todo get Minimum from scsaling or from plotter???? + rExplicitScale.Minimum = 0.0; //@todo get Minimum from scaling or from plotter???? else rExplicitScale.Minimum = m_fValueMinimum; } @@ -143,7 +142,7 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( if( bAutoMaximum ) { if( m_aSourceScale.AxisType==AxisType::PERCENT ) - rExplicitScale.Minimum = 1.0; + rExplicitScale.Maximum = 1.0; else if( ::rtl::math::isNan( m_fValueMaximum ) ) rExplicitScale.Maximum = 10.0; //@todo get Maximum from scaling or from plotter???? else @@ -257,6 +256,9 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( { // *** STEP 1: initialize the range data *** + const double fInputMinimum = rExplicitScale.Minimum; + const double fInputMaximum = rExplicitScale.Maximum; + double fSourceMinimum = rExplicitScale.Minimum; double fSourceMaximum = rExplicitScale.Maximum; @@ -269,7 +271,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( values. In the last step, the original values will be restored. */ uno::Reference< XScaling > xScaling = rExplicitScale.Scaling; if( !xScaling.is() ) - xScaling.set( new LogarithmicScaling ); + xScaling.set( AxisHelper::createLogarithmicScaling() ); uno::Reference< XScaling > xInverseScaling = xScaling->getInverseScaling(); fSourceMinimum = xScaling->doScaling( fSourceMinimum ); @@ -412,10 +414,38 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( // round to entire multiples of the distance and add additional space if( bAutoMinimum && m_bExpandBorderToIncrementRhythm ) + { fAxisMinimum = TickmarkHelper::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); + + //ensure valid values after scaling #i100995# + if( !bAutoDistance ) + { + double fCheck = xInverseScaling->doScaling( fAxisMinimum ); + if( !::rtl::math::isFinite( fCheck ) || fCheck <= 0 ) + { + bAutoDistance = true; + bHasCalculatedDistance = false; + continue; + } + } + } if( bAutoMaximum && m_bExpandBorderToIncrementRhythm ) + { fAxisMaximum = TickmarkHelper::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); + //ensure valid values after scaling #i100995# + if( !bAutoDistance ) + { + double fCheck = xInverseScaling->doScaling( fAxisMaximum ); + if( !::rtl::math::isFinite( fCheck ) || fCheck <= 0 ) + { + bAutoDistance = true; + bHasCalculatedDistance = false; + continue; + } + } + } + // set the resulting limits (swap back to negative range if needed) if( bSwapAndNegateRange ) { @@ -440,6 +470,22 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( // convert limits back to logarithmic scale rExplicitScale.Minimum = xInverseScaling->doScaling( rExplicitScale.Minimum ); rExplicitScale.Maximum = xInverseScaling->doScaling( rExplicitScale.Maximum ); + + //ensure valid values after scaling #i100995# + if( !::rtl::math::isFinite( rExplicitScale.Minimum ) || rExplicitScale.Minimum <= 0) + { + rExplicitScale.Minimum = fInputMinimum; + if( !::rtl::math::isFinite( rExplicitScale.Minimum ) || rExplicitScale.Minimum <= 0 ) + rExplicitScale.Minimum = 1.0; + } + if( !::rtl::math::isFinite( rExplicitScale.Maximum) || rExplicitScale.Maximum <= 0 ) + { + rExplicitScale.Maximum= fInputMaximum; + if( !::rtl::math::isFinite( rExplicitScale.Maximum) || rExplicitScale.Maximum <= 0 ) + rExplicitScale.Maximum = 10.0; + } + if( rExplicitScale.Maximum < rExplicitScale.Minimum ) + ::std::swap( rExplicitScale.Maximum, rExplicitScale.Minimum ); } //--------------------------------------------------------------- |