summaryrefslogtreecommitdiff
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 19:52:38 +0200
commit5eaa4feece4b3d0fba26cfe76d2be26e0f15c128 (patch)
tree2172719ff485bf2bc88923c82654014559796457
parente3f09dcbd5e6aafe42d02c7b51497007abcdf1f7 (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> (cherry picked from commit 9b693d896bf9a08cd8987e483f5269d6f2be1fd3) Reviewed-on: https://gerrit.libreoffice.org/36533
-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 6ad240ba6832..993d5c762c49 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>
@@ -74,7 +75,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
@@ -226,6 +227,7 @@ const char* emfTypeToName(sal_uInt16 type)
case EmfPlusRecordTypeDrawPie: return "EmfPlusRecordTypeDrawPie";
case EmfPlusRecordTypeFillPath: return "EmfPlusRecordTypeFillPath";
case EmfPlusRecordTypeDrawPath: return "EmfPlusRecordTypeDrawPath";
+ case EmfPlusRecordTypeDrawBeziers: return "EmfPlusRecordTypeDrawBeziers";
case EmfPlusRecordTypeDrawImage: return "EmfPlusRecordTypeDrawImage";
case EmfPlusRecordTypeDrawImagePoints: return "EmfPlusRecordTypeDrawImagePoints";
case EmfPlusRecordTypeDrawString: return "EmfPlusRecordTypeDrawString";
@@ -2104,6 +2106,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:
{