emfio/inc/mtftools.hxx | 6 +-- emfio/qa/cppunit/emf/EmfImportTest.cxx | 51 ++++++++++++++------------------- emfio/source/reader/emfreader.cxx | 16 +++++----- emfio/source/reader/mtftools.cxx | 4 +- 4 files changed, 35 insertions(+), 42 deletions(-)
New commits: commit b33cc5a7388c1739ff4a02a84751800f3e3086ce Author: Bartosz Kosiorek <[email protected]> AuthorDate: Wed Sep 10 22:27:37 2025 +0200 Commit: Bartosz Kosiorek <[email protected]> CommitDate: Fri Sep 12 00:46:24 2025 +0200 tdf#159306 WMF/EMF Fix PS_COSMETIC lines display Change-Id: I3a2572a76aae61bcf8552e4623168cd72411373a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190816 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <[email protected]> diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 91a7a461f84f..2230801ff288 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -204,6 +204,8 @@ namespace emfio enum PenStyle : sal_uInt32 { PS_COSMETIC = 0x00000000, + PS_GEOMETRIC = 0x00010000, + PS_SOLID = 0x00000000, PS_DASH = 0x00000001, PS_DOT = 0x00000002, @@ -223,9 +225,7 @@ namespace emfio PS_JOIN_ROUND = 0x00000000, PS_JOIN_BEVEL = 0x00001000, PS_JOIN_MITER = 0x00002000, - PS_JOIN_STYLE_MASK = 0x0000F000, - - PS_GEOMETRIC = 0x00010000 + PS_JOIN_STYLE_MASK = 0x0000F000 }; /* [MS-WMF] - v20210625 - pages 30, 82 */ diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 37c42d4c2126..a59c95c1d8f9 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -87,19 +87,19 @@ CPPUNIT_TEST_FIXTURE(Test, testPolyPolygon) assertXPath(pDocument, aXPathPrefix + "mask/polypolygoncolor[2]/polypolygon", "path", u"m2574 13194v-12065h15303v12065z"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 44); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 116); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - u"2574,13194 2574,1129"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", u"#000000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", u"0"); + u"2574,13194 2574,1129 17877,1129 17877,13194"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", u"#ffffff"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", u"35"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", - u"2574,1129 2574,1129"); + u"2574,13194 2574,1129"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", u"#000000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", u"0"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", u"35"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[10]/polygon", - u"8674,1129 8674,1129"); + u"8674,13194 8674,1129"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "color", u"#000000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "width", u"0"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[10]/line", "width", u"35"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 28); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[6]", "width", u"459"); @@ -556,14 +556,13 @@ CPPUNIT_TEST_FIXTURE(Test, testEnglishMapMode) assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[1]", "width", u"424"); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[1]", "height", u"424"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline", 3); + assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline", 5); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[1]/polygon", u"-1,-1 29699,-1 29699,21000 -1,21000"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[2]/polygon", u"1058,7937 1058,13230 4233,13230 4233,12171 2115,12171 2115,7937"); - assertXPathContent( - pDocument, aXPathPrefix + "mask/polygonhairline[3]/polygon", - u"12699,1058 16933,1058 16933,2118 15346,2118 15346,6349 14287,6349 14287,2118 12699,2118"); + assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[3]/polygon", + u"1058,7937 1058,13230 4233,13230 4233,12171 2115,12171 2115,7937"); } CPPUNIT_TEST_FIXTURE(Test, testRectangleWithModifyWorldTransform) @@ -910,7 +909,7 @@ CPPUNIT_TEST_FIXTURE(Test, testEmfPolydraw) assertXPathContent(pDocument, aXPathPrefix + "polygonstroke[1]/polygon", u"50,50 50,50 1000,1000 1000,1000 2000,2500 2000,1000"); assertXPath(pDocument, aXPathPrefix + "polygonstroke[1]/line", "color", u"#ff0000"); - assertXPath(pDocument, aXPathPrefix + "polygonstroke[1]/stroke", "dotDashArray", u"30 10 "); + assertXPath(pDocument, aXPathPrefix + "polygonstroke[1]/stroke", "dotDashArray", u"90 30 "); } CPPUNIT_TEST_FIXTURE(Test, testEmfPlusBrushPathGradientWithBlendColors) @@ -1588,29 +1587,23 @@ CPPUNIT_TEST_FIXTURE(Test, testCreatePen) assertXPath(pDocument, aXPathPrefix + "mask/polypolygon", "path", u"m0 0h31250v18192h-31250z"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 3); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke", 758); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[1]/polygon", - u"17898,5693 20172,5693"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", u"#008000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", u"0"); + u"0,0 31225,0 31225,17742 0,17742"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "color", u"#ffffff"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[1]/line", "width", u"25"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[2]/polygon", - u"17898,6959 20172,6959"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", u"#000080"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", u"0"); + u"25,23 31200,23 31200,17719 25,17719"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "color", u"#ffffff"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[2]/line", "width", u"25"); assertXPathContent(pDocument, aXPathPrefix + "mask/polygonstroke[3]/polygon", - u"17898,7381 20172,7381"); + u"27875,16523 27875,1453"); assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[3]/line", "color", u"#ff0000"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[3]/line", "width", u"0"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonstroke[3]/line", "width", u"3"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline", 755); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline[5]", "color", u"#ff0000"); - assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[5]/polygon", - u"27925,16078 27875,16078"); - assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline[10]", "color", u"#ff0000"); - assertXPathContent(pDocument, aXPathPrefix + "mask/polygonhairline[10]/polygon", - u"27925,14180 27875,14180"); + assertXPath(pDocument, aXPathPrefix + "mask/polygonhairline", 0); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion", 69); assertXPath(pDocument, aXPathPrefix + "mask/textsimpleportion[1]", "width", u"374"); diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 9ecfe1a411d9..abd842e417da 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1258,10 +1258,10 @@ namespace emfio SAL_INFO("emfio", " Index: " << nIndex << " Style: 0x" << std::hex << nPenStyle << std::dec << " PenWidth: " << nPenWidth); - if ((nPenStyle & PS_STYLE_MASK) > PS_INSIDEFRAME) - nPenStyle = PS_COSMETIC; - if ((nPenStyle & PS_GEOMETRIC) == 0) - nPenWidth = 0; + // PS_COSMETIC width is always fixed at one logical unit + // and is not affected by any geometric transformations like scaling + if (nPenStyle == PS_COSMETIC) + nPenWidth = 1; CreateObjectIndexed(nIndex, std::make_unique<WinMtfLineStyle>(ReadColor(), nPenStyle, nPenWidth)); } } @@ -1284,10 +1284,10 @@ namespace emfio else { SAL_INFO("emfio", " Style: 0x" << std::hex << nPenStyle << std::dec); - if ((nPenStyle & PS_STYLE_MASK) > PS_INSIDEFRAME) - nPenStyle = PS_COSMETIC; - if ((nPenStyle & PS_GEOMETRIC) == 0) - nWidth = 0; + // PS_COSMETIC width is always fixed at one logical unit + // and is not affected by any geometric transformations like scaling + if (nPenStyle == PS_COSMETIC) + nWidth = 1; SAL_INFO("emfio", " Width: " << nWidth); CreateObjectIndexed(nIndex, std::make_unique<WinMtfLineStyle>(aColorRef, nPenStyle, nWidth)); } diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index f5467f88c923..b57c528b67f9 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -803,12 +803,12 @@ namespace emfio break; case StockObject::WHITE_PEN : { - maLineStyle = WinMtfLineStyle(COL_WHITE, PS_COSMETIC, 0); + maLineStyle = WinMtfLineStyle(COL_WHITE, PS_COSMETIC, 1); } break; case StockObject::BLACK_PEN : { - maLineStyle = WinMtfLineStyle(COL_BLACK, PS_COSMETIC, 0); + maLineStyle = WinMtfLineStyle(COL_BLACK, PS_COSMETIC, 1); } break; case StockObject::NULL_PEN :
