[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - vcl/qa vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Tue Apr 26 22:29:14 UTC 2016


 vcl/qa/cppunit/wmf/wmfimporttest.cxx |   24 ++++++++++++------------
 vcl/source/filter/wmf/enhwmf.cxx     |   26 ++++----------------------
 vcl/source/filter/wmf/winmtf.cxx     |   12 ++++++++++--
 vcl/source/filter/wmf/winwmf.cxx     |   11 -----------
 4 files changed, 26 insertions(+), 47 deletions(-)

New commits:
commit e21606f3cce557e5eb84b2e7747c173edf526a55
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sun Mar 6 12:24:09 2016 +1100

    tdf#79679 vcl: dashed lines show as solid lines when importing EMF files
    
    Backported fix to 5.0.
    
    Issue is a regression in commit 09c722873b2d378d2d155f5f1dd7d8f3fb2012e9.
    (EMF/WMF: fix rendering of pen styles (dash, dot, dashdot, dashdotdot).
    
    I've looked at how the latest version of Word on the Mac works, and it
    turns out that the spacings for the PenStyle enumerations in the LogPen
    objects for all the create pen EMF records are as follows:
    
    * PS_DOT           - ■ □ ■ □ ■ □ ■ □ ■ □ ■
    * PS_DASHDOT       - ■ ■ ■ □ ■ □ ■ ■ ■ □ ■
    * PS_DASHDOTDOT    - ■ ■ ■ □ ■ □ ■ □ ■ ■ ■
    
    (where ■ is the actual filled in area, and □ is the space between the
    filled in areas)
    
    In other words, each dash fills in the space of three dots, and there
    is the one dot worth of empty space between the dashes and dots. Each
    "dot" has a width and height equal to the width specified in the pen.
    
    So basically, we seem to be arbitrarily setting the dot, dash and
    distance lengths arbitrarily, which were reasonable guesses but tended
    to produce very odd lines at different zoom levels.
    
    Change-Id: Ie8b5fa396e4fb0f480cb3594c8129a59f472c1b8
    Reviewed-on: https://gerrit.libreoffice.org/22886
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/22928
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/vcl/qa/cppunit/wmf/wmfimporttest.cxx b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
index 32c4d90..176ff5d 100644
--- a/vcl/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
@@ -146,38 +146,38 @@ void WmfTest::testEmfLineStyles()
     assertXPath(pDoc, "/metafile/linecolor[5]", "color", "#0000ff");
 
     assertXPath(pDoc, "/metafile/line[1]", "style", "dash");
-    assertXPath(pDoc, "/metafile/line[1]", "dashlen", "225");
+    assertXPath(pDoc, "/metafile/line[1]", "dashlen", "528");
     assertXPath(pDoc, "/metafile/line[1]", "dashcount", "1");
-    assertXPath(pDoc, "/metafile/line[1]", "dotlen", "0");
+    assertXPath(pDoc, "/metafile/line[1]", "dotlen", "176");
     assertXPath(pDoc, "/metafile/line[1]", "dotcount", "0");
-    assertXPath(pDoc, "/metafile/line[1]", "distance", "100");
+    assertXPath(pDoc, "/metafile/line[1]", "distance", "176");
     assertXPath(pDoc, "/metafile/line[1]", "join", "miter");
     assertXPath(pDoc, "/metafile/line[1]", "cap", "butt");
 
     assertXPath(pDoc, "/metafile/line[2]", "style", "dash");
-    assertXPath(pDoc, "/metafile/line[2]", "dashlen", "0");
+    assertXPath(pDoc, "/metafile/line[2]", "dashlen", "528");
     assertXPath(pDoc, "/metafile/line[2]", "dashcount", "0");
-    assertXPath(pDoc, "/metafile/line[2]", "dotlen", "30");
+    assertXPath(pDoc, "/metafile/line[2]", "dotlen", "176");
     assertXPath(pDoc, "/metafile/line[2]", "dotcount", "1");
-    assertXPath(pDoc, "/metafile/line[2]", "distance", "50");
+    assertXPath(pDoc, "/metafile/line[2]", "distance", "176");
     assertXPath(pDoc, "/metafile/line[2]", "join", "miter");
     assertXPath(pDoc, "/metafile/line[2]", "cap", "butt");
 
     assertXPath(pDoc, "/metafile/line[3]", "style", "dash");
-    assertXPath(pDoc, "/metafile/line[3]", "dashlen", "150");
+    assertXPath(pDoc, "/metafile/line[3]", "dashlen", "528");
     assertXPath(pDoc, "/metafile/line[3]", "dashcount", "1");
-    assertXPath(pDoc, "/metafile/line[3]", "dotlen", "30");
+    assertXPath(pDoc, "/metafile/line[3]", "dotlen", "176");
     assertXPath(pDoc, "/metafile/line[3]", "dotcount", "1");
-    assertXPath(pDoc, "/metafile/line[3]", "distance", "90");
+    assertXPath(pDoc, "/metafile/line[3]", "distance", "176");
     assertXPath(pDoc, "/metafile/line[3]", "join", "miter");
     assertXPath(pDoc, "/metafile/line[3]", "cap", "butt");
 
     assertXPath(pDoc, "/metafile/line[4]", "style", "dash");
-    assertXPath(pDoc, "/metafile/line[4]", "dashlen", "150");
+    assertXPath(pDoc, "/metafile/line[4]", "dashlen", "528");
     assertXPath(pDoc, "/metafile/line[4]", "dashcount", "1");
-    assertXPath(pDoc, "/metafile/line[4]", "dotlen", "30");
+    assertXPath(pDoc, "/metafile/line[4]", "dotlen", "176");
     assertXPath(pDoc, "/metafile/line[4]", "dotcount", "2");
-    assertXPath(pDoc, "/metafile/line[4]", "distance", "50");
+    assertXPath(pDoc, "/metafile/line[4]", "distance", "176");
     assertXPath(pDoc, "/metafile/line[4]", "join", "miter");
     assertXPath(pDoc, "/metafile/line[4]", "cap", "butt");
 };
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 5b1099d..674f1b4 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -17,11 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "winmtf.hxx"
 #include <osl/endian.h>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <boost/bind.hpp>
 #include <vcl/dibtools.hxx>
+
+#include "winmtf.hxx"
+
 #include <boost/scoped_array.hpp>
 
 using namespace std;
@@ -902,37 +904,27 @@ bool EnhWMFReader::ReadEnhWMF()
                             aLineInfo.SetWidth( aSize.Width() );
 
                         bool bTransparent = false;
-                        switch( nStyle & 0xFF )
+                        switch( nStyle & PS_STYLE_MASK )
                         {
                             case PS_DASHDOTDOT :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 1 );
                                 aLineInfo.SetDotCount( 2 );
-                                aLineInfo.SetDashLen( 150 );
-                                aLineInfo.SetDotLen( 30 );
-                                aLineInfo.SetDistance( 50 );
                             break;
                             case PS_DASHDOT :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 1 );
                                 aLineInfo.SetDotCount( 1 );
