From 32cec4ca8bf1e09dd33aa461984e8e8ae34f4a7c Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Sat, 9 Apr 2016 23:15:09 +0200 Subject: tdf#48066 render stroke-miterlimit correctly in SVG import The property stroke-miterlimit is transported to the renderers via a new member mfMiterMinimumAngle in class LineAttribute Several drawPolyLine methods are adapted. This patch does not include changes in MetaAction. Presentation mode, printing, and PDF-export is still wrong. Corrected LineJoinMiter to LineJoinBevel in canvas, that s closer to NONE. Removed DrawPolyLine method without MiterMinimumAngle and adapted calls accordingly. Change-Id: I6bcd24add5d85c4d9a39e3788e0682091c5fc9c4 Reviewed-on: https://gerrit.libreoffice.org/23946 Tested-by: Jenkins Reviewed-by: Armin Le Grand Reviewed-by: Regina Henschel --- drawinglayer/source/attribute/lineattribute.cxx | 25 ++++++++++++++++------ .../source/primitive2d/polygonprimitive2d.cxx | 6 +++++- .../source/processor2d/vclpixelprocessor2d.cxx | 4 +++- drawinglayer/source/processor2d/vclprocessor2d.cxx | 3 ++- 4 files changed, 29 insertions(+), 9 deletions(-) (limited to 'drawinglayer') diff --git a/drawinglayer/source/attribute/lineattribute.cxx b/drawinglayer/source/attribute/lineattribute.cxx index 5e720fbd6969..89ce998924fe 100644 --- a/drawinglayer/source/attribute/lineattribute.cxx +++ b/drawinglayer/source/attribute/lineattribute.cxx @@ -34,16 +34,19 @@ namespace drawinglayer double mfWidth; // absolute line width basegfx::B2DLineJoin meLineJoin; // type of LineJoin css::drawing::LineCap meLineCap; // BUTT, ROUND, or SQUARE + double mfMiterMinimumAngle; // as needed for createAreaGeometry ImpLineAttribute( const basegfx::BColor& rColor, double fWidth, basegfx::B2DLineJoin aB2DLineJoin, - css::drawing::LineCap aLineCap) + css::drawing::LineCap aLineCap, + double fMiterMinimumAngle) : maColor(rColor), mfWidth(fWidth), meLineJoin(aB2DLineJoin), - meLineCap(aLineCap) + meLineCap(aLineCap), + mfMiterMinimumAngle(fMiterMinimumAngle) { } @@ -51,7 +54,8 @@ namespace drawinglayer : maColor(basegfx::BColor()), mfWidth(0.0), meLineJoin(basegfx::B2DLineJoin::Round), - meLineCap(css::drawing::LineCap_BUTT) + meLineCap(css::drawing::LineCap_BUTT), + mfMiterMinimumAngle(15.0 * F_PI180) { } @@ -60,13 +64,15 @@ namespace drawinglayer double getWidth() const { return mfWidth; } basegfx::B2DLineJoin getLineJoin() const { return meLineJoin; } css::drawing::LineCap getLineCap() const { return meLineCap; } + double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } bool operator==(const ImpLineAttribute& rCandidate) const { return (getColor() == rCandidate.getColor() && getWidth() == rCandidate.getWidth() && getLineJoin() == rCandidate.getLineJoin() - && getLineCap() == rCandidate.getLineCap()); + && getLineCap() == rCandidate.getLineCap() + && getMiterMinimumAngle() == rCandidate.getMiterMinimumAngle()); } }; @@ -80,13 +86,15 @@ namespace drawinglayer const basegfx::BColor& rColor, double fWidth, basegfx::B2DLineJoin aB2DLineJoin, - css::drawing::LineCap aLineCap) + css::drawing::LineCap aLineCap, + double fMiterMinimumAngle) : mpLineAttribute( ImpLineAttribute( rColor, fWidth, aB2DLineJoin, - aLineCap)) + aLineCap, + fMiterMinimumAngle)) { } @@ -144,6 +152,11 @@ namespace drawinglayer return mpLineAttribute->getLineCap(); } + double LineAttribute::getMiterMinimumAngle() const + { + return mpLineAttribute->getMiterMinimumAngle(); + } + } // end of namespace attribute } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index ddc83d02d670..76fc498d34d5 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -252,6 +252,7 @@ namespace drawinglayer const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin()); const css::drawing::LineCap aLineCap(getLineAttribute().getLineCap()); basegfx::B2DPolyPolygon aAreaPolyPolygon; + const double fMiterMinimumAngle(getLineAttribute().getMiterMinimumAngle()); for(sal_uInt32 a(0L); a < nCount; a++) { @@ -260,7 +261,10 @@ namespace drawinglayer aHairLinePolyPolygon.getB2DPolygon(a), fHalfLineWidth, aLineJoin, - aLineCap)); + aLineCap, + 12.5 * F_PI180 /* default fMaxAllowedAngle*/ , + 0.4 /* default fMaxPartOfEdge*/ , + fMiterMinimumAngle)); } // prepare return value diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 7b18c5900068..f3b08ec5795b 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -259,7 +259,9 @@ namespace drawinglayer fLineWidth, fTransparency, rSource.getLineAttribute().getLineJoin(), - rSource.getLineAttribute().getLineCap())) + rSource.getLineAttribute().getLineCap(), + rSource.getLineAttribute().getMiterMinimumAngle(), + false /*bBypassAACheck, default*/)) { bTryWorked = true; } diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index e6ce0f59fc43..f5d24cf001cb 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -1301,7 +1301,8 @@ namespace drawinglayer aHairlinePolyPolygon.getB2DPolygon(a), fDiscreteLineWidth, rLineAttribute.getLineJoin(), - rLineAttribute.getLineCap()); + rLineAttribute.getLineCap(), + rLineAttribute.getMiterMinimumAngle()); } bDone = true; -- cgit