diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-12-29 22:25:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-30 17:41:32 +0100 |
commit | 90668f3473f4e52cec823ad39c6fcb44ba7c089b (patch) | |
tree | 142e529b364ec70271b7c2696e58b88bafbd4ef9 | |
parent | 97c3280afbb960bd5567bb56af4090fc38030df7 (diff) |
use Degree10 in XPolygon
Change-Id: I1820455de46bd428e1fbc0601aba58d377fdb930
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108488
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 7 | ||||
-rw-r--r-- | include/svx/xpoly.hxx | 7 | ||||
-rw-r--r-- | sd/source/ui/func/fucon3d.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdopath.cxx | 4 | ||||
-rw-r--r-- | svx/source/xoutdev/_xpoly.cxx | 38 |
5 files changed, 32 insertions, 28 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 72c44289c9e4..b94289983417 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -881,9 +881,12 @@ static basegfx::B2DPolyPolygon GetLineArrow( const sal_Int32 nLineWidth, const s break; case mso_lineArrowOvalEnd : { - aRetPolyPoly = basegfx::B2DPolyPolygon( XPolygon( Point( static_cast<sal_Int32>( fWidthMul * fLineWidth * 0.50 ), 0 ), + aRetPolyPoly = basegfx::B2DPolyPolygon( + XPolygon( + Point( static_cast<sal_Int32>( fWidthMul * fLineWidth * 0.50 ), 0 ), static_cast<sal_Int32>( fWidthMul * fLineWidth * 0.50 ), - static_cast<sal_Int32>( fLengthMul * fLineWidth * 0.50 ), 0, 3600 ).getB2DPolygon() ); + static_cast<sal_Int32>( fLengthMul * fLineWidth * 0.50 ), + 0_deg10, 3600_deg10 ).getB2DPolygon() ); rbArrowCenter = true; aArrowName.append("msArrowOvalEnd "); } diff --git a/include/svx/xpoly.hxx b/include/svx/xpoly.hxx index 7f50a4c76281..a2074ef8e42d 100644 --- a/include/svx/xpoly.hxx +++ b/include/svx/xpoly.hxx @@ -23,6 +23,7 @@ #include <svx/svxdllapi.h> #include <o3tl/cow_wrapper.hxx> #include <tools/poly.hxx> +#include <tools/degree.hxx> class Point; namespace tools { class Rectangle; } @@ -48,9 +49,9 @@ class SVXCORE_DLLPUBLIC XPolygon final // auxiliary functions for Bezier conversion void SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT); void GenBezArc(const Point& rCenter, tools::Long nRx, tools::Long nRy, - tools::Long nXHdl, tools::Long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd, + tools::Long nXHdl, tools::Long nYHdl, Degree10 nStart, Degree10 nEnd, sal_uInt16 nQuad, sal_uInt16 nFirst); - static bool CheckAngles(sal_uInt16& nStart, sal_uInt16 nEnd, sal_uInt16& nA1, sal_uInt16& nA2); + static bool CheckAngles(Degree10& nStart, Degree10 nEnd, Degree10& nA1, Degree10& nA2); public: XPolygon( sal_uInt16 nSize=16 ); @@ -59,7 +60,7 @@ public: XPolygon( const tools::Polygon& rPoly ); XPolygon( const tools::Rectangle& rRect, tools::Long nRx = 0, tools::Long nRy = 0 ); XPolygon( const Point& rCenter, tools::Long nRx, tools::Long nRy, - sal_uInt16 nStartAngle = 0, sal_uInt16 nEndAngle = 3600, + Degree10 nStartAngle = 0_deg10, Degree10 nEndAngle = 3600_deg10, bool bClose = true ); ~XPolygon(); diff --git a/sd/source/ui/func/fucon3d.cxx b/sd/source/ui/func/fucon3d.cxx index 81d4919928b0..119ca5779716 100644 --- a/sd/source/ui/func/fucon3d.cxx +++ b/sd/source/ui/func/fucon3d.cxx @@ -107,7 +107,7 @@ E3dCompoundObject* FuConstruct3dObject::ImpCreateBasic3DShape() case SID_3D_SHELL: { - XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0, 900, false); + XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0_deg10, 900_deg10, false); aXPoly.Scale(5.0, 5.0); ::basegfx::B2DPolygon aB2DPolygon(aXPoly.getB2DPolygon()); @@ -128,7 +128,7 @@ E3dCompoundObject* FuConstruct3dObject::ImpCreateBasic3DShape() case SID_3D_HALF_SPHERE: { - XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0, 900, false); + XPolygon aXPoly(Point (0, 1250), 2500, 2500, 0_deg10, 900_deg10, false); aXPoly.Scale(5.0, 5.0); aXPoly.Insert(0, Point (2400*5, 1250*5), PolyFlags::Normal); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index a57cf2ab1f6f..24c93bb67f63 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -357,13 +357,13 @@ XPolygon ImpPathCreateUser::GetCirclePoly() const { if (nCircRelAngle>=0) { XPolygon aXP(aCircCenter,nCircRadius,nCircRadius, - sal_uInt16((nCircStAngle+5)/10),sal_uInt16((nCircStAngle+nCircRelAngle+5)/10),false); + Degree10((nCircStAngle+5)/10),Degree10((nCircStAngle+nCircRelAngle+5)/10),false); aXP[0]=aCircStart; aXP.SetFlags(0,PolyFlags::Smooth); if (!bAngleSnap) aXP[aXP.GetPointCount()-1]=aCircEnd; return aXP; } else { XPolygon aXP(aCircCenter,nCircRadius,nCircRadius, - sal_uInt16(NormAngle36000(nCircStAngle+nCircRelAngle+5)/10),sal_uInt16((nCircStAngle+5)/10),false); + Degree10(NormAngle36000(nCircStAngle+nCircRelAngle+5)/10),Degree10((nCircStAngle+5)/10),false); sal_uInt16 nCount=aXP.GetPointCount(); for (sal_uInt16 nNum=nCount/2; nNum>0;) { nNum--; // reverse XPoly's order of points diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx index ffee17f79755..65b64650dd48 100644 --- a/svx/source/xoutdev/_xpoly.cxx +++ b/svx/source/xoutdev/_xpoly.cxx @@ -261,7 +261,7 @@ XPolygon::XPolygon(const tools::Rectangle& rRect, tools::Long nRx, tools::Long n aCenter.AdjustY( -nRy ); break; } - GenBezArc(aCenter, nRx, nRy, nXHdl, nYHdl, 0, 900, nQuad, nPos); + GenBezArc(aCenter, nRx, nRy, nXHdl, nYHdl, 0_deg10, 900_deg10, nQuad, nPos); pImpXPolygon->pFlagAry[nPos ] = PolyFlags::Smooth; pImpXPolygon->pFlagAry[nPos+3] = PolyFlags::Smooth; nPos += 4; @@ -280,12 +280,12 @@ XPolygon::XPolygon(const tools::Rectangle& rRect, tools::Long nRx, tools::Long n /// create an ellipse (curve) as Bézier polygon XPolygon::XPolygon(const Point& rCenter, tools::Long nRx, tools::Long nRy, - sal_uInt16 nStartAngle, sal_uInt16 nEndAngle, bool bClose) + Degree10 nStartAngle, Degree10 nEndAngle, bool bClose) : pImpXPolygon( 17 ) { - nStartAngle %= 3600; - if ( nEndAngle > 3600 ) nEndAngle %= 3600; - bool bFull = (nStartAngle == 0 && nEndAngle == 3600); + nStartAngle %= 3600_deg10; + if ( nEndAngle > 3600_deg10 ) nEndAngle %= 3600_deg10; + bool bFull = (nStartAngle == 0_deg10 && nEndAngle == 3600_deg10); // factor for control points of the Bézier curve: 8/3 * (sin(45g) - 0.5) tools::Long nXHdl = static_cast<tools::Long>(0.552284749 * nRx); @@ -295,8 +295,8 @@ XPolygon::XPolygon(const Point& rCenter, tools::Long nRx, tools::Long nRy, do { - sal_uInt16 nA1, nA2; - sal_uInt16 nQuad = nStartAngle / 900; + Degree10 nA1, nA2; + sal_uInt16 nQuad = nStartAngle.get() / 900; if ( nQuad == 4 ) nQuad = 0; bLoopEnd = CheckAngles(nStartAngle, nEndAngle, nA1, nA2); GenBezArc(rCenter, nRx, nRy, nXHdl, nYHdl, nA1, nA2, nQuad, nPos); @@ -537,7 +537,7 @@ void XPolygon::SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT) /// Generate a Bézier arc void XPolygon::GenBezArc(const Point& rCenter, tools::Long nRx, tools::Long nRy, - tools::Long nXHdl, tools::Long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd, + tools::Long nXHdl, tools::Long nYHdl, Degree10 nStart, Degree10 nEnd, sal_uInt16 nQuad, sal_uInt16 nFirst) { Point* pPoints = pImpXPolygon->pPointAry.get(); @@ -576,23 +576,23 @@ void XPolygon::GenBezArc(const Point& rCenter, tools::Long nRx, tools::Long nRy, pPoints[nFirst+1].AdjustX( nXHdl ); pPoints[nFirst+2].AdjustY( nYHdl ); } - if ( nStart > 0 ) - SubdivideBezier(nFirst, false, static_cast<double>(nStart) / 900); - if ( nEnd < 900 ) - SubdivideBezier(nFirst, true, static_cast<double>(nEnd-nStart) / (900-nStart)); + if ( nStart > 0_deg10 ) + SubdivideBezier(nFirst, false, static_cast<double>(nStart.get()) / 900); + if ( nEnd < 900_deg10 ) + SubdivideBezier(nFirst, true, static_cast<double>((nEnd-nStart).get()) / (900_deg10-nStart).get()); SetFlags(nFirst+1, PolyFlags::Control); SetFlags(nFirst+2, PolyFlags::Control); } -bool XPolygon::CheckAngles(sal_uInt16& nStart, sal_uInt16 nEnd, sal_uInt16& nA1, sal_uInt16& nA2) +bool XPolygon::CheckAngles(Degree10& nStart, Degree10 nEnd, Degree10& nA1, Degree10& nA2) { - if ( nStart == 3600 ) nStart = 0; - if ( nEnd == 0 ) nEnd = 3600; - sal_uInt16 nStPrev = nStart; - sal_uInt16 nMax = (nStart / 900 + 1) * 900; - sal_uInt16 nMin = nMax - 900; + if ( nStart == 3600_deg10 ) nStart = 0_deg10; + if ( nEnd == 0_deg10 ) nEnd = 3600_deg10; + Degree10 nStPrev = nStart; + Degree10 nMax((nStart.get() / 900 + 1) * 900); + Degree10 nMin = nMax - 900_deg10; - if ( nEnd >= nMax || nEnd <= nStart ) nA2 = 900; + if ( nEnd >= nMax || nEnd <= nStart ) nA2 = 900_deg10; else nA2 = nEnd - nMin; nA1 = nStart - nMin; nStart = nMax; |