summaryrefslogtreecommitdiff
path: root/tools/source
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2022-03-07 12:26:03 +0100
committerAndras Timar <andras.timar@collabora.com>2022-03-22 10:30:04 +0100
commit4b26bf4daa581a7426dd1f4cad3feef62ac5df11 (patch)
treeee66c07a6fa89632cb76b6ef85898a64904fe365 /tools/source
parent13c68ba93ab98fa1e49a0aa4aa393f25143420ca (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> (cherry picked from commit 7b28920382d3820344bfc4075bac98f85e838dba) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131206 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'tools/source')
-rw-r--r--tools/source/generic/poly.cxx41
1 files changed, 27 insertions, 14 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 13d2df0e47ef..44fa52fd7d44 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))
{
}