diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2022-03-07 12:26:03 +0100 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2022-03-10 21:19:59 +0100 |
commit | 7b28920382d3820344bfc4075bac98f85e838dba (patch) | |
tree | dd66a426f9b9b6b6fdb6d698941309ad31d2e4f3 /tools/source | |
parent | 8f48f91009caa86d896f247059874242ed18bf39 (diff) |
tdf#113066 tdf#142204 EMF Implement SETARCDIRECTION
Change-Id: I30206c68ecf1829ba0094e6259b8ed7dc05f2e9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131103
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/generic/poly.cxx | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 6e5b2d778fa7..ed0086a9df37 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -225,21 +225,21 @@ ImplPolygon::ImplPolygon( const Point& rCenter, tools::Long nRadX, tools::Long n mnPoints = 0; } -ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, - PolyStyle eStyle ) +ImplPolygon::ImplPolygon(const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, + PolyStyle eStyle, const bool bClockWiseArcDirection) { const auto nWidth = rBound.GetWidth(); const auto nHeight = rBound.GetHeight(); - if( ( nWidth != 0 ) && ( nHeight != 0 ) ) + if ((nWidth != 0) && (nHeight != 0)) { - const Point aCenter( rBound.Center() ); + const Point aCenter(rBound.Center()); // tdf#142268 Get Top Left corner of rectangle (the rectangle is not always correctly created) const auto aBoundLeft = rBound.Left() < aCenter.X() ? rBound.Left() : rBound.Right(); const auto aBoundTop = rBound.Top() < aCenter.Y() ? rBound.Top() : rBound.Bottom(); const auto nRadX = o3tl::saturating_sub(aCenter.X(), aBoundLeft); const auto nRadY = o3tl::saturating_sub(aCenter.Y(), aBoundTop); - sal_uInt16 nPoints; + sal_uInt16 nPoints; tools::Long nRadXY; const bool bOverflow = o3tl::checked_multiply(nRadX, nRadY, nRadXY); @@ -270,17 +270,29 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c double fStep; sal_uInt16 nStart; sal_uInt16 nEnd; - // #i73608# If startPoint is equal to endPoint, then draw full circle instead of nothing (as Metafiles spec) - if( fDiff <= 0. ) - fDiff += 2 * M_PI; + + if (bClockWiseArcDirection == false) + { + // #i73608# If startPoint is equal to endPoint, then draw full circle instead of nothing (as Metafiles spec) + if (fDiff <= 0.) + fDiff += 2. * M_PI; + } + else + { + fDiff = (2. * M_PI) - fDiff; + if (fDiff > 2. * M_PI) + fDiff -= 2. * M_PI; + } // Proportionally shrink number of points( fDiff / (2PI) ); - nPoints = std::max( static_cast<sal_uInt16>( ( fDiff / (2 * M_PI) ) * nPoints ), sal_uInt16(16) ); - fStep = fDiff / ( nPoints - 1 ); + nPoints = std::max(static_cast<sal_uInt16>((fDiff / (2. * M_PI)) * nPoints), sal_uInt16(16)); + fStep = fDiff / (nPoints - 1); + if (bClockWiseArcDirection == true) + fStep = -fStep; - if( PolyStyle::Pie == eStyle ) + if (PolyStyle::Pie == eStyle) { - const Point aCenter2( FRound( fCenterX ), FRound( fCenterY ) ); + const Point aCenter2(FRound(fCenterX), FRound(fCenterY)); nStart = 1; nEnd = nPoints + 1; @@ -903,8 +915,9 @@ Polygon::Polygon( const Point& rCenter, tools::Long nRadX, tools::Long nRadY ) { } -Polygon::Polygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, - PolyStyle eStyle ) : mpImplPolygon(ImplPolygon(rBound, rStart, rEnd, eStyle)) +Polygon::Polygon(const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, + PolyStyle eStyle, const bool bClockWiseArcDirection) + : mpImplPolygon(ImplPolygon(rBound, rStart, rEnd, eStyle, bClockWiseArcDirection)) { } |