-                                aLineInfo.SetDashLen( 150 );
-                                aLineInfo.SetDotLen( 30 );
-                                aLineInfo.SetDistance( 90 );
                             break;
                             case PS_DOT :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 0 );
                                 aLineInfo.SetDotCount( 1 );
-                                aLineInfo.SetDotLen( 30 );
-                                aLineInfo.SetDistance( 50 );
                             break;
                             case PS_DASH :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 1 );
                                 aLineInfo.SetDotCount( 0 );
-                                aLineInfo.SetDashLen( 225 );
-                                aLineInfo.SetDistance( 100 );
                             break;
                             case PS_NULL :
                                 bTransparent = true;
@@ -1005,31 +997,21 @@ bool EnhWMFReader::ReadEnhWMF()
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 1 );
                                 aLineInfo.SetDotCount( 2 );
-                                aLineInfo.SetDashLen( 150 );
-                                aLineInfo.SetDotLen( 30 );
-                                aLineInfo.SetDistance( 50 );
                             break;
                             case PS_DASHDOT :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 1 );
                                 aLineInfo.SetDotCount( 1 );
-                                aLineInfo.SetDashLen( 150 );
-                                aLineInfo.SetDotLen( 30 );
-                                aLineInfo.SetDistance( 90 );
                             break;
                             case PS_DOT :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 0 );
                                 aLineInfo.SetDotCount( 1 );
