From 7ff2c9cfc5fa8c261b1f7f959172f60255fcf617 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 19 Nov 2021 20:04:22 +0300 Subject: [PATCH] Use more basegfx::deg2rad and basegfx::rad2deg Change-Id: I9dc57628b98f67994d546f6887e96389be1efe62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125568 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- oox/source/drawingml/shape.cxx | 4 ++-- oox/source/export/chartexport.cxx | 2 +- oox/source/export/drawingml.cxx | 2 +- oox/source/export/shapes.cxx | 4 ++-- sax/source/tools/converter.cxx | 4 ++-- svx/source/dialog/dialcontrol.cxx | 2 +- svx/source/svdraw/svdotext.cxx | 4 ++-- vcl/source/bitmap/BitmapEmbossGreyFilter.cxx | 4 ++-- vcl/source/outdev/bitmapex.cxx | 2 +- writerfilter/source/dmapper/GraphicImport.cxx | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 1f1d430e241d..9aed4d3588d0 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -661,7 +661,7 @@ void lcl_RotateAtCenter(basegfx::B2DHomMatrix& aTransformation,sal_Int32 nMSORot { if (nMSORotationAngle == 0) return; - double fRad = basegfx::deg2rad(nMSORotationAngle / 60000.0); + double fRad = basegfx::deg2rad<60000>(nMSORotationAngle); basegfx::B2DPoint aCenter(0.5, 0.5); aCenter *= aTransformation; aTransformation.translate(-aCenter); @@ -771,7 +771,7 @@ Reference< XShape > const & Shape::createAndInsert( if (bUseRotationTransform && mnDiagramRotation != 0) { aTransformation.translate(-0.5, -0.5); - aTransformation.rotate(basegfx::deg2rad(mnDiagramRotation / 60000.0)); + aTransformation.rotate(basegfx::deg2rad<60000>(mnDiagramRotation)); aTransformation.translate(0.5, 0.5); } diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 4b88f6959460..491211bd1999 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1519,7 +1519,7 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape, const OUString awt::Size aSize = xShape->getSize(); awt::Point aPos2 = xShape->getPosition(); // rotated shapes need special handling... - double fSin = fabs(sin(basegfx::deg2rad(nRotation*0.01))); + double fSin = fabs(sin(basegfx::deg2rad<100>(nRotation))); // remove part of height from X direction, if title is rotated down if( nRotation*0.01 > 180.0 ) aPos2.X -= static_cast(fSin * aSize.Height + 0.5); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index dfb30c2f484b..dd112c9b6643 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -4389,7 +4389,7 @@ static sal_Int32 lcl_CalculateDist(const double dX, const double dY) static sal_Int32 lcl_CalculateDir(const double dX, const double dY) { - return (static_cast< sal_Int32 >(basegfx::rad2deg(atan2(dY,dX)) * 60000) + 21600000) % 21600000; + return (static_cast< sal_Int32 >(basegfx::rad2deg<60000>(atan2(dY,dX))) + 21600000) % 21600000; } void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 776f8df83472..35b7a4bd4c9d 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -689,9 +689,9 @@ static sal_Int32 lcl_CircleAngle2CustomShapeEllipseAngleOOX(const sal_Int32 nInt { if (nWidth != 0 || nHeight != 0) { - double fAngle = basegfx::deg2rad(nInternAngle / 100.0); // intern 1/100 deg to degree to rad + double fAngle = basegfx::deg2rad<100>(nInternAngle); // intern 1/100 deg to rad fAngle = atan2(nHeight * sin(fAngle), nWidth * cos(fAngle)); // circle to ellipse - fAngle = basegfx::rad2deg(fAngle) * 60000.0; // rad to degree to OOXML angle unit + fAngle = basegfx::rad2deg<60000>(fAngle); // rad to OOXML angle unit sal_Int32 nAngle = basegfx::fround(fAngle); // normalize nAngle = nAngle % 21600000; return nAngle < 0 ? (nAngle + 21600000) : nAngle; diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index 69fbc8104cfb..6b6301bac0ff 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -748,7 +748,7 @@ bool Converter::convertAngle(sal_Int16& rAngle, std::u16string_view rString, } else if (std::u16string_view::npos != rString.find(u"rad")) { - nValue = basegfx::rad2deg(fValue) * 10.0; + nValue = basegfx::rad2deg<10>(fValue); } else // no explicit unit { @@ -798,7 +798,7 @@ bool Converter::convertAngle(sal_Int16& rAngle, std::string_view rString, } else if (std::string_view::npos != rString.find("rad")) { - nValue = basegfx::rad2deg(fValue) * 10.0; + nValue = basegfx::rad2deg<10>(fValue); } else // no explicit unit { diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx index 0a62215fd60e..fe88a426649d 100644 --- a/svx/source/dialog/dialcontrol.cxx +++ b/svx/source/dialog/dialcontrol.cxx @@ -452,7 +452,7 @@ void DialControl::HandleMouseEvent( const Point& rPos, bool bInitial ) if( fH != 0.0 ) { double fAngle = acos( nX / fH ); - sal_Int32 nAngle = static_cast(basegfx::rad2deg(fAngle) * 100.0); + sal_Int32 nAngle = basegfx::rad2deg<100>(fAngle); if( nY < 0 ) nAngle = 36000 - nAngle; if( bInitial ) // round to entire 15 degrees diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 30c5524288e9..91a0870630e0 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1562,8 +1562,8 @@ bool SdrTextObj::IsTopToBottom() const bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const { // get turn and shear - double fRotate = basegfx::deg2rad(maGeo.nRotationAngle.get() / 100.0); - double fShearX = basegfx::deg2rad(maGeo.nShearAngle.get() / 100.0); + double fRotate = toRadians(maGeo.nRotationAngle); + double fShearX = toRadians(maGeo.nShearAngle); // get aRect, this is the unrotated snaprect tools::Rectangle aRectangle(maRect); diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx index d25950b1c9f2..a8705176f1d1 100644 --- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx +++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx @@ -46,8 +46,8 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const sal_Int32 nGrey11, nGrey12, nGrey13; sal_Int32 nGrey21, nGrey22, nGrey23; sal_Int32 nGrey31, nGrey32, nGrey33; - double fAzim = basegfx::deg2rad(mnAzimuthAngle100 * 0.01); - double fElev = basegfx::deg2rad(mnElevationAngle100 * 0.01); + double fAzim = basegfx::deg2rad<100>(mnAzimuthAngle100); + double fElev = basegfx::deg2rad<100>(mnElevationAngle100); std::unique_ptr pHMap(new sal_Int32[nWidth + 2]); std::unique_ptr pVMap(new sal_Int32[nHeight + 2]); sal_Int32 nX, nY, nNx, nNy, nDotL; diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx index 44170e633bfe..7855d1ae5613 100644 --- a/vcl/source/outdev/bitmapex.cxx +++ b/vcl/source/outdev/bitmapex.cxx @@ -665,7 +665,7 @@ void OutputDevice::DrawTransformedBitmapEx( { fFullRotate += 2 * M_PI; } - Degree10 nAngle10(basegfx::fround(basegfx::rad2deg(fFullRotate) * 10)); + Degree10 nAngle10(basegfx::fround(basegfx::rad2deg<10>(fFullRotate))); aTransformed.Rotate(nAngle10, COL_TRANSPARENT); } basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0); diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index b6049e78c61a..704774ec504a 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1122,7 +1122,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) { aMatrix = basegfx::utils::createRotateAroundPoint( aImportSize.Width / 2.0, aImportSize.Height / 2.0, - basegfx::deg2rad( nOOXAngle / 60000.0)); + basegfx::deg2rad<60000>(nOOXAngle)); aB2DWrapPolyPolygon.transform(aMatrix); } basegfx::B2DRange aB2DWrapRange = aB2DWrapPolyPolygon.getB2DRange(); @@ -1149,7 +1149,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) if (nOOXAngle != 0) { aMatrix = basegfx::utils::createRotateB2DHomMatrix( - basegfx::deg2rad(nOOXAngle / 60000.0)); + basegfx::deg2rad<60000>(nOOXAngle)); aShapeRange.transform(aMatrix); } } -- 2.11.4.GIT