[Libreoffice-commits] core.git: vcl/qa vcl/source

Stephan van den Akker stephanv778 at gmail.com
Fri Feb 26 08:57:11 UTC 2016


 vcl/qa/cppunit/wmf/data/line_styles.emf |binary
 vcl/qa/cppunit/wmf/wmfimporttest.cxx    |   46 ++++++++++++++++++++++++++++++++
 vcl/source/filter/wmf/enhwmf.cxx        |   36 ++++++++++++++++---------
 3 files changed, 70 insertions(+), 12 deletions(-)

New commits:
commit 9db34a7712e277389b2041cfbd77a60476d7f7f1
Author: Stephan van den Akker <stephanv778 at gmail.com>
Date:   Tue Feb 23 11:13:20 2016 +0100

    Improve the import of pen styles from EMF files
    
    Change-Id: I643c29befeb29b7b1cdd66375f661f4adb0e6cfa
    Reviewed-on: https://gerrit.libreoffice.org/22638
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/vcl/qa/cppunit/wmf/data/line_styles.emf b/vcl/qa/cppunit/wmf/data/line_styles.emf
new file mode 100644
index 0000000..07b7832
Binary files /dev/null and b/vcl/qa/cppunit/wmf/data/line_styles.emf differ
diff --git a/vcl/qa/cppunit/wmf/wmfimporttest.cxx b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
index 6e595c0..2a1a341 100644
--- a/vcl/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
@@ -43,6 +43,7 @@ public:
     void testNonPlaceableWmf();
     void testSine();
     void testEmfProblem();
+    void testEmfLineStyles();
     void testWorldTransformFontSize();
     void testTdf93750();
 
@@ -50,6 +51,7 @@ public:
     CPPUNIT_TEST(testNonPlaceableWmf);
     CPPUNIT_TEST(testSine);
     CPPUNIT_TEST(testEmfProblem);
+    CPPUNIT_TEST(testEmfLineStyles);
     CPPUNIT_TEST(testWorldTransformFontSize);
     CPPUNIT_TEST(testTdf93750);
 
@@ -120,6 +122,50 @@ void WmfTest::testEmfProblem()
     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876");
 }
 
+void WmfTest::testEmfLineStyles()
+{
+    SvFileStream aFileStream(getFullUrl("line_styles.emf"), StreamMode::READ);
+    GDIMetaFile aGDIMetaFile;
+    ReadWindowMetafile(aFileStream, aGDIMetaFile);
+
+    MetafileXmlDump dumper;
+    dumper.filterAllActionTypes();
+    dumper.filterActionType(MetaActionType::LINE, false);
+    dumper.filterActionType(MetaActionType::LINECOLOR, false);
+    xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
+
+    CPPUNIT_ASSERT (pDoc);
+
+    assertXPath(pDoc, "/metafile/line", 4);
+    assertXPath(pDoc, "/metafile/linecolor", 5);
+
+    assertXPath(pDoc, "/metafile/linecolor[1]", "color", "#ffffff");
+    assertXPath(pDoc, "/metafile/linecolor[2]", "color", "#00ff00");
+    assertXPath(pDoc, "/metafile/linecolor[3]", "color", "#408080");
+    assertXPath(pDoc, "/metafile/linecolor[4]", "color", "#ff0000");
+    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]", "dotlen", "0");
+    assertXPath(pDoc, "/metafile/line[1]", "distance", "100");
+
+    assertXPath(pDoc, "/metafile/line[2]", "style", "dash");
+    assertXPath(pDoc, "/metafile/line[2]", "dashlen", "0");
+    assertXPath(pDoc, "/metafile/line[2]", "dotlen", "30");
+    assertXPath(pDoc, "/metafile/line[2]", "distance", "50");
+
+    assertXPath(pDoc, "/metafile/line[3]", "style", "dash");
+    assertXPath(pDoc, "/metafile/line[3]", "dashlen", "150");
+    assertXPath(pDoc, "/metafile/line[3]", "dotlen", "30");
+    assertXPath(pDoc, "/metafile/line[3]", "distance", "90");
+
+    assertXPath(pDoc, "/metafile/line[4]", "style", "dash");
+    assertXPath(pDoc, "/metafile/line[4]", "dashlen", "150");
+    assertXPath(pDoc, "/metafile/line[4]", "dotlen", "30");
+    assertXPath(pDoc, "/metafile/line[4]", "distance", "50");
+};
+
 void WmfTest::testWorldTransformFontSize()
 {
     SvFileStream aFileStream(getFullUrl("image1.emf"), StreamMode::READ);
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index f8341e3..02eebdf 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -1008,20 +1008,38 @@ bool EnhWMFReader::ReadEnhWMF()
                             aLineInfo.SetWidth( nWidth );
 
                         bool bTransparent = false;
-                        sal_uInt16 nDashCount = 0;
-                        sal_uInt16 nDotCount = 0;
 
                         switch( nStyle & PS_STYLE_MASK )
                         {
                             case PS_DASHDOTDOT :
-                                nDotCount++;
+                                aLineInfo.SetStyle( LINE_DASH );
+                                aLineInfo.SetDashCount( 1 );
+                                aLineInfo.SetDotCount( 2 );
+                                aLineInfo.SetDashLen( 150 );
+                                aLineInfo.SetDotLen( 30 );
+                                aLineInfo.SetDistance( 50 );
+                            break;
                             case PS_DASHDOT :
-                                nDashCount++;
+                                aLineInfo.SetStyle( LINE_DASH );
+                                aLineInfo.SetDashCount( 1 );
+                                aLineInfo.SetDotCount( 1 );
+                                aLineInfo.SetDashLen( 150 );
+                                aLineInfo.SetDotLen( 30 );
+                                aLineInfo.SetDistance( 90 );
+                            break;
                             case PS_DOT :
-                                nDotCount++;
+                                aLineInfo.SetStyle( LINE_DASH );
+                                aLineInfo.SetDashCount( 0 );
+                                aLineInfo.SetDotCount( 1 );
+                                aLineInfo.SetDotLen( 30 );
+                                aLineInfo.SetDistance( 50 );
                             break;
                             case PS_DASH :
-                                nDashCount++;
+                                aLineInfo.SetStyle( LINE_DASH );
+                                aLineInfo.SetDashCount( 1 );
+                                aLineInfo.SetDotCount( 0 );
+                                aLineInfo.SetDashLen( 225 );
+                                aLineInfo.SetDistance( 100 );
                             break;
                             case PS_NULL :
                                 bTransparent = true;
@@ -1033,12 +1051,6 @@ bool EnhWMFReader::ReadEnhWMF()
                             default :
                                 aLineInfo.SetStyle( LINE_SOLID );
                         }
-                        if ( nDashCount | nDotCount )
-                        {
-                            aLineInfo.SetStyle( LINE_DASH );
-                            aLineInfo.SetDashCount( nDashCount );
-                            aLineInfo.SetDotCount( nDotCount );
-                        }
                         pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( aColorRef, aLineInfo, bTransparent ) );
                     }
                 }


More information about the Libreoffice-commits mailing list