[Libreoffice-commits] core.git: basic/qa chart2/source sc/inc sc/source

BaiXiaochun (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 30 22:39:56 UTC 2021


 basic/qa/cppunit/test_scanner.cxx                     |    6 +--
 chart2/source/view/axes/MinimumAndMaximumSupplier.cxx |   21 +++--------
 chart2/source/view/axes/VCoordinateSystem.cxx         |    9 ++--
 chart2/source/view/charttypes/Splines.cxx             |   15 +++-----
 chart2/source/view/charttypes/VSeriesPlotter.cxx      |   33 ++++++++----------
 chart2/source/view/main/VDataSeries.cxx               |    7 +--
 sc/inc/math.hxx                                       |   12 +-----
 sc/source/core/data/dpitemdata.cxx                    |    4 +-
 sc/source/core/data/dputil.cxx                        |   10 +----
 9 files changed, 43 insertions(+), 74 deletions(-)

New commits:
commit 3964e0854507b2696ae0fbe48a4fb005c779947e
Author:     BaiXiaochun <bai.xiaochun.mofan at protonmail.com>
AuthorDate: Tue Jun 29 20:31:30 2021 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Jul 1 00:39:17 2021 +0200

    Purge out rtl::math::setInf
    
    Change-Id: I71af8273c672a4cbcbfefafffd0003ab266dcce6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118132
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx
index 5663c44d027e..6459ab45f6b1 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -13,7 +13,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/plugin/TestPlugIn.h>
 
-#include <rtl/math.hxx>
+#include <limits>
 
 #include <scanner.hxx>
 
@@ -654,11 +654,9 @@ void ScannerTest::testNumbers()
     // the buffer is artificially constrained by the scanner.
     CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // HACK
 
-    double fInf = 0.0;
-    rtl::math::setInf(&fInf, false);
     symbols = getSymbols("10e308", errors);
     CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
-    CPPUNIT_ASSERT_EQUAL(fInf, symbols[0].number);
+    CPPUNIT_ASSERT_EQUAL(std::numeric_limits<double>::infinity(), symbols[0].number);
     CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
     CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
     CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // math error, overflow
diff --git a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
index 422d08e64029..eaf5c4347379 100644
--- a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
+++ b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
@@ -21,8 +21,7 @@
 
 #include <com/sun/star/chart/TimeUnit.hpp>
 
-#include <rtl/math.hxx>
-
+#include <cmath>
 #include <limits>
 
 namespace chart
@@ -49,8 +48,7 @@ bool MergedMinimumAndMaximumSupplier::hasMinimumAndMaximumSupplier( MinimumAndMa
 
 double MergedMinimumAndMaximumSupplier::getMinimumX()
 {
-    double fGlobalExtremum;
-    ::rtl::math::setInf(&fGlobalExtremum, false);
+    double fGlobalExtremum = std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
         double fLocalExtremum = elem->getMinimumX();
@@ -64,8 +62,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumX()
 
 double MergedMinimumAndMaximumSupplier::getMaximumX()
 {
-    double fGlobalExtremum;
-    ::rtl::math::setInf(&fGlobalExtremum, true);
+    double fGlobalExtremum = -std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
         double fLocalExtremum = elem->getMaximumX();
@@ -79,8 +76,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumX()
 
 double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
 {
-    double fGlobalExtremum;
-    ::rtl::math::setInf(&fGlobalExtremum, false);
+    double fGlobalExtremum = std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
         double fLocalExtremum = elem->getMinimumYInRange( fMinimumX, fMaximumX, nAxisIndex );
@@ -94,8 +90,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, do
 
 double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
 {
-    double fGlobalExtremum;
-    ::rtl::math::setInf(&fGlobalExtremum, true);
+    double fGlobalExtremum = -std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
         double fLocalExtremum = elem->getMaximumYInRange( fMinimumX, fMaximumX, nAxisIndex );
@@ -109,8 +104,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, do
 
 double MergedMinimumAndMaximumSupplier::getMinimumZ()
 {
-    double fGlobalExtremum;
-    ::rtl::math::setInf(&fGlobalExtremum, false);
+    double fGlobalExtremum = std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
         double fLocalExtremum = elem->getMinimumZ();
@@ -124,8 +118,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumZ()
 
 double MergedMinimumAndMaximumSupplier::getMaximumZ()
 {
-    double fGlobalExtremum;
-    ::rtl::math::setInf(&fGlobalExtremum, true);
+    double fGlobalExtremum = -std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
         double fLocalExtremum = elem->getMaximumZ();
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 1c900b392233..c9364b63a76a 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -34,8 +34,9 @@
 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
 #include <comphelper/sequence.hxx>
 #include <tools/diagnose_ex.h>
+
 #include <algorithm>
-#include <rtl/math.hxx>
+#include <limits>
 
 namespace chart
 {
@@ -354,10 +355,8 @@ void VCoordinateSystem::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAuto
         m_aMergedMinMaxSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() );
     }
 
-    double fMin = 0.0;
-    double fMax = 0.0;
-    ::rtl::math::setInf(&fMin, false);
-    ::rtl::math::setInf(&fMax, true);
+    double fMin = std::numeric_limits<double>::infinity();
+    double fMax = -std::numeric_limits<double>::infinity();
     if( nDimIndex == 0 )
     {
         // x dimension
diff --git a/chart2/source/view/charttypes/Splines.cxx b/chart2/source/view/charttypes/Splines.cxx
index 338179b2827c..521b559776ee 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -18,13 +18,14 @@
  */
 
 #include "Splines.hxx"
-#include <rtl/math.hxx>
 #include <osl/diagnose.h>
 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
 
 #include <vector>
 #include <algorithm>
 #include <memory>
+#include <cmath>
+#include <limits>
 
 namespace chart
 {
@@ -120,9 +121,8 @@ lcl_SplineCalculation::lcl_SplineCalculation(
           m_fYpN( fYnFirstDerivation ),
           m_nKLow( 0 ),
           m_nKHigh( rSortedPoints.size() - 1 ),
-          m_fLastInterpolatedValue(0.0)
+          m_fLastInterpolatedValue(std::numeric_limits<double>::infinity())
 {
-    ::rtl::math::setInf( &m_fLastInterpolatedValue, false );
     Calculate();
 }
 
@@ -133,9 +133,8 @@ lcl_SplineCalculation::lcl_SplineCalculation(
           m_fYpN( 0.0 ),  /*dummy*/
           m_nKLow( 0 ),
           m_nKHigh( rSortedPoints.size() - 1 ),
-          m_fLastInterpolatedValue(0.0)
+          m_fLastInterpolatedValue(std::numeric_limits<double>::infinity())
 {
-    ::rtl::math::setInf( &m_fLastInterpolatedValue, false );
     CalculatePeriodic();
 }
 
@@ -600,10 +599,8 @@ void SplineCalculater::CalculateCubicSplines(
         }
         else // generate the kind "natural spline"
         {
-            double fInfty;
-            ::rtl::math::setInf( &fInfty, false );
-            double fXDerivation = fInfty;
-            double fYDerivation = fInfty;
+            double fXDerivation = std::numeric_limits<double>::infinity();
+            double fYDerivation = std::numeric_limits<double>::infinity();
             aSplineX.reset(new lcl_SplineCalculation( aInputX, fXDerivation, fXDerivation ));
             aSplineY.reset(new lcl_SplineCalculation( aInputY, fYDerivation, fYDerivation ));
         }
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index f69bb8a10dd7..ee89ab640134 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -851,8 +851,7 @@ double lcl_getErrorBarLogicLength(
                                              ? OUString("PositiveError")
                                              : OUString("NegativeError") ) >>= fPercent )
                 {
-                    double fMaxValue;
-                    ::rtl::math::setInf(&fMaxValue, true);
+                    double fMaxValue = -std::numeric_limits<double>::infinity();
                     for(double d : rData)
                     {
                         if(fMaxValue < d)
@@ -1706,9 +1705,8 @@ double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, s
         return fMinY;
     }
 
-    double fMinimum, fMaximum;
-    ::rtl::math::setInf(&fMinimum, false);
-    ::rtl::math::setInf(&fMaximum, true);
+    double fMinimum = std::numeric_limits<double>::infinity();
+    double fMaximum = -std::numeric_limits<double>::infinity();
     for(std::vector<VDataSeriesGroup> & rXSlots : m_aZSlots)
     {
         for(VDataSeriesGroup & rXSlot : rXSlots)
@@ -1739,9 +1737,8 @@ double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, s
         return fMaxY;
     }
 
-    double fMinimum, fMaximum;
-    ::rtl::math::setInf(&fMinimum, false);
-    ::rtl::math::setInf(&fMaximum, true);
+    double fMinimum = std::numeric_limits<double>::infinity();
+    double fMaximum = -std::numeric_limits<double>::infinity();
     for( std::vector< VDataSeriesGroup > & rXSlots : m_aZSlots)
     {
         for(VDataSeriesGroup & rXSlot : rXSlots)
@@ -1817,8 +1814,8 @@ bool VSeriesPlotter::isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIn
 
 void VSeriesPlotter::getMinimumAndMaximumX( double& rfMinimum, double& rfMaximum ) const
 {
-    ::rtl::math::setInf(&rfMinimum, false);
-    ::rtl::math::setInf(&rfMaximum, true);
+    rfMinimum = std::numeric_limits<double>::infinity();
+    rfMaximum = -std::numeric_limits<double>::infinity();
 
     for (auto const& ZSlot : m_aZSlots)
     {
@@ -1840,8 +1837,8 @@ void VSeriesPlotter::getMinimumAndMaximumX( double& rfMinimum, double& rfMaximum
 
 void VSeriesPlotter::getMinimumAndMaximumYInContinuousXRange( double& rfMinY, double& rfMaxY, double fMinX, double fMaxX, sal_Int32 nAxisIndex ) const
 {
-    ::rtl::math::setInf(&rfMinY, false);
-    ::rtl::math::setInf(&rfMaxY, true);
+    rfMinY = std::numeric_limits<double>::infinity();
+    rfMaxY = -std::numeric_limits<double>::infinity();
 
     for (auto const& ZSlot : m_aZSlots)
     {
@@ -1926,8 +1923,8 @@ sal_Int32 VDataSeriesGroup::getAttachedAxisIndexForFirstSeries() const
 void VDataSeriesGroup::getMinimumAndMaximumX( double& rfMinimum, double& rfMaximum ) const
 {
 
-    ::rtl::math::setInf(&rfMinimum, false);
-    ::rtl::math::setInf(&rfMaximum, true);
+    rfMinimum = std::numeric_limits<double>::infinity();
+    rfMaximum = -std::numeric_limits<double>::infinity();
 
     for (std::unique_ptr<VDataSeries> const & pSeries : m_aSeriesVector)
     {
@@ -2131,8 +2128,8 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex
     assert(nCategoryIndex >= 0);
     assert(nCategoryIndex < getPointCount());
 
-    ::rtl::math::setInf(&rfMinimumY, false);
-    ::rtl::math::setInf(&rfMaximumY, true);
+    rfMinimumY = std::numeric_limits<double>::infinity();
+    rfMaximumY = -std::numeric_limits<double>::infinity();
 
     if(m_aSeriesVector.empty())
         return;
@@ -2218,8 +2215,8 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategoryRange(
         , double& rfMinimumY, double& rfMaximumY, sal_Int32 nAxisIndex )
 {
     //@todo maybe cache these values
-    ::rtl::math::setInf(&rfMinimumY, false);
-    ::rtl::math::setInf(&rfMaximumY, true);
+    rfMinimumY = std::numeric_limits<double>::infinity();
+    rfMaximumY = -std::numeric_limits<double>::infinity();
 
     //iterate through the given categories
     if(nStartCategoryIndex<0)
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 87abdb2810c8..1135174c24d3 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -34,7 +34,6 @@
 #include <com/sun/star/chart2/XRegressionCurveCalculator.hpp>
 #include <com/sun/star/chart2/RelativePosition.hpp>
 
-#include <rtl/math.hxx>
 #include <osl/diagnose.h>
 #include <tools/color.hxx>
 #include <tools/diagnose_ex.h>
@@ -657,8 +656,7 @@ bool VDataSeries::isLabelCustomPos(sal_Int32 nPointIndex) const
 
 double VDataSeries::getMinimumofAllDifferentYValues( sal_Int32 index ) const
 {
-    double fMin=0.0;
-    ::rtl::math::setInf(&fMin, false);
+    double fMin = std::numeric_limits<double>::infinity();
 
     if( !m_aValues_Y.is() &&
         (m_aValues_Y_Min.is() || m_aValues_Y_Max.is()
@@ -693,8 +691,7 @@ double VDataSeries::getMinimumofAllDifferentYValues( sal_Int32 index ) const
 
 double VDataSeries::getMaximumofAllDifferentYValues( sal_Int32 index ) const
 {
-    double fMax=0.0;
-    ::rtl::math::setInf(&fMax, true);
+    double fMax = -std::numeric_limits<double>::infinity();
 
     if( !m_aValues_Y.is() &&
         (m_aValues_Y_Min.is() || m_aValues_Y_Max.is()
diff --git a/sc/inc/math.hxx b/sc/inc/math.hxx
index 459b82e74bcd..a1afff90a0a7 100644
--- a/sc/inc/math.hxx
+++ b/sc/inc/math.hxx
@@ -52,16 +52,10 @@ inline double divide( const double& fNumerator, const double& fDenominator )
 {
     if (fDenominator == 0.0)
     {
-        double fVal;
         if (std::isfinite( fNumerator) && fNumerator != 0.0)
-        {
-            rtl::math::setInf( &fVal, std::signbit( fNumerator));
-        }
-        else
-        {
-            rtl::math::setNan( &fVal);
-        }
-        return fVal;
+            return std::signbit(fNumerator) ? -std::numeric_limits<double>::infinity()
+                                            :  std::numeric_limits<double>::infinity();
+        return std::numeric_limits<double>::quiet_NaN();
     }
     return fNumerator / fDenominator;
 }
diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx
index f6d2e9812f9e..da3293d7c2be 100644
--- a/sc/source/core/data/dpitemdata.cxx
+++ b/sc/source/core/data/dpitemdata.cxx
@@ -167,14 +167,14 @@ void ScDPItemData::SetRangeStart(double fVal)
 void ScDPItemData::SetRangeFirst()
 {
     DisposeString();
-    rtl::math::setInf(&mfValue, true);
+    mfValue = -std::numeric_limits<double>::infinity();
     meType = RangeStart;
 }
 
 void ScDPItemData::SetRangeLast()
 {
     DisposeString();
-    rtl::math::setInf(&mfValue, false);
+    mfValue = std::numeric_limits<double>::infinity();
     meType = RangeStart;
 }
 
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index 6fabf2e286dd..62d61a733055 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -153,16 +153,10 @@ OUString ScDPUtil::getDateGroupName(
 double ScDPUtil::getNumGroupStartValue(double fValue, const ScDPNumGroupInfo& rInfo)
 {
     if (fValue < rInfo.mfStart && !rtl::math::approxEqual(fValue, rInfo.mfStart))
-    {
-        rtl::math::setInf(&fValue, true);
-        return fValue;
-    }
+        return -std::numeric_limits<double>::infinity();
 
     if (fValue > rInfo.mfEnd && !rtl::math::approxEqual(fValue, rInfo.mfEnd))
-    {
-        rtl::math::setInf(&fValue, false);
-        return fValue;
-    }
+        return std::numeric_limits<double>::infinity();
 
     double fDiff = fValue - rInfo.mfStart;
     double fDiv = rtl::math::approxFloor( fDiff / rInfo.mfStep );


More information about the Libreoffice-commits mailing list