summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-08-04 10:37:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-08-04 20:51:27 +0200
commit8c48d69f06ddb3cb6c807a1e7db62dddb9778ded (patch)
tree8b6bf137be41ebe93746c4958ab9106bbf5cc339 /oox
parentc05fbde6c870b7e6bc2f9bf642dc7d76215a496f (diff)
Use more basegfx deg<->rad functions, instead of direct formulas
Also make the functions constexpr. Due to slight changes in floating-point arithmetics (90.0 instead of 180.0, M_PI2 instead of M_PI resp.), results might differ in last digits (usually 17th decimal digit). This has lead to need to tweak char2dump's PieChartTest unit test. Change-Id: I20323dd7dab27e4deb408ea4181e390cc05e7cd3 Reviewed-on: https://gerrit.libreoffice.org/58583 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx2
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx4
-rw-r--r--oox/source/drawingml/effectproperties.cxx2
-rw-r--r--oox/source/drawingml/shape.cxx4
-rw-r--r--oox/source/export/drawingml.cxx2
5 files changed, 7 insertions, 7 deletions
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index a0535671dbc6..3d0b8c413bab 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -398,7 +398,7 @@ void LayoutConverter::convertFromModel( const Reference< XShape >& rxShape, doub
// the call to XShape.getSize() may recalc the chart view
awt::Size aShapeSize = rxShape->getSize();
// rotated shapes need special handling...
- double fSin = fabs( sin( fRotationAngle * F_PI180 ) );
+ double fSin = fabs( sin( basegfx::deg2rad(fRotationAngle) ) );
// add part of height to X direction, if title is rotated down
if( fRotationAngle > 180.0 )
aShapePos.X += static_cast< sal_Int32 >( fSin * aShapeSize.Height + 0.5 );
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index d3c006dc447a..ed0678340e4b 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -322,8 +322,8 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
{
const double fAngle = static_cast<double>(idx)*nSpanAngle/nShapes + nStartAngle;
const awt::Point aCurrPos(
- aCenter.Width + nRadius*sin(fAngle*F_PI180) - aChildSize.Width/2,
- aCenter.Height - nRadius*cos(fAngle*F_PI180) - aChildSize.Height/2);
+ aCenter.Width + nRadius*sin(basegfx::deg2rad(fAngle)) - aChildSize.Width/2,
+ aCenter.Height - nRadius*cos(basegfx::deg2rad(fAngle)) - aChildSize.Height/2);
aCurrShape->setPosition(aCurrPos);
aCurrShape->setSize(aChildSize);
diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
index 49f1d915a11c..ff9ded567784 100644
--- a/oox/source/drawingml/effectproperties.cxx
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -58,7 +58,7 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
attribIt->second >>= nAttrDist;
// Negative X or Y dist indicates left or up, respectively
- double nAngle = ( static_cast<double>(nAttrDir) / PER_DEGREE ) * F_PI180;
+ double nAngle = basegfx::deg2rad(static_cast<double>(nAttrDir) / PER_DEGREE);
sal_Int32 nDist = convertEmuToHmm( nAttrDist );
sal_Int32 nXDist = cos(nAngle) * nDist;
sal_Int32 nYDist = sin(nAngle) * nDist;
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 70028b34fe87..5b75b94cdfba 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -653,7 +653,7 @@ Reference< XShape > const & Shape::createAndInsert(
{
// rotate diagram's shape around object's center before sizing
aTransformation.translate(-0.5, -0.5);
- aTransformation.rotate(F_PI180 * (mnDiagramRotation / 60000.0));
+ aTransformation.rotate(basegfx::deg2rad(mnDiagramRotation / 60000.0));
aTransformation.translate(0.5, 0.5);
}
@@ -702,7 +702,7 @@ Reference< XShape > const & Shape::createAndInsert(
}
}
// rotate around object's center
- aTransformation.rotate( F_PI180 * ( static_cast<double>(mnRotation) / 60000.0 ) );
+ aTransformation.rotate(basegfx::deg2rad(static_cast<double>(mnRotation) / 60000.0));
}
// move object back from center
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index b5d681dd1a13..e0fc6dbae783 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3298,7 +3298,7 @@ sal_Int32 lcl_CalculateDist(const double dX, const double dY)
sal_Int32 lcl_CalculateDir(const double dX, const double dY)
{
- return (static_cast< sal_Int32 >(atan2(dY,dX) * 180 * 60000 / M_PI) + 21600000) % 21600000;
+ return (static_cast< sal_Int32 >(basegfx::rad2deg(atan2(dY,dX)) * 60000) + 21600000) % 21600000;
}
void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )