From 5f61c9fe99ac93087b898adddbb4d4733f1fcd07 Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (Collabora)" Date: Thu, 6 Feb 2020 18:53:12 +0100 Subject: tdf#130478 Enhance Dashed line drawing on all systems For more info and explanation including state of process information and discussion(s) see task please. Adding corrections for gerrit build Change-Id: Ie10fb8093a86459dee80db5ab4355b47e46c1f8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88130 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- vcl/qt5/Qt5Graphics_GDI.cxx | 50 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 9 deletions(-) mode change 100644 => 100755 vcl/qt5/Qt5Graphics_GDI.cxx (limited to 'vcl/qt5') diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx old mode 100644 new mode 100755 index 2aa70949dc32..102c84900c08 --- a/vcl/qt5/Qt5Graphics_GDI.cxx +++ b/vcl/qt5/Qt5Graphics_GDI.cxx @@ -29,7 +29,9 @@ #include #include +#include #include +#include static const basegfx::B2DPoint aHalfPointOfs(0.5, 0.5); @@ -323,37 +325,67 @@ bool Qt5Graphics::drawPolyPolygonBezier(sal_uInt32 /*nPoly*/, const sal_uInt32* bool Qt5Graphics::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon& rPolyLine, double fTransparency, - const basegfx::B2DVector& rLineWidths, + const basegfx::B2DVector& rLineWidth, + const std::vector* pStroke, // MM01 basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap, double fMiterMinimumAngle, bool bPixelSnapHairline) { if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor) + { return true; + } - // short circuit if there is nothing to do - if (0 == rPolyLine.count()) + // MM01 check done for simple reasons + if (!rPolyLine.count() || fTransparency < 0.0 || fTransparency > 1.0) { return true; } + // MM01 need to do line dashing as fallback stuff here now + const double fDotDashLength( + nullptr != pStroke ? std::accumulate(pStroke->begin(), pStroke->end(), 0.0) : 0.0); + const bool bStrokeUsed(0.0 != fDotDashLength); + basegfx::B2DPolyPolygon aPolyPolygonLine; + + if (bStrokeUsed) + { + // apply LineStyle + basegfx::utils::applyLineDashing(rPolyLine, // source + *pStroke, // pattern + &aPolyPolygonLine, // traget for lines + nullptr, // target for gaps + fDotDashLength); // full length if available + } + else + { + // no line dashing, just copy + aPolyPolygonLine.append(rPolyLine); + } + // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline - basegfx::B2DPolygon aPolyLine(rPolyLine); - aPolyLine.transform(rObjectToDevice); + aPolyPolygonLine.transform(rObjectToDevice); if (bPixelSnapHairline) { - aPolyLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine); + aPolyPolygonLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyPolygonLine); } - const basegfx::B2DVector aLineWidths(rObjectToDevice * rLineWidths); + const basegfx::B2DVector aLineWidth(rObjectToDevice * rLineWidth); // setup poly-polygon path QPainterPath aPath; - AddPolygonToPath(aPath, aPolyLine, aPolyLine.isClosed(), !getAntiAliasB2DDraw(), true); + + // MM01 todo - I assume that this is OKAY to be done in one run for Qt5, + // but this NEEDS to be checked/verified + for (sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++) + { + const basegfx::B2DPolygon aPolyLine(aPolyPolygonLine.getB2DPolygon(a)); + AddPolygonToPath(aPath, aPolyLine, aPolyLine.isClosed(), !getAntiAliasB2DDraw(), true); + } Qt5Painter aPainter(*this, false, 255 * (1.0 - fTransparency)); // setup line attributes QPen aPen = aPainter.pen(); - aPen.setWidth(aLineWidths.getX()); + aPen.setWidth(aLineWidth.getX()); switch (eLineJoin) { -- cgit