diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-03-17 18:16:04 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-03-22 11:56:55 +0100 |
commit | 8932c8906ff31f0f50f7478d41821506b0941cdf (patch) | |
tree | b509bac264d77a76f9ca89b2d6ccabcdd15e285e /emfio | |
parent | cc289e9a47291111dcfa40a520c41da459fe4edc (diff) |
tdf#35986 tdf#140271 EMF Fix line width of CREATEPEN record
According to [MS-EMF] documentation:
"If the pen type in the PenStyle field is
PS_COSMETIC, this value MUST be 0x00000001."
Unfortunately based on observation of EMF import,
it seems that it is not true. As a result the implementation
must be partially reversed.
Change-Id: I0c2ec5e26b710e1a12d5196b6c8be4709f26dc4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112651
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112865
Diffstat (limited to 'emfio')
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 30 | ||||
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 17 |
2 files changed, 21 insertions, 26 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index e81a37d48487..7ec0e915abdc 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -311,7 +311,7 @@ void Test::TestEnglishMapMode() void Test::TestCreatePen() { // Check import of EMF image with records: RESTOREDC, SAVEDC, MOVETOEX, LINETO, POLYLINE16, EXTTEXTOUTW with DxBuffer - // The CREATEPEN record is used with PS_COSMETIC line style, which will be displayed as solid hairline + // The CREATEPEN record is used with PS_COSMETIC line style, which sometimes will be displayed as solid hairline Primitive2DSequence aSequence = parseEmf("/emfio/qa/cppunit/emf/data/TestCreatePen.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -320,24 +320,24 @@ void Test::TestCreatePen() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", "path", "m0 0h31250v18192h-31250z"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 3); - assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", "17898,5693 20172,5693"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "color", "#008000"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "width", "3"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke", 748); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/polygon", "27875,16523 27875,1453"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[1]/line", "width", "6"); - assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/polygon", "17898,6959 20172,6959"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "color", "#000080"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "width", "3"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/polygon", "27975,16453 27875,16453"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[2]/line", "width", "6"); - assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/polygon", "17898,7381 20172,7381"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/polygon", "27925,16078 27875,16078"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/line", "color", "#ff0000"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/line", "width", "3"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonstroke[3]/line", "width", "6"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 755); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]", "color", "#ff0000"); - assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]/polygon", "27925,14180 27875,14180"); - assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[100]", "color", "#008000"); - assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[100]/polygon", "26100,14414 26050,14414"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline", 10); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[5]", "color", "#008000"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[5]/polygon", "25850,2179 25844,1958"); + assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]", "color", "#000080"); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[10]/polygon", "2025,1642 2025,1501"); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion", 69); assertXPath(pDocument, "/primitive2D/metafile/transform/mask/textsimpleportion[1]", "width", "374"); diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 5dfd2ffbe76c..4c0859bbff5a 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1122,17 +1122,12 @@ namespace emfio mpInputStream->ReadUInt32( nStyle ).ReadInt32( nPenWidth ).ReadInt32( nIgnored ); - SAL_INFO("emfio", "\t\tIndex: " << nIndex << " nStyle: 0x" << std::hex << nStyle << std::dec << " nPenWidth: " << nPenWidth); - // nStyle = PS_COSMETIC = 0x0 - line with a width of one logical unit and a style that is a solid color - if ( !nStyle ) - { - // Width 0 means default width for LineInfo (HairLine) with 1 pixel wide - aLineInfo.SetWidth( 0 ); - } - else - { - aLineInfo.SetWidth( nPenWidth ); - } + SAL_INFO("emfio", "\t\tIndex: " << nIndex << " Style: 0x" << std::hex << nStyle << std::dec << " PenWidth: " << nPenWidth); + // According to documentation: nStyle = PS_COSMETIC = 0x0 - line with a width of one logical unit and a style that is a solid color + // tdf#140271 Based on observed behaviour the line width is not constant with PS_COSMETIC + + // Width 0 means default width for LineInfo (HairLine) with 1 pixel wide + aLineInfo.SetWidth( nPenWidth ); bool bTransparent = false; switch( nStyle & PS_STYLE_MASK ) |