From 3b1db9b7a9afe147ed7f841c875bc3b91b03ace9 Mon Sep 17 00:00:00 2001 From: Patrick Jaap Date: Tue, 26 Sep 2017 14:42:44 +0200 Subject: tdf#112012 EMF+ dashed lines: correct dash length Since the first guess of the right transformation seemed to be wrong, here is the next try. The pure float value is multiplied with the pen width. This is way more intuitive for me and renders the EMF files from the bugtracker exactly like in MSO. See 588c5b0cff9bbdb2efbdfb259268154b0074e7e6 for the previous patch. Change-Id: I74e82a0f9800d950e0d989184765a53e520b48e6 Reviewed-on: https://gerrit.libreoffice.org/42810 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- drawinglayer/source/tools/emfphelperdata.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drawinglayer') diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index e95b243f7a0d..513b8fbce930 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -421,11 +421,13 @@ namespace emfplushelper if (pen->penDataFlags & 0x00000020 && pen->dashStyle != EmfPlusLineStyleCustom) // pen has a predefined line style { - // taken from the old cppcanvas implementation - const std::vector dash = { 3, 3 }; - const std::vector dot = { 1, 3 }; - const std::vector dashdot = { 3, 3, 1, 3 }; - const std::vector dashdotdot = { 3, 3, 1, 3, 1, 3 }; + // short writing + const double pw = transformedPenWidth; + // taken from the old cppcanvas implementation and multiplied with pen width + const std::vector dash = { 3*pw, 3*pw }; + const std::vector dot = { pw, 3*pw }; + const std::vector dashdot = { 3*pw, 3*pw, pw, 3*pw }; + const std::vector dashdotdot = { 3*pw, 3*pw, pw, 3*pw, pw, 3*pw }; drawinglayer::attribute::StrokeAttribute aStrokeAttribute; @@ -459,11 +461,8 @@ namespace emfplushelper std::vector aPattern(pen->dashPattern.size()); for (size_t i=0; idashPattern[i]),0).getX(); - // here, this is just a guess - // without transform it es way too small - // with 1 * MapSize(...) it es too large - // with 0.5 * MapSize is looks like in MSO + // convert from float to double and multiply with the adjusted pen width + aPattern[i] = transformedPenWidth * pen->dashPattern[i]; } drawinglayer::attribute::StrokeAttribute strokeAttribute(aPattern); mrTargetHolders.Current().append( -- cgit