[Libreoffice-commits] core.git: emfio/qa emfio/source
Bartosz Kosiorek (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 19 08:00:53 UTC 2021
emfio/qa/cppunit/emf/EmfImportTest.cxx | 30 +++++++++++++++---------------
emfio/source/reader/emfreader.cxx | 17 ++++++-----------
2 files changed, 21 insertions(+), 26 deletions(-)
New commits:
commit 54a8aefa3372dce3da7cf0ad846d55d1b7b92467
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Wed Mar 17 18:16:04 2021 +0100
Commit: Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Fri Mar 19 09:00:11 2021 +0100
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 at poczta.onet.pl>
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 85450a2e67a3..f587135e1b1e 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -312,7 +312,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(u"/emfio/qa/cppunit/emf/data/TestCreatePen.emf");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
@@ -321,24 +321,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 30730725a182..e5a3b7d65046 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1131,17 +1131,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 )
More information about the Libreoffice-commits
mailing list