From ef967a90bb297ab657316c626e1f5bedc068124d Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Fri, 7 Dec 2012 16:53:46 +0100 Subject: [PATCH] #i121437 Add display of quadratic Bezier curve in custom shapes Author: Regina Henschel --- .../source/customshapes/EnhancedCustomShape2d.cxx | 28 ++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/main/svx/source/customshapes/EnhancedCustomShape2d.cxx b/main/svx/source/customshapes/EnhancedCustomShape2d.cxx index c6c3978..82cf78a 100644 --- a/main/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/main/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1494,6 +1494,34 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm } } break; + + case QUADRATICCURVETO : + { + for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 1 ) < nCoordSize ); i++ ) + { + if ( rSrcPt ) + { + const Point aPreviousEndPoint(GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True)); + const Point aControlQ(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); + const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); + const Point aControlA((aPreviousEndPoint + (aControlQ * 2)) / 3); + const Point aControlB(((aControlQ * 2) + aEnd) / 3); + DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding Q control point (!)"); + aNewB2DPolygon.appendBezierSegment( + basegfx::B2DPoint(aControlA.X(), aControlA.Y()), + basegfx::B2DPoint(aControlB.X(), aControlB.Y()), + basegfx::B2DPoint(aEnd.X(), aEnd.Y())); + } + else // no previous point , do a moveto + { + rSrcPt++; // skip control point + const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True )); + DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding Q control point (!)"); + aNewB2DPolygon.append(basegfx::B2DPoint(aEnd.X(), aEnd.Y())); + } + } + } + break; case ANGLEELLIPSE : { -- 1.7.5.1