diff options
author | BaiXiaochun <bai.xiaochun.mofan@protonmail.com> | 2021-06-29 17:38:29 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-06-30 09:52:45 +0200 |
commit | 7838efe4b703945ccde963f8506c8c7744e04e6e (patch) | |
tree | 5b51faa8c5bd0799aafb1af702126f4b0feb852b /chart2 | |
parent | e9dc82b761a71369c4c49ae6d5fd8892f999c77a (diff) |
Purge out rtl::math::setNan
Change-Id: If8794c105e279afd4437517d3e61f2f900eb6490
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118123
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'chart2')
30 files changed, 174 insertions, 259 deletions
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 0a7b00cc884e..9b162acc06e8 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -442,9 +442,6 @@ std::vector<std::vector<double> > getDataSeriesYValuesFromChartType( const Refer CPPUNIT_ASSERT(xDSCont.is()); const Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries(); - double fNan; - rtl::math::setNan(&fNan); - std::vector<std::vector<double> > aRet; for (uno::Reference<chart2::XDataSeries> const & ds : aDataSeriesSeq) { @@ -472,7 +469,7 @@ std::vector<std::vector<double> > getDataSeriesYValuesFromChartType( const Refer if (any >>= fVal) aValues.push_back(fVal); else - aValues.push_back(fNan); + aValues.push_back(std::numeric_limits<double>::quiet_NaN()); } aRet.push_back(aValues); } diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 9fc30c823a79..aabdce1c8f65 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -28,7 +28,8 @@ #include <com/sun/star/chart/XChartDocument.hpp> #include <float.h> -#include <rtl/math.hxx> +#include <cmath> +#include <limits> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -57,7 +58,7 @@ uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Se aRet[nOuter][nInner] = rData[nOuter][nInner]; double& rValue = aRet[nOuter][nInner]; if( rValue == DBL_MIN ) - ::rtl::math::setNan( &rValue ); + rValue = std::numeric_limits<double>::quiet_NaN(); } } return aRet; diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 37e820eb5d94..e5e9be3b99a5 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -35,7 +35,6 @@ #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/virdev.hxx> -#include <rtl/math.hxx> #include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <toolkit/helper/vclunohelper.hxx> @@ -45,6 +44,7 @@ #include <com/sun/star/container/XIndexReplace.hpp> #include <algorithm> +#include <limits> using namespace ::com::sun::star; @@ -489,10 +489,8 @@ DataBrowser::DataBrowser(const css::uno::Reference<css::awt::XWindow> &rParent, m_rNumberEditController( new ::svt::FormattedFieldCellController( m_aNumberEditField.get() )), m_rTextEditController( new ::svt::EditCellController( m_aTextEditField.get() )) { - double fNan; - ::rtl::math::setNan( & fNan ); Formatter& rFormatter = m_aNumberEditField->get_formatter(); - rFormatter.SetDefaultValue( fNan ); + rFormatter.SetDefaultValue( std::numeric_limits<double>::quiet_NaN() ); rFormatter.TreatAsNumber( true ); RenewTable(); } @@ -741,16 +739,13 @@ OUString DataBrowser::GetCellText( sal_Int32 nRow, sal_uInt16 nColumnId ) const double DataBrowser::GetCellNumber( sal_Int32 nRow, sal_uInt16 nColumnId ) const { - double fResult; - ::rtl::math::setNan( & fResult ); - if(( nColumnId >= 1 ) && ( nRow >= 0 ) && m_apDataBrowserModel) { - fResult = m_apDataBrowserModel->getCellNumber( + return m_apDataBrowserModel->getCellNumber( static_cast< sal_Int32 >( nColumnId ) - 1, nRow ); } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } void DataBrowser::Resize() diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index c8359f74ab23..8de5c31e32dc 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -45,9 +45,8 @@ #include <tools/diagnose_ex.h> #include <comphelper/property.hxx> -#include <rtl/math.hxx> - #include <algorithm> +#include <limits> using namespace ::com::sun::star; @@ -582,9 +581,6 @@ DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn ) double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { - double fResult; - ::rtl::math::setNan( & fResult ); - tDataColumnVector::size_type nIndex( nAtColumn ); if( nIndex < m_aColumns.size() && m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) @@ -595,10 +591,10 @@ double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { Sequence< double > aValues( xData->getNumericalData()); if( nAtRow < aValues.getLength()) - fResult = aValues[nAtRow]; + return aValues[nAtRow]; } } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } uno::Any DataBrowserModel::getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ) diff --git a/chart2/source/inc/CommonFunctors.hxx b/chart2/source/inc/CommonFunctors.hxx index 9bdbce5af535..0340c82b692e 100644 --- a/chart2/source/inc/CommonFunctors.hxx +++ b/chart2/source/inc/CommonFunctors.hxx @@ -24,6 +24,8 @@ #include <rtl/ustring.hxx> #include "charttoolsdllapi.hxx" +#include <limits> + namespace chart::CommonFunctors { @@ -43,15 +45,13 @@ template< typename T > /** unary function to convert css::uno::Any into a double number. - <p>In case no number can be generated from the Any, NaN (see - rtl::math::SetNAN()) is returned.</p> + <p>In case no number can be generated from the Any, NaN is returned.</p> */ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble { double operator() ( const css::uno::Any & rAny ) { - double fResult; - ::rtl::math::setNan( & fResult ); + double fResult = std::numeric_limits<double>::quiet_NaN(); rAny >>= fResult; return fResult; } @@ -97,7 +97,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble double fResult = ::rtl::math::stringToDouble( rStr, '.', ',', & eConversionStatus ); if( eConversionStatus != rtl_math_ConversionStatus_Ok ) - ::rtl::math::setNan( & fResult ); + return std::numeric_limits<double>::quiet_NaN(); return fResult; } diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx index 76bb4a071b7c..4993c749f2ca 100644 --- a/chart2/source/tools/CommonConverters.cxx +++ b/chart2/source/tools/CommonConverters.cxx @@ -24,10 +24,11 @@ #include <com/sun/star/chart2/data/XDataSequence.hpp> #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> -#include <rtl/math.hxx> #include <osl/diagnose.h> #include <basegfx/matrix/b3dhommatrix.hxx> +#include <limits> + namespace chart { @@ -429,7 +430,7 @@ uno::Sequence< double > DataSequenceToDoubleSequence( for(sal_Int32 nN=aValues.getLength();nN--;) { if( !(aValues[nN] >>= aResult[nN]) ) - ::rtl::math::setNan( &aResult[nN] ); + aResult[nN] = std::numeric_limits<double>::quiet_NaN(); } } diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 80a75f333d28..3fbb442cccd8 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -57,6 +57,8 @@ #include <tools/diagnose_ex.h> #include <sal/log.hxx> +#include <limits> + using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using namespace ::std; @@ -975,8 +977,6 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c { Sequence< Sequence< Any > > aAnyCategories( xDataAccess->getAnyRowDescriptions() ); double fTest = 0.0; - double fNan = 0.0; - ::rtl::math::setNan( & fNan ); sal_Int32 nN = aAnyCategories.getLength(); for( ; nN--; ) { @@ -988,7 +988,7 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c Any& rAny = rCat[0]; if( !(rAny>>=fTest) ) { - rAny <<= fNan; + rAny <<= std::numeric_limits<double>::quiet_NaN(); } } } diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index bf65f58ec850..57919f3cbada 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -29,9 +29,11 @@ #include <com/sun/star/chart2/AxisType.hpp> #include <o3tl/safeint.hxx> -#include <rtl/math.hxx> +#include <rtl/ustrbuf.hxx> #include <tools/diagnose_ex.h> +#include <limits> + namespace chart { @@ -453,8 +455,7 @@ static bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& { if( aAny.hasValue() && !bContainsEmptyString )//empty string does not count as non date value! bOnlyDatesFound=false; - ::rtl::math::setNan( &aDate ); - rDateCategories.push_back( aDate ); + rDateCategories.push_back( std::numeric_limits<double>::quiet_NaN() ); } } std::sort( rDateCategories.begin(), rDateCategories.end() ); diff --git a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx index 1d389d6f99bf..a5063ee1039b 100644 --- a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <limits> #include <string_view> #include <ExponentialRegressionCurveCalculator.hxx> @@ -34,12 +35,10 @@ namespace chart { ExponentialRegressionCurveCalculator::ExponentialRegressionCurveCalculator() - : m_fLogSlope(0.0) - , m_fLogIntercept(0.0) + : m_fLogSlope(std::numeric_limits<double>::quiet_NaN()) + , m_fLogIntercept(std::numeric_limits<double>::quiet_NaN()) , m_fSign(1.0) { - ::rtl::math::setNan( & m_fLogSlope ); - ::rtl::math::setNan( & m_fLogIntercept ); } ExponentialRegressionCurveCalculator::~ExponentialRegressionCurveCalculator() @@ -65,9 +64,9 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression( nMax = aValues.first.size(); if( nMax <= 1 ) { - ::rtl::math::setNan( & m_fLogSlope ); - ::rtl::math::setNan( & m_fLogIntercept ); - ::rtl::math::setNan( & m_fCorrelationCoefficient );// actual it is coefficient of determination + m_fLogSlope = std::numeric_limits<double>::quiet_NaN(); + m_fLogIntercept = std::numeric_limits<double>::quiet_NaN(); + m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN();// actual it is coefficient of determination return; } m_fSign = -1.0; @@ -116,16 +115,13 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression( double SAL_CALL ExponentialRegressionCurveCalculator::getCurveValue( double x ) { - double fResult; - ::rtl::math::setNan( & fResult ); - if( ! ( std::isnan( m_fLogSlope ) || std::isnan( m_fLogIntercept ))) { - fResult = m_fSign * exp(m_fLogIntercept + x * m_fLogSlope); + return m_fSign * exp(m_fLogIntercept + x * m_fLogSlope); } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } uno::Sequence< geometry::RealPoint2D > SAL_CALL ExponentialRegressionCurveCalculator::getCurveValues( diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx index 35c615fe2873..1f5bcddc6c82 100644 --- a/chart2/source/tools/InternalData.cxx +++ b/chart2/source/tools/InternalData.cxx @@ -22,7 +22,6 @@ #include <strings.hrc> #include <osl/diagnose.h> -#include <rtl/math.hxx> #ifdef DEBUG_CHART2_TOOLS #define DEBUG_INTERNAL_DATA 1 @@ -34,6 +33,7 @@ #include <algorithm> #include <iterator> +#include <limits> using ::com::sun::star::uno::Sequence; @@ -129,10 +129,8 @@ void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows ) m_aColumnLabels.resize( m_nColumnCount ); m_aData.resize( m_nRowCount * m_nColumnCount ); - double fNan; - ::rtl::math::setNan( & fNan ); // set all values to Nan - m_aData = fNan; + m_aData = std::numeric_limits<double>::quiet_NaN(); for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow ) { @@ -296,9 +294,7 @@ bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount ) if( bGrow ) { - double fNan; - ::rtl::math::setNan( &fNan ); - tDataType aNewData( fNan, nNewSize ); + tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize ); // copy old data for( int nCol=0; nCol<m_nColumnCount; ++nCol ) static_cast< tDataType >( @@ -322,9 +318,7 @@ void InternalData::insertColumn( sal_Int32 nAfterIndex ) sal_Int32 nNewColumnCount = m_nColumnCount + 1; sal_Int32 nNewSize( nNewColumnCount * m_nRowCount ); - double fNan; - ::rtl::math::setNan( &fNan ); - tDataType aNewData( fNan, nNewSize ); + tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize ); // copy old data int nCol=0; @@ -379,9 +373,7 @@ void InternalData::insertRow( sal_Int32 nAfterIndex ) sal_Int32 nNewRowCount = m_nRowCount + 1; sal_Int32 nNewSize( m_nColumnCount * nNewRowCount ); - double fNan; - ::rtl::math::setNan( &fNan ); - tDataType aNewData( fNan, nNewSize ); + tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize ); // copy old data sal_Int32 nIndex = nAfterIndex + 1; @@ -416,9 +408,7 @@ void InternalData::deleteColumn( sal_Int32 nAtIndex ) sal_Int32 nNewColumnCount = m_nColumnCount - 1; sal_Int32 nNewSize( nNewColumnCount * m_nRowCount ); - double fNan; - ::rtl::math::setNan( &fNan ); - tDataType aNewData( fNan, nNewSize ); + tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize ); // copy old data int nCol=0; @@ -450,9 +440,7 @@ void InternalData::deleteRow( sal_Int32 nAtIndex ) sal_Int32 nNewRowCount = m_nRowCount - 1; sal_Int32 nNewSize( m_nColumnCount * nNewRowCount ); - double fNan; - ::rtl::math::setNan( &fNan ); - tDataType aNewData( fNan, nNewSize ); + tDataType aNewData( std::numeric_limits<double>::quiet_NaN(), nNewSize ); // copy old data sal_Int32 nIndex = nAtIndex; diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index e9beeb6d1d41..505159fa87b6 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -17,8 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <rtl/math.hxx> - #include <iterator> #include <InternalDataProvider.hxx> @@ -40,6 +38,7 @@ #include <comphelper/property.hxx> #include <tools/diagnose_ex.h> +#include <limits> #include <vector> #include <algorithm> @@ -1365,16 +1364,15 @@ uno::Sequence< OUString > SplitCategoriesProvider_ForComplexDescriptions::getStr // ____ XDateCategories ____ Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() { - double fNan = InternalDataProvider::getNotANumber(); - double fValue = fNan; vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); sal_Int32 nCount = aCategories.size(); Sequence< double > aDoubles( nCount ); sal_Int32 nN=0; for (auto const& category : aCategories) { + double fValue; if( category.empty() || !(category[0]>>=fValue) ) - fValue = fNan; + fValue = std::numeric_limits<double>::quiet_NaN(); aDoubles[nN++]=fValue; } return aDoubles; @@ -1489,9 +1487,7 @@ void SAL_CALL InternalDataProvider::removeChartDataChangeEventListener( double SAL_CALL InternalDataProvider::getNotANumber() { - double fNan; - ::rtl::math::setNan( & fNan ); - return fNan; + return std::numeric_limits<double>::quiet_NaN(); } sal_Bool SAL_CALL InternalDataProvider::isNotANumber( double nNumber ) diff --git a/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx b/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx index bfa5d9e4be5d..c9e000e0243e 100644 --- a/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx +++ b/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx @@ -30,11 +30,9 @@ namespace chart { LogarithmicRegressionCurveCalculator::LogarithmicRegressionCurveCalculator() : - m_fSlope( 0.0 ), - m_fIntercept( 0.0 ) + m_fSlope( std::numeric_limits<double>::quiet_NaN() ), + m_fIntercept( std::numeric_limits<double>::quiet_NaN() ) { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); } LogarithmicRegressionCurveCalculator::~LogarithmicRegressionCurveCalculator() @@ -53,9 +51,9 @@ void SAL_CALL LogarithmicRegressionCurveCalculator::recalculateRegression( const size_t nMax = aValues.first.size(); if( nMax <= 1 ) // at least 2 points { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); - ::rtl::math::setNan( & m_fCorrelationCoefficient ); + m_fSlope = std::numeric_limits<double>::quiet_NaN(); + m_fIntercept = std::numeric_limits<double>::quiet_NaN(); + m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN(); return; } @@ -89,16 +87,13 @@ void SAL_CALL LogarithmicRegressionCurveCalculator::recalculateRegression( double SAL_CALL LogarithmicRegressionCurveCalculator::getCurveValue( double x ) { - double fResult; - ::rtl::math::setNan( & fResult ); - if( ! ( std::isnan( m_fSlope ) || std::isnan( m_fIntercept ))) { - fResult = m_fSlope * log( x ) + m_fIntercept; + return m_fSlope * log( x ) + m_fIntercept; } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } uno::Sequence< geometry::RealPoint2D > SAL_CALL LogarithmicRegressionCurveCalculator::getCurveValues( diff --git a/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx b/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx index c9821343b4ec..70c3f1822de4 100644 --- a/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx +++ b/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx @@ -20,7 +20,9 @@ #include <MeanValueRegressionCurveCalculator.hxx> #include <osl/diagnose.h> -#include <rtl/math.hxx> + +#include <cmath> +#include <limits> using namespace ::com::sun::star; @@ -28,9 +30,8 @@ namespace chart { MeanValueRegressionCurveCalculator::MeanValueRegressionCurveCalculator() : - m_fMeanValue( 0.0 ) + m_fMeanValue( std::numeric_limits<double>::quiet_NaN() ) { - ::rtl::math::setNan( & m_fMeanValue ); } MeanValueRegressionCurveCalculator::~MeanValueRegressionCurveCalculator() @@ -59,7 +60,7 @@ void SAL_CALL MeanValueRegressionCurveCalculator::recalculateRegression( if( nMax == 0 ) { - ::rtl::math::setNan( & m_fMeanValue ); + m_fMeanValue = std::numeric_limits<double>::quiet_NaN(); } else { diff --git a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx index 1c456b8835e6..d21ec8d27714 100644 --- a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx +++ b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx @@ -22,7 +22,7 @@ #include <ResId.hxx> #include <strings.hrc> -#include <rtl/math.hxx> +#include <limits> #include <com/sun/star/chart2/MovingAverageType.hpp> @@ -43,7 +43,7 @@ void SAL_CALL MovingAverageRegressionCurveCalculator::recalculateRegression( const uno::Sequence< double >& aXValues, const uno::Sequence< double >& aYValues ) { - ::rtl::math::setNan( & m_fCorrelationCoefficient ); + m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN(); RegressionCalculationHelper::tDoubleVectorPair aValues( RegressionCalculationHelper::cleanup( @@ -134,9 +134,7 @@ void MovingAverageRegressionCurveCalculator::calculateValues( double SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValue( double /*x*/ ) { - double fResult; - rtl::math::setNan(&fResult); - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } uno::Sequence< geometry::RealPoint2D > SAL_CALL MovingAverageRegressionCurveCalculator::getCurveValues( diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx index 38e326cbbbc4..d6b22c1635f5 100644 --- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx @@ -21,6 +21,7 @@ #include <RegressionCalculationHelper.hxx> #include <cmath> +#include <limits> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> @@ -90,7 +91,7 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression( const uno::Sequence< double >& aXValues, const uno::Sequence< double >& aYValues ) { - rtl::math::setNan(&m_fCorrelationCoefficient); + m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN(); RegressionCalculationHelper::tDoubleVectorPair aValues( RegressionCalculationHelper::cleanup( aXValues, aYValues, RegressionCalculationHelper::isValid())); @@ -269,18 +270,13 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression( double SAL_CALL PolynomialRegressionCurveCalculator::getCurveValue( double x ) { - double fResult; - rtl::math::setNan(&fResult); - if (mCoefficients.empty()) - { - return fResult; - } + return std::numeric_limits<double>::quiet_NaN(); sal_Int32 aNoCoefficients = static_cast<sal_Int32>(mCoefficients.size()); // Horner's method - fResult = 0.0; + double fResult = 0.0; for (sal_Int32 i = aNoCoefficients - 1; i >= 0; i--) { fResult = mCoefficients[i] + (x * fResult); diff --git a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx index 89f6dc5b9e6e..1fa82434e0b4 100644 --- a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx @@ -21,6 +21,7 @@ #include <RegressionCalculationHelper.hxx> #include <SpecialCharacters.hxx> +#include <limits> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> @@ -30,12 +31,10 @@ namespace chart { PotentialRegressionCurveCalculator::PotentialRegressionCurveCalculator() - : m_fSlope(0.0) - , m_fIntercept(0.0) + : m_fSlope(std::numeric_limits<double>::quiet_NaN()) + , m_fIntercept(std::numeric_limits<double>::quiet_NaN()) , m_fSign(1.0) { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); } PotentialRegressionCurveCalculator::~PotentialRegressionCurveCalculator() @@ -61,9 +60,9 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression( nMax = aValues.first.size(); if( nMax <= 1 ) { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); - ::rtl::math::setNan( & m_fCorrelationCoefficient ); + m_fSlope = std::numeric_limits<double>::quiet_NaN(); + m_fIntercept = std::numeric_limits<double>::quiet_NaN(); + m_fCorrelationCoefficient = std::numeric_limits<double>::quiet_NaN(); return; } m_fSign = -1.0; @@ -101,16 +100,13 @@ void SAL_CALL PotentialRegressionCurveCalculator::recalculateRegression( double SAL_CALL PotentialRegressionCurveCalculator::getCurveValue( double x ) { - double fResult; - ::rtl::math::setNan( & fResult ); - if( ! ( std::isnan( m_fSlope ) || std::isnan( m_fIntercept ))) { - fResult = m_fIntercept * pow( x, m_fSlope ); + return m_fIntercept * pow( x, m_fSlope ); } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } uno::Sequence< geometry::RealPoint2D > SAL_CALL PotentialRegressionCurveCalculator::getCurveValues( diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx index a71e607e9f70..ff2f4d13a896 100644 --- a/chart2/source/tools/RegressionCurveCalculator.cxx +++ b/chart2/source/tools/RegressionCurveCalculator.cxx @@ -37,17 +37,15 @@ namespace chart { RegressionCurveCalculator::RegressionCurveCalculator() - : m_fCorrelationCoefficient(0.0) + : m_fCorrelationCoefficient(std::numeric_limits<double>::quiet_NaN()) , mDegree(2) , mForceIntercept(false) - , mInterceptValue(0.0) + , mInterceptValue(std::numeric_limits<double>::quiet_NaN()) , mPeriod(2) , mXName("x") , mYName("f(x)") , mnMovingType(0) { - rtl::math::setNan( &m_fCorrelationCoefficient ); - rtl::math::setNan( &mInterceptValue ); } RegressionCurveCalculator::~RegressionCurveCalculator() diff --git a/chart2/source/tools/Scaling.cxx b/chart2/source/tools/Scaling.cxx index e10757928a99..b49dab6d6fb9 100644 --- a/chart2/source/tools/Scaling.cxx +++ b/chart2/source/tools/Scaling.cxx @@ -18,10 +18,12 @@ */ #include <Scaling.hxx> -#include <rtl/math.hxx> #include <com/sun/star/uno/RuntimeException.hpp> #include <cppuhelper/supportsservice.hxx> +#include <cmath> +#include <limits> + namespace com::sun::star::uno { class XComponentContext; } namespace @@ -57,12 +59,9 @@ LogarithmicScaling::~LogarithmicScaling() double SAL_CALL LogarithmicScaling::doScaling( double value ) { - double fResult; if( std::isnan( value ) || std::isinf( value ) ) - ::rtl::math::setNan( & fResult ); - else - fResult = log( value ) / m_fLogOfBase; - return fResult; + return std::numeric_limits<double>::quiet_NaN(); + return std::log( value ) / m_fLogOfBase; } uno::Reference< XScaling > SAL_CALL LogarithmicScaling::getInverseScaling() @@ -106,12 +105,9 @@ ExponentialScaling::~ExponentialScaling() double SAL_CALL ExponentialScaling::doScaling( double value ) { - double fResult; if( std::isnan( value ) || std::isinf( value ) ) - ::rtl::math::setNan( & fResult ); - else - fResult = pow( m_fBase, value ); - return fResult; + return std::numeric_limits<double>::quiet_NaN(); + return std::pow( m_fBase, value ); } uno::Reference< XScaling > SAL_CALL ExponentialScaling::getInverseScaling() @@ -154,12 +150,9 @@ LinearScaling::~LinearScaling() double SAL_CALL LinearScaling::doScaling( double value ) { - double fResult; if( std::isnan( value ) || std::isinf( value ) ) - ::rtl::math::setNan( & fResult ); - else - fResult = m_fOffset + m_fSlope * value; - return fResult; + return std::numeric_limits<double>::quiet_NaN(); + return m_fOffset + m_fSlope * value; } uno::Reference< XScaling > SAL_CALL @@ -205,12 +198,9 @@ PowerScaling::~PowerScaling() double SAL_CALL PowerScaling::doScaling( double value ) { - double fResult; if( std::isnan( value ) || std::isinf( value ) ) - ::rtl::math::setNan( & fResult ); - else - fResult = pow( value, m_fExponent ); - return fResult; + return std::numeric_limits<double>::quiet_NaN(); + return std::pow( value, m_fExponent ); } uno::Reference< XScaling > SAL_CALL diff --git a/chart2/source/tools/StatisticsHelper.cxx b/chart2/source/tools/StatisticsHelper.cxx index ef9c141208a1..332843aaa307 100644 --- a/chart2/source/tools/StatisticsHelper.cxx +++ b/chart2/source/tools/StatisticsHelper.cxx @@ -22,7 +22,6 @@ #include <ErrorBar.hxx> #include <unonames.hxx> -#include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/chart2/XDataSeries.hpp> @@ -33,6 +32,9 @@ #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <tools/diagnose_ex.h> +#include <cmath> +#include <limits> + using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; using namespace ::com::sun::star; @@ -60,16 +62,11 @@ double lcl_getVariance( const Sequence< double > & rData, sal_Int32 & rOutValidC } } - double fResult; if( rOutValidCount == 0 ) - ::rtl::math::setNan( & fResult ); - else - { - const double fN = static_cast< double >( rOutValidCount ); - fResult = (fQuadSum - fSum*fSum/fN) / fN; - } + return std::numeric_limits<double>::quiet_NaN(); - return fResult; + const double fN = static_cast< double >( rOutValidCount ); + return (fQuadSum - fSum*fSum/fN) / fN; } Reference< chart2::data::XLabeledDataSequence > lcl_getErrorBarLabeledSequence( @@ -183,20 +180,11 @@ double StatisticsHelper::getStandardError( const Sequence< double > & rData ) { sal_Int32 nValCount; double fVar = lcl_getVariance( rData, nValCount ); - double fResult; - - if( nValCount == 0 || - std::isnan( fVar )) - { - ::rtl::math::setNan( & fResult ); - } - else - { - // standard-deviation / sqrt(n) - fResult = sqrt( fVar ) / sqrt( double(nValCount) ); - } - return fResult; + if( nValCount == 0 || std::isnan( fVar )) + return std::numeric_limits<double>::quiet_NaN(); + // standard-deviation / sqrt(n) + return sqrt( fVar ) / sqrt( double(nValCount) ); } Reference< chart2::data::XLabeledDataSequence > StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( @@ -238,8 +226,7 @@ double StatisticsHelper::getErrorFromDataSource( bool bPositiveValue, bool bYError /* = true */ ) { - double fResult = 0.0; - ::rtl::math::setNan( & fResult ); + double fResult = std::numeric_limits<double>::quiet_NaN(); Reference< chart2::data::XDataSequence > xValues( StatisticsHelper::getErrorDataSequenceFromDataSource( xDataSource, bPositiveValue, bYError )); diff --git a/chart2/source/view/axes/DateScaling.cxx b/chart2/source/view/axes/DateScaling.cxx index a926b5a43c51..6f352c486517 100644 --- a/chart2/source/view/axes/DateScaling.cxx +++ b/chart2/source/view/axes/DateScaling.cxx @@ -22,6 +22,8 @@ #include <rtl/math.hxx> #include <cppuhelper/supportsservice.hxx> +#include <limits> + namespace { @@ -55,7 +57,7 @@ double SAL_CALL DateScaling::doScaling( double value ) { double fResult(value); if( std::isnan( value ) || std::isinf( value ) ) - ::rtl::math::setNan( & fResult ); + return std::numeric_limits<double>::quiet_NaN(); else { Date aDate(m_aNullDate); @@ -131,7 +133,7 @@ double SAL_CALL InverseDateScaling::doScaling( double value ) { double fResult(value); if( std::isnan( value ) || std::isinf( value ) ) - ::rtl::math::setNan( & fResult ); + return std::numeric_limits<double>::quiet_NaN(); else { switch( m_nTimeUnit ) diff --git a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx index 2c9264786edf..422d08e64029 100644 --- a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx +++ b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx @@ -23,6 +23,8 @@ #include <rtl/math.hxx> +#include <limits> + namespace chart { using namespace ::com::sun::star; @@ -56,7 +58,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumX() fGlobalExtremum=fLocalExtremum; } if(std::isinf(fGlobalExtremum)) - ::rtl::math::setNan(&fGlobalExtremum); + return std::numeric_limits<double>::quiet_NaN(); return fGlobalExtremum; } @@ -71,7 +73,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumX() fGlobalExtremum=fLocalExtremum; } if(std::isinf(fGlobalExtremum)) - ::rtl::math::setNan(&fGlobalExtremum); + return std::numeric_limits<double>::quiet_NaN(); return fGlobalExtremum; } @@ -86,7 +88,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, do fGlobalExtremum=fLocalExtremum; } if(std::isinf(fGlobalExtremum)) - ::rtl::math::setNan(&fGlobalExtremum); + return std::numeric_limits<double>::quiet_NaN(); return fGlobalExtremum; } @@ -101,7 +103,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, do fGlobalExtremum=fLocalExtremum; } if(std::isinf(fGlobalExtremum)) - ::rtl::math::setNan(&fGlobalExtremum); + return std::numeric_limits<double>::quiet_NaN(); return fGlobalExtremum; } @@ -116,7 +118,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumZ() fGlobalExtremum=fLocalExtremum; } if(std::isinf(fGlobalExtremum)) - ::rtl::math::setNan(&fGlobalExtremum); + return std::numeric_limits<double>::quiet_NaN(); return fGlobalExtremum; } @@ -131,7 +133,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumZ() fGlobalExtremum=fLocalExtremum; } if(std::isinf(fGlobalExtremum)) - ::rtl::math::setNan(&fGlobalExtremum); + return std::numeric_limits<double>::quiet_NaN(); return fGlobalExtremum; } diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 7557f9b3d95b..f433a6bd076b 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -109,8 +109,8 @@ ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale, const Date& rNu void ScaleAutomatism::resetValueRange( ) { - ::rtl::math::setNan( &m_fValueMinimum ); - ::rtl::math::setNan( &m_fValueMaximum ); + m_fValueMinimum = std::numeric_limits<double>::quiet_NaN(); + m_fValueMaximum = std::numeric_limits<double>::quiet_NaN(); } void ScaleAutomatism::expandValueRange( double fMinimum, double fMaximum ) diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index fcb3391c693c..e2b983d7d63a 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -44,6 +44,7 @@ #include <basegfx/numeric/ftools.hxx> #include <algorithm> +#include <limits> #include <memory> using namespace ::com::sun::star; @@ -1109,18 +1110,15 @@ double VCartesianAxis::getLabelLineIntersectionValue() const double VCartesianAxis::getExtraLineIntersectionValue() const { - double fNan; - rtl::math::setNan(&fNan); - if( !m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis ) - return fNan; + return std::numeric_limits<double>::quiet_NaN(); double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY(); double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY(); if( *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin || *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax ) - return fNan; + return std::numeric_limits<double>::quiet_NaN(); return *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis; } diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 9421e94e6e9e..37b90cdfdbc0 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -36,7 +36,6 @@ #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> -#include <rtl/math.hxx> #include <sal/log.hxx> #include <osl/diagnose.h> @@ -45,10 +44,11 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <officecfg/Office/Compatibility.hxx> +#include <limits> + namespace chart { using namespace ::com::sun::star; -using namespace ::rtl::math; using namespace ::com::sun::star::chart2; AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel @@ -589,10 +589,10 @@ struct FormerPoint : m_fX(fX), m_fY(fY), m_fZ(fZ) {} FormerPoint() + : m_fX(std::numeric_limits<double>::quiet_NaN()) + , m_fY(std::numeric_limits<double>::quiet_NaN()) + , m_fZ(std::numeric_limits<double>::quiet_NaN()) { - ::rtl::math::setNan( &m_fX ); - ::rtl::math::setNan( &m_fY ); - ::rtl::math::setNan( &m_fZ ); } double m_fX; diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index ccdb6a9bc58d..02532136b075 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -394,11 +394,11 @@ struct FormerBarPoint : m_fX(fX), m_fUpperY(fUpperY), m_fLowerY(fLowerY), m_fZ(fZ) {} FormerBarPoint() + : m_fX(std::numeric_limits<double>::quiet_NaN()) + , m_fUpperY(std::numeric_limits<double>::quiet_NaN()) + , m_fLowerY(std::numeric_limits<double>::quiet_NaN()) + , m_fZ(std::numeric_limits<double>::quiet_NaN()) { - ::rtl::math::setNan( &m_fX ); - ::rtl::math::setNan( &m_fUpperY ); - ::rtl::math::setNan( &m_fLowerY ); - ::rtl::math::setNan( &m_fZ ); } double m_fX; diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index 9ad349b9f455..d5141be5cb58 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -24,16 +24,16 @@ #include <LabelPositionHelper.hxx> #include <com/sun/star/chart/DataLabelPlacement.hpp> -#include <rtl/math.hxx> #include <sal/log.hxx> #include <osl/diagnose.h> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <limits> + namespace chart { using namespace ::com::sun::star; -using namespace ::rtl::math; using namespace ::com::sun::star::chart2; BubbleChart::BubbleChart( const uno::Reference<XChartType>& xChartTypeModel @@ -145,10 +145,10 @@ struct FormerPoint : m_fX(fX), m_fY(fY), m_fZ(fZ) {} FormerPoint() + : m_fX(std::numeric_limits<double>::quiet_NaN()) + , m_fY(std::numeric_limits<double>::quiet_NaN()) + , m_fZ(std::numeric_limits<double>::quiet_NaN()) { - ::rtl::math::setNan( &m_fX ); - ::rtl::math::setNan( &m_fY ); - ::rtl::math::setNan( &m_fZ ); } double m_fX; diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index da270d37de48..2db1dd5512ae 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -32,16 +32,16 @@ #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> -#include <rtl/math.hxx> #include <osl/diagnose.h> #include <com/sun/star/drawing/XShapes.hpp> #include <officecfg/Office/Compatibility.hxx> +#include <limits> + namespace chart { using namespace ::com::sun::star; -using namespace ::rtl::math; using namespace ::com::sun::star::chart2; NetChart::NetChart( const uno::Reference<XChartType>& xChartTypeModel @@ -301,10 +301,11 @@ struct FormerPoint : m_fX(fX), m_fY(fY), m_fZ(fZ) {} FormerPoint() + : m_fX(std::numeric_limits<double>::quiet_NaN()) + , m_fY(std::numeric_limits<double>::quiet_NaN()) + , m_fZ(std::numeric_limits<double>::quiet_NaN()) + { - ::rtl::math::setNan( &m_fX ); - ::rtl::math::setNan( &m_fY ); - ::rtl::math::setNan( &m_fZ ); } double m_fX; diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index e77a7964ee71..08f94d00f513 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -34,12 +34,12 @@ #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <rtl/math.hxx> #include <sal/log.hxx> #include <osl/diagnose.h> #include <tools/diagnose_ex.h> #include <tools/helpers.hxx> +#include <limits> #include <memory> using namespace ::com::sun::star; @@ -198,9 +198,8 @@ PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel , m_pPosHelper( new PiePositionHelper( (m_nDimension==3) ? 0.0 : 90.0 ) ) , m_bUseRings(false) , m_bSizeExcludesLabelsAndExplodedSegments(bExcludingPositioning) + , m_fMaxOffset(std::numeric_limits<double>::quiet_NaN()) { - ::rtl::math::setNan(&m_fMaxOffset); - PlotterBase::m_pPosHelper = m_pPosHelper.get(); VSeriesPlotter::m_pMainPosHelper = m_pPosHelper.get(); m_pPosHelper->m_fRadiusOffset = 0.0; @@ -711,7 +710,7 @@ void PieChart::createShapes() nExplodeableSlot = m_aZSlots.front().size()-1; m_aLabelInfoList.clear(); - ::rtl::math::setNan(&m_fMaxOffset); + m_fMaxOffset = std::numeric_limits<double>::quiet_NaN(); sal_Int32 n3DRelativeHeight = 100; uno::Reference< beans::XPropertySet > xPropertySet( m_xChartTypeModel, uno::UNO_QUERY ); if ( (m_nDimension==3) && xPropertySet.is()) diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 2c62b46cc678..f69bb8a10dd7 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <limits> #include <memory> #include <VSeriesPlotter.hxx> #include <BaseGFXHelper.hxx> @@ -808,8 +809,7 @@ double lcl_getErrorBarLogicLength( bool bPositive, bool bYError ) { - double fResult; - ::rtl::math::setNan( & fResult ); + double fResult = std::numeric_limits<double>::quiet_NaN(); try { switch( nErrorBarStyle ) @@ -1726,7 +1726,7 @@ double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, s } } if(std::isinf(fMinimum)) - ::rtl::math::setNan(&fMinimum); + return std::numeric_limits<double>::quiet_NaN(); return fMinimum; } @@ -1759,7 +1759,7 @@ double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, s } } if(std::isinf(fMaximum)) - ::rtl::math::setNan(&fMaximum); + return std::numeric_limits<double>::quiet_NaN(); return fMaximum; } @@ -1833,9 +1833,9 @@ void VSeriesPlotter::getMinimumAndMaximumX( double& rfMinimum, double& rfMaximum } } if(std::isinf(rfMinimum)) - ::rtl::math::setNan(&rfMinimum); + rfMinimum = std::numeric_limits<double>::quiet_NaN(); if(std::isinf(rfMaximum)) - ::rtl::math::setNan(&rfMaximum); + rfMaximum = std::numeric_limits<double>::quiet_NaN(); } void VSeriesPlotter::getMinimumAndMaximumYInContinuousXRange( double& rfMinY, double& rfMaxY, double fMinX, double fMaxX, sal_Int32 nAxisIndex ) const @@ -1856,9 +1856,9 @@ void VSeriesPlotter::getMinimumAndMaximumYInContinuousXRange( double& rfMinY, do } } if(std::isinf(rfMinY)) - ::rtl::math::setNan(&rfMinY); + rfMinY = std::numeric_limits<double>::quiet_NaN(); if(std::isinf(rfMaxY)) - ::rtl::math::setNan(&rfMaxY); + rfMaxY = std::numeric_limits<double>::quiet_NaN(); } sal_Int32 VSeriesPlotter::getPointCount() const @@ -1944,9 +1944,9 @@ void VDataSeriesGroup::getMinimumAndMaximumX( double& rfMinimum, double& rfMaxim } } if(std::isinf(rfMinimum)) - ::rtl::math::setNan(&rfMinimum); + rfMinimum = std::numeric_limits<double>::quiet_NaN(); if(std::isinf(rfMaximum)) - ::rtl::math::setNan(&rfMaximum); + rfMaximum = std::numeric_limits<double>::quiet_NaN(); } namespace { @@ -2007,14 +2007,15 @@ public: void getTotalRange(double& rfMin, double& rfMax) const { - rtl::math::setNan(&rfMin); - rtl::math::setNan(&rfMax); - TotalStoreType aStore; getTotalStore(aStore); if (aStore.empty()) + { + rfMin = std::numeric_limits<double>::quiet_NaN(); + rfMax = std::numeric_limits<double>::quiet_NaN(); return; + } TotalStoreType::const_iterator it = aStore.begin(), itEnd = aStore.end(); rfMin = it->second.first; @@ -2085,8 +2086,8 @@ private: void VDataSeriesGroup::getMinimumAndMaximumYInContinuousXRange( double& rfMinY, double& rfMaxY, double fMinX, double fMaxX, sal_Int32 nAxisIndex ) const { - ::rtl::math::setNan(&rfMinY); - ::rtl::math::setNan(&rfMaxY); + rfMinY = std::numeric_limits<double>::quiet_NaN(); + rfMaxY = std::numeric_limits<double>::quiet_NaN(); if (m_aSeriesVector.empty()) // No data series. Bail out. @@ -2145,12 +2146,11 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex return; } - double fTotalSum, fPositiveSum, fNegativeSum, fFirstPositiveY, fFirstNegativeY; - ::rtl::math::setNan( &fTotalSum ); - ::rtl::math::setNan( &fPositiveSum ); - ::rtl::math::setNan( &fNegativeSum ); - ::rtl::math::setNan( &fFirstPositiveY ); - ::rtl::math::setNan( &fFirstNegativeY ); + double fTotalSum = std::numeric_limits<double>::quiet_NaN(); + double fPositiveSum = std::numeric_limits<double>::quiet_NaN(); + double fNegativeSum = std::numeric_limits<double>::quiet_NaN(); + double fFirstPositiveY = std::numeric_limits<double>::quiet_NaN(); + double fFirstNegativeY = std::numeric_limits<double>::quiet_NaN(); if( bSeparateStackingForDifferentSigns ) { @@ -2233,8 +2233,8 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategoryRange( nEndCategoryIndex=0; for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex <= nEndCategoryIndex; nCatIndex++ ) { - double fMinimumY; ::rtl::math::setNan(&fMinimumY); - double fMaximumY; ::rtl::math::setNan(&fMaximumY); + double fMinimumY = std::numeric_limits<double>::quiet_NaN(); + double fMaximumY = std::numeric_limits<double>::quiet_NaN(); calculateYMinAndMaxForCategory( nCatIndex , bSeparateStackingForDifferentSigns, fMinimumY, fMaximumY, nAxisIndex ); diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 247fe41a2d27..87abdb2810c8 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <limits> #include <memory> #include <VDataSeries.hxx> #include <ObjectIdentifier.hxx> @@ -67,12 +68,7 @@ double VDataSequence::getValue( sal_Int32 index ) const { if( 0<=index && index<Doubles.getLength() ) return Doubles[index]; - else - { - double fNan; - ::rtl::math::setNan( & fNan ); - return fNan; - } + return std::numeric_limits<double>::quiet_NaN(); } sal_Int32 VDataSequence::detectNumberFormatKey( sal_Int32 index ) const @@ -152,8 +148,8 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries ) , m_pValueSequenceForDataLabelNumberFormatDetection(&m_aValues_Y) - , m_fXMeanValue(1.0) - , m_fYMeanValue(1.0) + , m_fXMeanValue(std::numeric_limits<double>::quiet_NaN()) + , m_fYMeanValue(std::numeric_limits<double>::quiet_NaN()) , m_aAttributedDataPointIndexList() @@ -171,9 +167,6 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries ) , mpOldSeries(nullptr) , mnPercent(0.0) { - ::rtl::math::setNan( & m_fXMeanValue ); - ::rtl::math::setNan( & m_fYMeanValue ); - uno::Reference<data::XDataSource> xDataSource( xDataSeries, uno::UNO_QUERY ); uno::Sequence< uno::Reference< @@ -272,14 +265,14 @@ void VDataSeries::doSortByXValues() //prepare a vector for sorting std::vector< std::vector< double > > aTmp;//outer vector are points, inner vector are the different values of the point - double fNan; - ::rtl::math::setNan( & fNan ); sal_Int32 nPointIndex = 0; for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) { aTmp.push_back( - { ((nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] : fNan), - ((nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] : fNan) + { ((nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] + : std::numeric_limits<double>::quiet_NaN()), + ((nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] + : std::numeric_limits<double>::quiet_NaN()) } ); } @@ -435,7 +428,7 @@ void VDataSeries::setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex ) double VDataSeries::getXValue( sal_Int32 index ) const { - double fRet = 0.0; + double fRet = std::numeric_limits<double>::quiet_NaN(); if(m_aValues_X.is()) { if( 0<=index && index<m_aValues_X.getLength() ) @@ -447,16 +440,12 @@ double VDataSeries::getXValue( sal_Int32 index ) const fRet = nOldVal + (fRet - nOldVal) * mnPercent; } } - else - ::rtl::math::setNan( &fRet ); } else { // #i70133# always return correct X position - needed for short data series if( 0<=index /*&& index < m_nPointCount*/ ) fRet = index+1;//first category (index 0) matches with real number 1.0 - else - ::rtl::math::setNan( &fRet ); } lcl_maybeReplaceNanWithZero( fRet, getMissingValueTreatment() ); return fRet; @@ -464,7 +453,7 @@ double VDataSeries::getXValue( sal_Int32 index ) const double VDataSeries::getYValue( sal_Int32 index ) const { - double fRet = 0.0; + double fRet = std::numeric_limits<double>::quiet_NaN(); if(m_aValues_Y.is()) { if( 0<=index && index<m_aValues_Y.getLength() ) @@ -476,16 +465,12 @@ double VDataSeries::getYValue( sal_Int32 index ) const fRet = nOldVal + (fRet - nOldVal) * mnPercent; } } - else - ::rtl::math::setNan( &fRet ); } else { // #i70133# always return correct X position - needed for short data series if( 0<=index /*&& index < m_nPointCount*/ ) fRet = index+1;//first category (index 0) matches with real number 1.0 - else - ::rtl::math::setNan( &fRet ); } lcl_maybeReplaceNanWithZero( fRet, getMissingValueTreatment() ); return fRet; @@ -493,8 +478,8 @@ double VDataSeries::getYValue( sal_Int32 index ) const void VDataSeries::getMinMaxXValue(double& fMin, double& fMax) const { - rtl::math::setNan( &fMax ); - rtl::math::setNan( &fMin ); + fMax = std::numeric_limits<double>::quiet_NaN(); + fMin = std::numeric_limits<double>::quiet_NaN(); uno::Sequence< double > aValuesX = getAllX(); @@ -701,7 +686,7 @@ double VDataSeries::getMinimumofAllDifferentYValues( sal_Int32 index ) const } if( std::isinf(fMin) ) - ::rtl::math::setNan(&fMin); + return std::numeric_limits<double>::quiet_NaN(); return fMin; } @@ -737,7 +722,7 @@ double VDataSeries::getMaximumofAllDifferentYValues( sal_Int32 index ) const } if( std::isinf(fMax) ) - ::rtl::math::setNan(&fMax); + return std::numeric_limits<double>::quiet_NaN(); return fMax; } @@ -1112,11 +1097,7 @@ double VDataSeries::getValueByProperty( sal_Int32 nIndex, const OUString& rPropN { auto const itr = m_PropertyMap.find(rPropName); if (itr == m_PropertyMap.end()) - { - double fNan; - ::rtl::math::setNan( &fNan ); - return fNan; - } + return std::numeric_limits<double>::quiet_NaN(); const VDataSequence* pData = &itr->second; double fValue = pData->getValue(nIndex); |