summaryrefslogtreecommitdiff
path: root/cppcanvas/source
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2017-04-07 19:50:26 +0200
committerBartosz Kosiorek <gang65@poczta.onet.pl>2017-04-13 13:26:20 +0200
commit9b693d896bf9a08cd8987e483f5269d6f2be1fd3 (patch)
tree5260178e0897bf162c8126c1d2eb0bff52fcdd97 /cppcanvas/source
parent171477fb08e4b27b9659dc93bbd18480ab4930a7 (diff)
tdf#107019 EMF+ Add support for import EmfPlusRecordTypeDrawBeziers record
EmfPlusDrawBeziers record defines the pen strokes for drawing a Bezier spline. Change-Id: I6ae08a861bcbadd373741781af0011528947243e Reviewed-on: https://gerrit.libreoffice.org/36280 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'cppcanvas/source')
-rw-r--r--cppcanvas/source/mtfrenderer/emfplus.cxx50
1 files changed, 49 insertions, 1 deletions
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 7c33b28c213d..73c488c2abba 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -20,6 +20,7 @@
#include <tools/stream.hxx>
#include <vcl/metaact.hxx>
#include <vcl/graphicfilter.hxx>
+#include <basegfx/curve/b2dcubicbezier.hxx>
#include <basegfx/tools/canvastools.hxx>
#include <basegfx/tools/gradienttools.hxx>
#include <basegfx/tools/tools.hxx>
@@ -82,7 +83,7 @@ namespace
//TODO EmfPlusRecordTypeFillClosedCurve 0x4016
//TODO EmfPlusRecordTypeDrawClosedCurve 0x4017
//TODO EmfPlusRecordTypeDrawCurve 0x4018
-//TODO EmfPlusRecordTypeDrawBeziers 0x4019
+#define EmfPlusRecordTypeDrawBeziers 0x4019
#define EmfPlusRecordTypeDrawImage 0x401A
#define EmfPlusRecordTypeDrawImagePoints 0x401B
#define EmfPlusRecordTypeDrawString 0x401C
@@ -155,6 +156,7 @@ const char* emfTypeToName(sal_uInt16 type)
case EmfPlusRecordTypeFillPie: return "EmfPlusRecordTypeFillPie";
case EmfPlusRecordTypeFillPath: return "EmfPlusRecordTypeFillPath";
case EmfPlusRecordTypeDrawPath: return "EmfPlusRecordTypeDrawPath";
+ case EmfPlusRecordTypeDrawBeziers: return "EmfPlusRecordTypeDrawBeziers";
case EmfPlusRecordTypeDrawImage: return "EmfPlusRecordTypeDrawImage";
case EmfPlusRecordTypeDrawImagePoints: return "EmfPlusRecordTypeDrawImagePoints";
case EmfPlusRecordTypeDrawString: return "EmfPlusRecordTypeDrawString";
@@ -1066,6 +1068,52 @@ namespace cppcanvas
break;
}
+ case EmfPlusRecordTypeDrawBeziers:
+ {
+ sal_uInt32 aCount;
+ float x1, y1, x2, y2, x3, y3, x4, y4;
+ ::basegfx::B2DPoint aStartPoint, aControlPointA, aControlPointB, aEndPoint;
+ ::basegfx::B2DPolygon aPolygon;
+ rMF.ReadUInt32( aCount );
+
+ SAL_INFO("cppcanvas.emf", "EMF+ DrawBeziers slot: " << (flags & 0xff) << "Number of points: " << aCount);
+
+ SAL_WARN_IF( ( aCount - 1 ) % 3 != 0, "cppcanvas.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16...");
+
+ if( aCount < 4 )
+ {
+ SAL_WARN("cppcanvas.emf", "EMF+\t Bezier Draw does not support less than 4 points. Number of points: " << aCount);
+ break;
+ }
+
+ ReadPoint (rMF, x1, y1, flags);
+ // We need to add first starting point
+ aStartPoint = Map (x1, y1);
+ aPolygon.append( aStartPoint );
+
+ for( sal_uInt32 i = 4; i <= aCount; i += 3 )
+ {
+ ReadPoint (rMF, x2, y2, flags);
+ ReadPoint (rMF, x3, y3, flags);
+ ReadPoint (rMF, x4, y4, flags);
+
+ SAL_INFO("cppcanvas.emf", "EMF+\t Bezier points: " << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3 << " " << x4 << "," << y4);
+
+ aStartPoint = Map (x1, y1);
+ aControlPointA = Map (x2, y2);
+ aControlPointB = Map (x3, y3);
+ aEndPoint = Map (x4, y4);
+
+ ::basegfx::B2DCubicBezier cubicBezier( aStartPoint, aControlPointA, aControlPointB, aEndPoint );
+ cubicBezier.adaptiveSubdivideByDistance( aPolygon, 10.0 );
+ EMFPPlusDrawPolygon( ::basegfx::B2DPolyPolygon( aPolygon ), rFactoryParms,
+ rState, rCanvas, flags & 0xff );
+ // The ending coordinate of one Bezier curve is the starting coordinate of the next.
+ x1 = x4;
+ y1 = y4;
+ }
+ break;
+ }
case EmfPlusRecordTypeDrawImage:
case EmfPlusRecordTypeDrawImagePoints:
{