[Libreoffice-commits] core.git: drawinglayer/source

Patrick Jaap patrick.jaap at tu-dresden.de
Thu Sep 28 20:36:40 UTC 2017


 drawinglayer/source/tools/emfphelperdata.cxx |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

New commits:
commit 3b1db9b7a9afe147ed7f841c875bc3b91b03ace9
Author: Patrick Jaap <patrick.jaap at tu-dresden.de>
Date:   Tue Sep 26 14:42:44 2017 +0200

    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 <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

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<double> dash = { 3, 3 };
-                const std::vector<double> dot = { 1, 3 };
-                const std::vector<double> dashdot = { 3, 3, 1, 3 };
-                const std::vector<double> 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<double> dash = { 3*pw, 3*pw };
+                const std::vector<double> dot = { pw, 3*pw };
+                const std::vector<double> dashdot = { 3*pw, 3*pw, pw, 3*pw };
+                const std::vector<double> dashdotdot = { 3*pw, 3*pw, pw, 3*pw, pw, 3*pw };
 
                 drawinglayer::attribute::StrokeAttribute aStrokeAttribute;
 
@@ -459,11 +461,8 @@ namespace emfplushelper
                 std::vector<double> aPattern(pen->dashPattern.size());
                 for (size_t i=0; i<aPattern.size(); i++)
                 {
-                    aPattern[i] = 0.5 * MapSize(double(pen->dashPattern[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(


More information about the Libreoffice-commits mailing list