summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorBaiXiaochun <bai.xiaochun.mofan@protonmail.com>2021-06-30 18:12:08 +0200
committerEike Rathke <erack@redhat.com>2021-07-03 21:57:29 +0200
commit3128fd02c069765a4428022e84a324e991c69521 (patch)
tree77ae23473888cc8f547e9de1831ee5f41c2f7573 /chart2/source
parente732bbacbf33a3d0c08fb96a18072e5b1ca46691 (diff)
Purge out when safe rtl::math ( isValidArcArg / sin / cos )
/** If a value is a valid argument for sin(), cos(), tan(). IEEE 754 specifies that absolute values up to 2^64 (=1.844e19) for the radian must be supported by trigonometric functions. Unfortunately, at least on x86 architectures, the FPU doesn't generate an error pattern for values >2^64 but produces erroneous results instead and sets only the "invalid operation" (IM) flag in the status word :-( Thus the application has to handle it itself. */ chart2/source/tools/RelativePositionHelper.cxx Function name: RelativePositionHelper::getCenterOfAnchoredObject From here: suppose it's related to the orientation of the chart << 2^64 chart2/source/view/main/LabelPositionHelper.cxx LabelPositionHelper::LabelPositionHelper Suppose: setup label position. There won't be angles grater than 360º. chart2/source/view/main/PlottingPositionHelper.cxx PolarPlottingPositionHelper::transformUnitCircleToScene Suppose: maybe disc chart orientation? Internal angle should be safe. chart2/source/view/main/ShapeFactory.cxx ShapeFactory::getSizeAfterRotation Suppose: rotate shape Internal angle should be safe. drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx Constant 100% safe sc/source/core/data/documen4.cxx bool ScDocument::Solver Suppose: the tangent is being used as numerical derivative (Regula falsi algorithm) So no impossible angles scaddins/source/analysis/bessel.cxx Filtered it out as bad imput Change-Id: Ib348cca6ce13263d087b6731f93f58d8a15cc725 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118193 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/tools/RelativePositionHelper.cxx4
-rw-r--r--chart2/source/view/main/LabelPositionHelper.cxx171
-rw-r--r--chart2/source/view/main/PlottingPositionHelper.cxx4
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx8
4 files changed, 94 insertions, 93 deletions
diff --git a/chart2/source/tools/RelativePositionHelper.cxx b/chart2/source/tools/RelativePositionHelper.cxx
index deb3e5ca5a2c..260888e907dd 100644
--- a/chart2/source/tools/RelativePositionHelper.cxx
+++ b/chart2/source/tools/RelativePositionHelper.cxx
@@ -237,9 +237,9 @@ awt::Point RelativePositionHelper::getCenterOfAnchoredObject(
//take rotation into account:
aResult.X += static_cast< sal_Int32 >(
- ::rtl::math::round( fXDelta * rtl::math::cos( fAnglePi ) + fYDelta * rtl::math::sin( fAnglePi ) ) );
+ ::rtl::math::round( fXDelta * std::cos( fAnglePi ) + fYDelta * std::sin( fAnglePi ) ) );
aResult.Y += static_cast< sal_Int32 >(
- ::rtl::math::round( - fXDelta * rtl::math::sin( fAnglePi ) + fYDelta * rtl::math::cos( fAnglePi ) ) );
+ ::rtl::math::round( - fXDelta * std::sin( fAnglePi ) + fYDelta * std::cos( fAnglePi ) ) );
return aResult;
}
diff --git a/chart2/source/view/main/LabelPositionHelper.cxx b/chart2/source/view/main/LabelPositionHelper.cxx
index 74fd1ed78174..798c6562e1f6 100644
--- a/chart2/source/view/main/LabelPositionHelper.cxx
+++ b/chart2/source/view/main/LabelPositionHelper.cxx
@@ -25,7 +25,8 @@
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/drawing/XShape.hpp>
-#include <rtl/math.hxx>
+
+#include <cmath>
namespace chart
{
@@ -123,36 +124,36 @@ void lcl_correctRotation_Left( double& rfXCorrection, double& rfYCorrection
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection = -aSize.Height*std::sin( fAnglePi )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi )/2.0;
+ rfYCorrection = -aSize.Width*std::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi-F_PI2;
- rfXCorrection = -aSize.Width *rtl::math::sin( beta )
- -aSize.Height *rtl::math::cos( beta )/2.0;
+ rfXCorrection = -aSize.Width *std::sin( beta )
+ -aSize.Height *std::cos( beta )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = -aSize.Width *rtl::math::cos( beta )/2.0;
+ rfYCorrection = -aSize.Width *std::cos( beta )/2.0;
else
- rfYCorrection = -aSize.Width *rtl::math::cos( beta );
+ rfYCorrection = -aSize.Width *std::cos( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = fAnglePi - F_PI;
- rfXCorrection = -aSize.Width *rtl::math::cos( beta )
- -aSize.Height*rtl::math::sin( beta )/2.0;
+ rfXCorrection = -aSize.Width *std::cos( beta )
+ -aSize.Height*std::sin( beta )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = aSize.Width *rtl::math::sin( beta )/2.0;
+ rfYCorrection = aSize.Width *std::sin( beta )/2.0;
else
- rfYCorrection = aSize.Width *rtl::math::sin( beta );
+ rfYCorrection = aSize.Width *std::sin( beta );
}
else
{
double beta = 2*F_PI - fAnglePi;
- rfXCorrection = -aSize.Height*rtl::math::sin( beta )/2.0;
+ rfXCorrection = -aSize.Height*std::sin( beta )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = aSize.Width*rtl::math::sin( beta )/2.0;
+ rfYCorrection = aSize.Width*std::sin( beta )/2.0;
}
}
@@ -166,35 +167,35 @@ void lcl_correctRotation_Right( double& rfXCorrection, double& rfYCorrection
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection = aSize.Height*std::sin( fAnglePi )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
+ rfYCorrection = aSize.Width*std::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = F_PI - fAnglePi;
- rfXCorrection = aSize.Width *rtl::math::cos( beta )
- + aSize.Height*rtl::math::sin( beta )/2.0;
+ rfXCorrection = aSize.Width *std::cos( beta )
+ + aSize.Height*std::sin( beta )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = aSize.Width *rtl::math::sin( beta )/2.0;
+ rfYCorrection = aSize.Width *std::sin( beta )/2.0;
else
- rfYCorrection = aSize.Width *rtl::math::sin( beta );
+ rfYCorrection = aSize.Width *std::sin( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI2 - fAnglePi;
- rfXCorrection = aSize.Width *rtl::math::sin( beta )
- +aSize.Height*rtl::math::cos( beta )/2.0;
+ rfXCorrection = aSize.Width *std::sin( beta )
+ +aSize.Height*std::cos( beta )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = -aSize.Width *rtl::math::cos( beta )/2.0;
+ rfYCorrection = -aSize.Width *std::cos( beta )/2.0;
else
- rfYCorrection = -aSize.Width *rtl::math::cos( beta );
+ rfYCorrection = -aSize.Width *std::cos( beta );
}
else
{
- rfXCorrection = aSize.Height*rtl::math::sin( 2*F_PI - fAnglePi )/2.0;
+ rfXCorrection = aSize.Height*std::sin( 2*F_PI - fAnglePi )/2.0;
if( bRotateAroundCenter )
- rfYCorrection = -aSize.Width*rtl::math::sin( 2*F_PI - fAnglePi )/2.0;
+ rfYCorrection = -aSize.Width*std::sin( 2*F_PI - fAnglePi )/2.0;
}
}
@@ -208,35 +209,35 @@ void lcl_correctRotation_Top( double& rfXCorrection, double& rfYCorrection
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection = aSize.Height*std::sin( fAnglePi )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection += aSize.Width*rtl::math::cos( fAnglePi )/2.0;
- rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection += aSize.Width*std::cos( fAnglePi )/2.0;
+ rfYCorrection = -aSize.Width*std::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi - F_PI2;
- rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0;
+ rfXCorrection = aSize.Height*std::cos( beta )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection -= aSize.Width*rtl::math::sin( beta )/2.0;
- rfYCorrection = -aSize.Width*rtl::math::cos( beta )/2.0
- - aSize.Height*rtl::math::sin( beta );
+ rfXCorrection -= aSize.Width*std::sin( beta )/2.0;
+ rfYCorrection = -aSize.Width*std::cos( beta )/2.0
+ - aSize.Height*std::sin( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = fAnglePi - F_PI;
- rfXCorrection = -aSize.Height *rtl::math::sin( beta )/2.0;
+ rfXCorrection = -aSize.Height *std::sin( beta )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection += aSize.Width *rtl::math::cos( beta )/2.0;
- rfYCorrection = -aSize.Width *rtl::math::sin( beta )/2.0
- -aSize.Height *rtl::math::cos( beta );
+ rfXCorrection += aSize.Width *std::cos( beta )/2.0;
+ rfYCorrection = -aSize.Width *std::sin( beta )/2.0
+ -aSize.Height *std::cos( beta );
}
else
{
- rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection = aSize.Height*std::sin( fAnglePi )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection -= aSize.Width*rtl::math::cos( fAnglePi )/2.0;
- rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection -= aSize.Width*std::cos( fAnglePi )/2.0;
+ rfYCorrection = aSize.Width*std::sin( fAnglePi )/2.0;
}
}
@@ -250,36 +251,36 @@ void lcl_correctRotation_Bottom( double& rfXCorrection, double& rfYCorrection
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection = -aSize.Height*std::sin( fAnglePi )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection -= aSize.Width *rtl::math::cos( fAnglePi )/2.0;
- rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
+ rfXCorrection -= aSize.Width *std::cos( fAnglePi )/2.0;
+ rfYCorrection = aSize.Width*std::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi-F_PI2;
- rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0;
+ rfXCorrection = -aSize.Height*std::cos( beta )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection += aSize.Width *rtl::math::sin( beta )/2.0;
- rfYCorrection = aSize.Width *rtl::math::cos( beta )/2.0
- +aSize.Height*rtl::math::sin( beta );
+ rfXCorrection += aSize.Width *std::sin( beta )/2.0;
+ rfYCorrection = aSize.Width *std::cos( beta )/2.0
+ +aSize.Height*std::sin( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI2 - fAnglePi;
- rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0;
+ rfXCorrection = aSize.Height*std::cos( beta )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection -= aSize.Width *rtl::math::sin( beta )/2.0;
- rfYCorrection = aSize.Height*rtl::math::sin( beta )
- +aSize.Width*rtl::math::cos( beta )/2.0;
+ rfXCorrection -= aSize.Width *std::sin( beta )/2.0;
+ rfYCorrection = aSize.Height*std::sin( beta )
+ +aSize.Width*std::cos( beta )/2.0;
}
else
{
double beta = 2*F_PI - fAnglePi;
- rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0;
+ rfXCorrection = aSize.Height*std::sin( beta )/2.0;
if( !bRotateAroundCenter )
- rfXCorrection += aSize.Width*rtl::math::cos( beta )/2.0;
- rfYCorrection = aSize.Width*rtl::math::sin( beta )/2.0;
+ rfXCorrection += aSize.Width*std::cos( beta )/2.0;
+ rfYCorrection = aSize.Width*std::sin( beta )/2.0;
}
}
@@ -293,25 +294,25 @@ void lcl_correctRotation_Left_Top( double& rfXCorrection, double& rfYCorrection
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi );
+ rfYCorrection = -aSize.Width*std::sin( fAnglePi );
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi-F_PI2;
- rfXCorrection = -aSize.Width*rtl::math::sin( beta );
- rfYCorrection = -aSize.Height*rtl::math::sin( beta )
- -aSize.Width*rtl::math::cos( beta );
+ rfXCorrection = -aSize.Width*std::sin( beta );
+ rfYCorrection = -aSize.Height*std::sin( beta )
+ -aSize.Width*std::cos( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI2 - fAnglePi;
- rfXCorrection = -aSize.Height*rtl::math::cos( beta )
- -aSize.Width*rtl::math::sin( beta );
- rfYCorrection = -aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = -aSize.Height*std::cos( beta )
+ -aSize.Width*std::sin( beta );
+ rfYCorrection = -aSize.Height*std::sin( beta );
}
else
{
- rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi );
+ rfXCorrection = aSize.Height*std::sin( fAnglePi );
}
}
@@ -325,25 +326,25 @@ void lcl_correctRotation_Left_Bottom( double& rfXCorrection, double& rfYCorrecti
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi );
+ rfXCorrection = -aSize.Height*std::sin( fAnglePi );
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi-F_PI2;
- rfXCorrection = -aSize.Width*rtl::math::sin( beta )
- -aSize.Height*rtl::math::cos( beta );
- rfYCorrection = aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = -aSize.Width*std::sin( beta )
+ -aSize.Height*std::cos( beta );
+ rfYCorrection = aSize.Height*std::sin( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI2 - fAnglePi;
- rfXCorrection = -aSize.Width*rtl::math::sin( beta );
- rfYCorrection = aSize.Width*rtl::math::cos( beta )
- +aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = -aSize.Width*std::sin( beta );
+ rfYCorrection = aSize.Width*std::cos( beta )
+ +aSize.Height*std::sin( beta );
}
else
{
- rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi );
+ rfYCorrection = -aSize.Width*std::sin( fAnglePi );
}
}
@@ -357,25 +358,25 @@ void lcl_correctRotation_Right_Top( double& rfXCorrection, double& rfYCorrection
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi );
+ rfXCorrection = aSize.Height*std::sin( fAnglePi );
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi-F_PI2;
- rfXCorrection = aSize.Width*rtl::math::sin( beta )
- +aSize.Height*rtl::math::cos( beta );
- rfYCorrection = -aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = aSize.Width*std::sin( beta )
+ +aSize.Height*std::cos( beta );
+ rfYCorrection = -aSize.Height*std::sin( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI2 - fAnglePi;
- rfXCorrection = aSize.Width*rtl::math::sin( beta );
- rfYCorrection = -aSize.Width*rtl::math::cos( beta )
- -aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = aSize.Width*std::sin( beta );
+ rfYCorrection = -aSize.Width*std::cos( beta )
+ -aSize.Height*std::sin( beta );
}
else
{
- rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi );
+ rfYCorrection = aSize.Width*std::sin( fAnglePi );
}
}
@@ -389,25 +390,25 @@ void lcl_correctRotation_Right_Bottom( double& rfXCorrection, double& rfYCorrect
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi );
+ rfYCorrection = aSize.Width*std::sin( fAnglePi );
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = fAnglePi-F_PI2;
- rfXCorrection = aSize.Width*rtl::math::sin( beta );
- rfYCorrection = aSize.Height*rtl::math::sin( beta )
- +aSize.Width*rtl::math::cos( beta );
+ rfXCorrection = aSize.Width*std::sin( beta );
+ rfYCorrection = aSize.Height*std::sin( beta )
+ +aSize.Width*std::cos( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI2 - fAnglePi;
- rfXCorrection = aSize.Height*rtl::math::cos( beta )
- +aSize.Width*rtl::math::sin( beta );
- rfYCorrection = aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = aSize.Height*std::cos( beta )
+ +aSize.Width*std::sin( beta );
+ rfYCorrection = aSize.Height*std::sin( beta );
}
else
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi );
+ rfXCorrection = -aSize.Height*std::sin( fAnglePi );
}
}
diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx
index b8e9431ae2ab..69a346b067e3 100644
--- a/chart2/source/view/main/PlottingPositionHelper.cxx
+++ b/chart2/source/view/main/PlottingPositionHelper.cxx
@@ -615,8 +615,8 @@ drawing::Position3D PolarPlottingPositionHelper::transformUnitCircleToScene( dou
{
double fAnglePi = basegfx::deg2rad(fUnitAngleDegree);
- double fX=fUnitRadius*rtl::math::cos(fAnglePi);
- double fY=fUnitRadius*rtl::math::sin(fAnglePi);
+ double fX=fUnitRadius*std::cos(fAnglePi);
+ double fY=fUnitRadius*std::sin(fAnglePi);
double fZ=fLogicZ;
//!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 5b7c4859beb8..5f2cfb442820 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -2632,11 +2632,11 @@ awt::Size ShapeFactory::getSizeAfterRotation(
const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree);
aRet.Height = static_cast<sal_Int32>(
- aSize.Width*rtl::math::sin( fAnglePi )
- + aSize.Height*rtl::math::cos( fAnglePi ));
+ aSize.Width*std::sin( fAnglePi )
+ + aSize.Height*std::cos( fAnglePi ));
aRet.Width = static_cast<sal_Int32>(
- aSize.Width*rtl::math::cos( fAnglePi )
- + aSize.Height*rtl::math::sin( fAnglePi ));
+ aSize.Width*std::cos( fAnglePi )
+ + aSize.Height*std::sin( fAnglePi ));
}
}
return aRet;