summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2022-03-07 12:26:03 +0100
committerBartosz Kosiorek <gang65@poczta.onet.pl>2022-03-10 21:19:59 +0100
commit7b28920382d3820344bfc4075bac98f85e838dba (patch)
treedd66a426f9b9b6b6fdb6d698941309ad31d2e4f3 /tools
parent8f48f91009caa86d896f247059874242ed18bf39 (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')
-rw-r--r--tools/inc/poly.h2
-rw-r--r--tools/source/generic/poly.cxx41
2 files changed, 28 insertions, 15 deletions
diff --git a/tools/inc/poly.h b/tools/inc/poly.h
index 64885ac29762..772e854e31fb 100644
--- a/tools/inc/poly.h
+++ b/tools/inc/poly.h
@@ -38,7 +38,7 @@ public:
ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound);
ImplPolygon( const Point& rCenter, tools::Long nRadX, tools::Long nRadY );
ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd,
- PolyStyle eStyle );
+ PolyStyle eStyle, bool bClockWiseArcDirection );
ImplPolygon( const Point& rBezPt1, const Point& rCtrlPt1, const Point& rBezPt2,
const Point& rCtrlPt2, sal_uInt16 nPoints );
ImplPolygon(const basegfx::B2DPolygon& rPolygon);
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))
{
}