emfio/qa/cppunit/emf/EmfImportTest.cxx | 45 ++++++++++++++++++--------------- emfio/source/reader/emfreader.cxx | 25 +++++++++++------- emfio/source/reader/mtftools.cxx | 4 +- 3 files changed, 43 insertions(+), 31 deletions(-)
New commits: commit bbdbe8ea2ef176ef6f08b30b3c18876c2c4f0c22 Author: Bartosz Kosiorek <gan...@poczta.onet.pl> AuthorDate: Fri Feb 3 22:55:54 2023 +0100 Commit: Bartosz Kosiorek <gan...@poczta.onet.pl> CommitDate: Sat Feb 11 21:24:18 2023 +0000 tdf#142018 Properly create Pen width if style is COSMETIC Change-Id: I6453058c4af352a3b0e14cbccbc1a67c73cd1426 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146551 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 75f2b9001a08..e858fd7afc4d 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -180,14 +180,19 @@ void Test::testPolyPolygon() assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", "m2574 13194v-12065h15303v12065z"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 116); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 44); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - "2574,13194 2574,1129 17877,1129 17877,13194"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ffffff"); - + "2574,13194 2574,1129"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#000000"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "0"); + assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", + "2574,1129 2574,1129"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", "#000000"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", - "8674,13194 8674,1129"); + "8674,1129 8674,1129"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "color", "#000000"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "width", "0"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 28); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[6]", "width", "459"); @@ -1547,7 +1552,7 @@ void Test::TestRoundRect() 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 sometimes will be displayed as solid hairline + // The CREATEPEN record is used with PS_COSMETIC line style, and in this case width must be set to 0 Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestCreatePen.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -1556,29 +1561,29 @@ void Test::TestCreatePen() assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", "m0 0h31250v18192h-31250z"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 748); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 3); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - "27875,16523 27875,1453"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#ff0000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "6"); + "17898,5693 20172,5693"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", "#008000"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", - "27975,16453 27875,16453"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", "#ff0000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", "6"); + "17898,6959 20172,6959"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", "#000080"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", "0"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[3]/polygon", - "27925,16078 27875,16078"); + "17898,7381 20172,7381"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[3]/line", "color", "#ff0000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[3]/line", "width", "6"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[3]/line", "width", "0"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline", 10); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline[5]", "color", "#008000"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline", 755); + assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline[5]", "color", "#ff0000"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[5]/polygon", - "25850,2179 25844,1958"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline[10]", "color", "#000080"); + "27925,16078 27875,16078"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline[10]", "color", "#ff0000"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[10]/polygon", - "2025,1642 2025,1501"); + "27925,14180 27875,14180"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 69); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[1]", "width", "374"); diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index c24a053d3bc1..be4c8319238b 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1154,13 +1154,17 @@ namespace emfio mpInputStream->ReadUInt32(nIndex); if ((nIndex & ENHMETA_STOCK_OBJECT) == 0) { - sal_uInt32 nStyle(0); + sal_uInt32 nPenStyle(0); sal_Int32 nPenWidth(0), nIgnored; - mpInputStream->ReadUInt32(nStyle).ReadInt32(nPenWidth).ReadInt32(nIgnored); + mpInputStream->ReadUInt32(nPenStyle).ReadInt32(nPenWidth).ReadInt32(nIgnored); SAL_INFO("emfio", "\t\tIndex: " << nIndex << " Style: 0x" << std::hex - << nStyle << std::dec + << nPenStyle << std::dec << " PenWidth: " << nPenWidth); - CreateObjectIndexed(nIndex, std::make_unique<WinMtfLineStyle>(ReadColor(), nStyle, nPenWidth)); + if ((nPenStyle & PS_STYLE_MASK) > PS_INSIDEFRAME) + nPenStyle = PS_COSMETIC; + if ((nPenStyle & PS_GEOMETRIC) == 0) + nPenWidth = 0; + CreateObjectIndexed(nIndex, std::make_unique<WinMtfLineStyle>(ReadColor(), nPenStyle, nPenWidth)); } } break; @@ -1170,12 +1174,15 @@ namespace emfio mpInputStream->ReadUInt32(nIndex); if ((nIndex & ENHMETA_STOCK_OBJECT) == 0) { - sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries; + sal_uInt32 offBmi, cbBmi, offBits, cbBits, nPenStyle, nWidth, nBrushStyle, elpNumEntries; sal_Int32 elpHatch; mpInputStream->ReadUInt32(offBmi).ReadUInt32(cbBmi).ReadUInt32(offBits).ReadUInt32(cbBits); - mpInputStream->ReadUInt32(nStyle).ReadUInt32(nWidth).ReadUInt32(nBrushStyle); - - SAL_INFO("emfio", "\t\tStyle: 0x" << std::hex << nStyle << std::dec); + mpInputStream->ReadUInt32(nPenStyle).ReadUInt32(nWidth).ReadUInt32(nBrushStyle); + SAL_INFO("emfio", "\t\tStyle: 0x" << std::hex << nPenStyle << std::dec); + if ((nPenStyle & PS_STYLE_MASK) > PS_INSIDEFRAME) + nPenStyle = PS_COSMETIC; + if ((nPenStyle & PS_GEOMETRIC) == 0) + nWidth = 0; SAL_INFO("emfio", "\t\tWidth: " << nWidth); Color aColorRef = ReadColor(); mpInputStream->ReadInt32(elpHatch).ReadUInt32(elpNumEntries); @@ -1183,7 +1190,7 @@ namespace emfio if (!mpInputStream->good()) bStatus = false; else - CreateObjectIndexed(nIndex, std::make_unique<WinMtfLineStyle>(aColorRef, nStyle, nWidth)); + CreateObjectIndexed(nIndex, std::make_unique<WinMtfLineStyle>(aColorRef, nPenStyle, nWidth)); } } break; diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 7f067e4fcd15..5b82c54daa21 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -791,12 +791,12 @@ namespace emfio break; case StockObject::WHITE_PEN : { - maLineStyle = WinMtfLineStyle( COL_WHITE ); + maLineStyle = WinMtfLineStyle(COL_WHITE, PS_COSMETIC, 0); } break; case StockObject::BLACK_PEN : { - maLineStyle = WinMtfLineStyle( COL_BLACK ); + maLineStyle = WinMtfLineStyle(COL_BLACK, PS_COSMETIC, 0); } break; case StockObject::NULL_PEN :