-                                aLineInfo.SetDotLen( 30 );
-                                aLineInfo.SetDistance( 50 );
                             break;
                             case PS_DASH :
                                 aLineInfo.SetStyle( LINE_DASH );
                                 aLineInfo.SetDashCount( 1 );
                                 aLineInfo.SetDotCount( 0 );
-                                aLineInfo.SetDashLen( 225 );
-                                aLineInfo.SetDistance( 100 );
                             break;
                             case PS_NULL :
                                 bTransparent = true;
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index b2ae7dc..891ce44 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -730,8 +730,16 @@ void WinMtfOutput::CreateObject( sal_Int32 nIndex, GDIObjectType eType, void* pS
             {
                 WinMtfLineStyle* pLineStyle = static_cast<WinMtfLineStyle*>(pStyle);
                 Size aSize(pLineStyle->aLineInfo.GetWidth(), 0);
-                aSize = ImplMap(aSize);
-                pLineStyle->aLineInfo.SetWidth(aSize.Width());
+                pLineStyle->aLineInfo.SetWidth( ImplMap(aSize).Width() );
+
+                if ( pLineStyle->aLineInfo.GetStyle() == LINE_DASH )
+                {
+                    aSize.Width() += 1;
+                    long nDotLen = ImplMap( aSize ).Width();
+                    pLineStyle->aLineInfo.SetDistance( nDotLen );
+                    pLineStyle->aLineInfo.SetDotLen( nDotLen );
+                    pLineStyle->aLineInfo.SetDashLen( nDotLen * 3 );
+                }
             }
         }
         if ( (sal_uInt32)nIndex >= vGDIObj.size() )
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 04e5535..e89d555 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -813,31 +813,20 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
                     aLineInfo.SetStyle( LINE_DASH );
                     aLineInfo.SetDashCount( 1 );
                     aLineInfo.SetDotCount( 2 );
-                    aLineInfo.SetDashLen( 150 );
-                    aLineInfo.SetDotLen( 30 );
-                    aLineInfo.SetDistance( 50 );
                 break;
                 case PS_DASHDOT :
                     aLineInfo.SetStyle( LINE_DASH );
                     aLineInfo.SetDashCount( 1 );
                     aLineInfo.SetDotCount( 1 );
-                    aLineInfo.SetDashLen( 150 );
-                    aLineInfo.SetDotLen( 30 );
-                    aLineInfo.SetDistance( 90 );
                 break;
                 case PS_DOT :
                     aLineInfo.SetStyle( LINE_DASH );
                     aLineInfo.SetDashCount( 0 );
-                    aLineInfo.SetDotCount( 1 );
-                    aLineInfo.SetDotLen( 30 );
-                    aLineInfo.SetDistance( 50 );
                 break;
                 case PS_DASH :
                     aLineInfo.SetStyle( LINE_DASH );
                     aLineInfo.SetDashCount( 1 );
                     aLineInfo.SetDotCount( 0 );
-                    aLineInfo.SetDashLen( 225 );
-                    aLineInfo.SetDistance( 100 );
                 break;
                 case PS_NULL :
                     bTransparent = true;


More information about the Libreoffice-commits mailing list