1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <string_view>
24 #include <test/xmltesttools.hxx>
25 #include <test/bootstrapfixture.hxx>
26 #include <vcl/gdimtf.hxx>
27 #include <vcl/wmf.hxx>
28 #include <mtftools.hxx>
32 class WmfTest
: public test::BootstrapFixture
, public XmlTestTools
36 OUString
getFullUrl(std::u16string_view sFileName
)
38 return m_directories
.getURLFromSrc(maDataUrl
) + sFileName
;
43 : BootstrapFixture(true, false)
44 , maDataUrl(u
"/emfio/qa/cppunit/wmf/data/"_ustr
)
49 void testNonPlaceableWmf();
50 void testTdf88163NonPlaceableWmf();
51 void testTdf88163PlaceableWmf();
52 void testSetTextAlignWmf();
54 void testEmfProblem();
55 void testEmfLineStyles();
56 void testWorldTransformFontSize();
60 void testTdf39894Wmf();
61 void testTdf39894Emf();
62 void testETO_PDYWmf();
63 void testETO_PDYEmf();
64 void testStockObject();
66 CPPUNIT_TEST_SUITE(WmfTest
);
67 CPPUNIT_TEST(testEOFWmf
);
68 CPPUNIT_TEST(testNonPlaceableWmf
);
69 CPPUNIT_TEST(testTdf88163NonPlaceableWmf
);
70 CPPUNIT_TEST(testTdf88163PlaceableWmf
);
71 CPPUNIT_TEST(testSetTextAlignWmf
);
72 CPPUNIT_TEST(testSine
);
73 CPPUNIT_TEST(testEmfProblem
);
74 CPPUNIT_TEST(testEmfLineStyles
);
75 CPPUNIT_TEST(testWorldTransformFontSize
);
76 CPPUNIT_TEST(testBigPPI
);
77 CPPUNIT_TEST(testTdf93750
);
78 CPPUNIT_TEST(testTdf99402
);
79 CPPUNIT_TEST(testTdf39894Wmf
);
80 CPPUNIT_TEST(testTdf39894Emf
);
81 CPPUNIT_TEST(testETO_PDYWmf
);
82 CPPUNIT_TEST(testETO_PDYEmf
);
83 CPPUNIT_TEST(testStockObject
);
84 CPPUNIT_TEST_SUITE_END();
87 void WmfTest::testEOFWmf()
89 // tdf#155887 Test META_EOF with size different than 3
90 // It should be properly displayed as MS Office do
91 SvFileStream
aFileStream(getFullUrl(u
"EOF.wmf"), StreamMode::READ
);
92 GDIMetaFile aGDIMetaFile
;
93 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
95 MetafileXmlDump dumper
;
96 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
99 assertXPath(pDoc
, "/metafile/push", 2);
100 assertXPath(pDoc
, "/metafile/push[2]", "flags", u
"PushClipRegion");
101 assertXPath(pDoc
, "/metafile/push[2]/fillcolor", 2);
102 assertXPath(pDoc
, "/metafile/push[2]/fillcolor[1]", "color", u
"#000000");
103 assertXPath(pDoc
, "/metafile/push[2]/fillcolor[2]", "color", u
"#d0d0d0");
104 assertXPath(pDoc
, "/metafile/push[2]/linecolor", 60);
105 assertXPath(pDoc
, "/metafile/push[2]/polyline", 209);
106 assertXPath(pDoc
, "/metafile/push[2]/polyline[1]/point", 5);
107 assertXPath(pDoc
, "/metafile/push[2]/polyline[1]/point[3]", "x", u
"16906");
108 assertXPath(pDoc
, "/metafile/push[2]/polyline[1]/point[3]", "y", u
"12673");
109 assertXPath(pDoc
, "/metafile/push[2]/textarray", 307);
112 void WmfTest::testNonPlaceableWmf()
114 SvFileStream
aFileStream(getFullUrl(u
"visio_import_source.wmf"), StreamMode::READ
);
115 GDIMetaFile aGDIMetaFile
;
116 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
118 MetafileXmlDump dumper
;
119 dumper
.filterAllActionTypes();
120 dumper
.filterActionType(MetaActionType::POLYLINE
, false);
122 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
124 CPPUNIT_ASSERT(pDoc
);
126 // These values come from changes done in tdf#88163
127 assertXPath(pDoc
, "/metafile/polyline[1]/point[1]", "x", u
"16813");
128 assertXPath(pDoc
, "/metafile/polyline[1]/point[1]", "y", u
"1004");
130 assertXPath(pDoc
, "/metafile/polyline[1]/point[2]", "x", u
"16813");
131 assertXPath(pDoc
, "/metafile/polyline[1]/point[2]", "y", u
"7514");
133 assertXPath(pDoc
, "/metafile/polyline[1]/point[3]", "x", u
"26112");
134 assertXPath(pDoc
, "/metafile/polyline[1]/point[3]", "y", u
"7514");
136 assertXPath(pDoc
, "/metafile/polyline[1]/point[4]", "x", u
"26112");
137 assertXPath(pDoc
, "/metafile/polyline[1]/point[4]", "y", u
"1004");
139 assertXPath(pDoc
, "/metafile/polyline[1]/point[5]", "x", u
"16813");
140 assertXPath(pDoc
, "/metafile/polyline[1]/point[5]", "y", u
"1004");
143 void WmfTest::testTdf88163NonPlaceableWmf()
145 OUString
fileName(u
"tdf88163-non-placeable.wmf"_ustr
);
146 SvFileStream
aFileStream(getFullUrl(fileName
), StreamMode::READ
);
147 GDIMetaFile aGDIMetaFile
;
148 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
150 MetafileXmlDump dumper
;
151 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
153 CPPUNIT_ASSERT(pDoc
);
155 // These values come from the fix for tdf#88163
157 // Fails without the fix
158 // With fix: 3272, without fix: ~ 8000
159 auto x
= getXPath(pDoc
, "/metafile/push[2]/font[1]", "height");
160 CPPUNIT_ASSERT_EQUAL(sal_Int32(3272), x
.toInt32());
162 // Fails without the fix: Expected: 7359, Actual: 7336
163 assertXPath(pDoc
, "/metafile/push[2]/textarray[1]", "x", u
"7359");
164 // Fails without the fix: Expected: 4118, Actual: 4104
165 assertXPath(pDoc
, "/metafile/push[2]/textarray[1]", "y", u
"4118");
167 // Fails without the fix: Expected: 5989, Actual: 5971
168 assertXPath(pDoc
, "/metafile/push[2]/textarray[2]", "x", u
"5989");
169 // Fails without the fix: Expected: 16264, Actual: 16208
170 assertXPath(pDoc
, "/metafile/push[2]/textarray[2]", "y", u
"16264");
172 // Fails without the fix: Expected: 20769, Actual: 20705
173 assertXPath(pDoc
, "/metafile/push[2]/textarray[3]", "x", u
"20769");
174 // Fails without the fix: Expected: 4077, Actual: 4062
175 assertXPath(pDoc
, "/metafile/push[2]/textarray[3]", "y", u
"4077");
178 void WmfTest::testTdf88163PlaceableWmf()
180 OUString
fileName(u
"tdf88163-wrong-font-size.wmf"_ustr
);
181 SvFileStream
aFileStream(getFullUrl(fileName
), StreamMode::READ
);
182 GDIMetaFile aGDIMetaFile
;
183 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
185 MetafileXmlDump dumper
;
187 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
189 CPPUNIT_ASSERT(pDoc
);
191 // These values come from the fix for tdf#88163
193 // The fix does not affect the font size
194 auto x
= getXPath(pDoc
, "/metafile/push[2]/font[1]", "height");
195 CPPUNIT_ASSERT_EQUAL(sal_Int32(313), x
.toInt32());
197 // Fails without the fix: Expected: 1900, Actual: 19818
198 assertXPath(pDoc
, "/metafile", "height", u
"1900");
200 // Fails without the fix: Expected: 704, Actual: 7336
201 assertXPath(pDoc
, "/metafile/push[2]/textarray[1]", "x", u
"704");
202 // Fails without the fix: Expected: 394, Actual: 4110
203 assertXPath(pDoc
, "/metafile/push[2]/textarray[1]", "y", u
"394");
205 // Fails without the fix: Expected: 573, Actual: 5971
206 assertXPath(pDoc
, "/metafile/push[2]/textarray[2]", "x", u
"573");
207 // Fails without the fix: Expected: 1556, Actual: 16230
208 assertXPath(pDoc
, "/metafile/push[2]/textarray[2]", "y", u
"1556");
210 // Fails without the fix: Expected: 1987, Actual: 20706
211 assertXPath(pDoc
, "/metafile/push[2]/textarray[3]", "x", u
"1987");
212 // Fails without the fix: Expected: 390, Actual: 4068
213 assertXPath(pDoc
, "/metafile/push[2]/textarray[3]", "y", u
"390");
216 void WmfTest::testSetTextAlignWmf()
218 OUString
fileName(u
"TestSetTextAlign.wmf"_ustr
);
219 SvFileStream
aFileStream(getFullUrl(fileName
), StreamMode::READ
);
220 GDIMetaFile aGDIMetaFile
;
221 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
223 MetafileXmlDump dumper
;
225 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
227 CPPUNIT_ASSERT(pDoc
);
229 assertXPath(pDoc
, "/metafile", "height", u
"20999");
231 assertXPath(pDoc
, "/metafile/push[2]/textalign[2]", "align", u
"top");
232 assertXPath(pDoc
, "/metafile/push[2]/textarray[2]", "x", u
"11642");
233 assertXPath(pDoc
, "/metafile/push[2]/textarray[2]", "y", u
"212");
234 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[2]/text", u
"textalignment:default");
236 assertXPath(pDoc
, "/metafile/push[2]/textalign[3]", "align", u
"top");
237 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[3]", "x", 12700, 30);
238 assertXPath(pDoc
, "/metafile/push[2]/textarray[3]", "y", u
"212");
239 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[3]/text", u
"textalignment:0x00");
241 assertXPath(pDoc
, "/metafile/push[2]/textalign[4]", "align", u
"top");
242 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[4]", "x", 12026, 30);
243 assertXPath(pDoc
, "/metafile/push[2]/textarray[4]", "y", u
"423");
244 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[4]/text", u
"textalignment:0x02");
246 assertXPath(pDoc
, "/metafile/push[2]/textalign[5]", "align", u
"top");
247 // Fails without the fix: Expected: 12026, Actual: 12350
248 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[5]", "x", 12026, 30);
249 assertXPath(pDoc
, "/metafile/push[2]/textarray[5]", "y", u
"635");
250 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[5]/text", u
"textalignment:0x04");
252 assertXPath(pDoc
, "/metafile/push[2]/textalign[6]", "align", u
"top");
253 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[6]", "x", 12363, 30);
254 assertXPath(pDoc
, "/metafile/push[2]/textarray[6]", "y", u
"847");
255 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[6]/text", u
"textalignment:0x06");
257 assertXPath(pDoc
, "/metafile/push[2]/textalign[7]", "align", u
"top");
258 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[7]", "x", 12700, 30);
259 assertXPath(pDoc
, "/metafile/push[2]/textarray[7]", "y", u
"1058");
260 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[7]/text", u
"textalignment:0x08");
262 assertXPath(pDoc
, "/metafile/push[2]/textalign[8]", "align", u
"top");
263 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[8]", "x", 12026, 30);
264 assertXPath(pDoc
, "/metafile/push[2]/textarray[8]", "y", u
"1270");
265 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[8]/text", u
"textalignment:0x0A");
267 assertXPath(pDoc
, "/metafile/push[2]/textalign[9]", "align", u
"bottom");
268 // Fails without the fix: Expected: 12026, Actual: 12350
269 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[9]", "x", 12026, 30);
270 assertXPath(pDoc
, "/metafile/push[2]/textarray[9]", "y", u
"1482");
271 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[9]/text", u
"textalignment:0x0C");
273 assertXPath(pDoc
, "/metafile/push[2]/textalign[10]", "align", u
"bottom");
274 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[10]", "x", 12363, 30);
275 assertXPath(pDoc
, "/metafile/push[2]/textarray[10]", "y", u
"1693");
276 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[10]/text", u
"textalignment:0x0E");
278 assertXPath(pDoc
, "/metafile/push[2]/textalign[11]", "align", u
"bottom");
279 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[11]", "x", 12700, 30);
280 assertXPath(pDoc
, "/metafile/push[2]/textarray[11]", "y", u
"1905");
281 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[11]/text", u
"textalignment:0x10");
283 assertXPath(pDoc
, "/metafile/push[2]/textalign[12]", "align", u
"bottom");
284 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[12]", "x", 12026, 30);
285 assertXPath(pDoc
, "/metafile/push[2]/textarray[12]", "y", u
"2117");
286 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[12]/text", u
"textalignment:0x12");
288 assertXPath(pDoc
, "/metafile/push[2]/textalign[13]", "align", u
"bottom");
289 // Fails without the fix: Expected: 12026, Actual: 12350
290 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[13]", "x", 12026, 30);
291 assertXPath(pDoc
, "/metafile/push[2]/textarray[13]", "y", u
"2328");
292 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[13]/text", u
"textalignment:0x14");
294 assertXPath(pDoc
, "/metafile/push[2]/textalign[14]", "align", u
"bottom");
295 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[14]", "x", 12363, 30);
296 assertXPath(pDoc
, "/metafile/push[2]/textarray[14]", "y", u
"2540");
297 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[14]/text", u
"textalignment:0x16");
299 assertXPath(pDoc
, "/metafile/push[2]/textalign[15]", "align", u
"bottom");
300 assertXPathDoubleValue(pDoc
, "/metafile/push[2]/textarray[15]", "x", 12700, 30);
301 assertXPath(pDoc
, "/metafile/push[2]/textarray[15]", "y", u
"2752");
302 assertXPathContent(pDoc
, "/metafile/push[2]/textarray[15]/text", u
"textalignment:0x18");
305 void WmfTest::testSine()
307 SvFileStream
aFileStream(getFullUrl(u
"sine_wave.emf"), StreamMode::READ
);
308 GDIMetaFile aGDIMetaFile
;
309 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
311 MetafileXmlDump dumper
;
312 dumper
.filterAllActionTypes();
313 dumper
.filterActionType(MetaActionType::ISECTRECTCLIPREGION
, false);
314 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
316 CPPUNIT_ASSERT(pDoc
);
318 assertXPath(pDoc
, "/metafile/sectrectclipregion", 0);
321 void WmfTest::testEmfProblem()
323 SvFileStream
aFileStream(getFullUrl(u
"computer_mail.emf"), StreamMode::READ
);
324 GDIMetaFile aGDIMetaFile
;
325 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
327 MetafileXmlDump dumper
;
328 dumper
.filterAllActionTypes();
329 dumper
.filterActionType(MetaActionType::ISECTRECTCLIPREGION
, false);
330 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
332 CPPUNIT_ASSERT(pDoc
);
334 assertXPath(pDoc
, "/metafile/sectrectclipregion", 2);
335 assertXPath(pDoc
, "/metafile/sectrectclipregion[1]", "top", u
"2125");
336 assertXPath(pDoc
, "/metafile/sectrectclipregion[1]", "left", u
"1084");
337 assertXPath(pDoc
, "/metafile/sectrectclipregion[1]", "bottom", u
"2927");
338 assertXPath(pDoc
, "/metafile/sectrectclipregion[1]", "right", u
"2376");
341 void WmfTest::testEmfLineStyles()
343 SvFileStream
aFileStream(getFullUrl(u
"line_styles.emf"), StreamMode::READ
);
344 GDIMetaFile aGDIMetaFile
;
345 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
347 MetafileXmlDump dumper
;
348 dumper
.filterAllActionTypes();
349 dumper
.filterActionType(MetaActionType::LINE
, false);
350 dumper
.filterActionType(MetaActionType::LINECOLOR
, false);
351 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
353 CPPUNIT_ASSERT(pDoc
);
355 assertXPath(pDoc
, "/metafile/line", 4);
356 assertXPath(pDoc
, "/metafile/linecolor", 5);
358 assertXPath(pDoc
, "/metafile/linecolor[1]", "color", u
"#ffffff");
359 assertXPath(pDoc
, "/metafile/linecolor[2]", "color", u
"#00ff00");
360 assertXPath(pDoc
, "/metafile/linecolor[3]", "color", u
"#408080");
361 assertXPath(pDoc
, "/metafile/linecolor[4]", "color", u
"#ff0000");
362 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#0000ff");
364 assertXPath(pDoc
, "/metafile/line[1]", "style", u
"dash");
365 assertXPath(pDoc
, "/metafile/line[1]", "dashlen", u
"528");
366 assertXPath(pDoc
, "/metafile/line[1]", "dashcount", u
"1");
367 assertXPath(pDoc
, "/metafile/line[1]", "dotlen", u
"176");
368 assertXPath(pDoc
, "/metafile/line[1]", "dotcount", u
"0");
369 assertXPath(pDoc
, "/metafile/line[1]", "distance", u
"176");
370 assertXPath(pDoc
, "/metafile/line[1]", "join", u
"miter");
371 assertXPath(pDoc
, "/metafile/line[1]", "cap", u
"butt");
373 assertXPath(pDoc
, "/metafile/line[2]", "style", u
"dash");
374 assertXPath(pDoc
, "/metafile/line[2]", "dashlen", u
"528");
375 assertXPath(pDoc
, "/metafile/line[2]", "dashcount", u
"0");
376 assertXPath(pDoc
, "/metafile/line[2]", "dotlen", u
"176");
377 assertXPath(pDoc
, "/metafile/line[2]", "dotcount", u
"1");
378 assertXPath(pDoc
, "/metafile/line[2]", "distance", u
"176");
379 assertXPath(pDoc
, "/metafile/line[2]", "join", u
"miter");
380 assertXPath(pDoc
, "/metafile/line[2]", "cap", u
"butt");
382 assertXPath(pDoc
, "/metafile/line[3]", "style", u
"dash");
383 assertXPath(pDoc
, "/metafile/line[3]", "dashlen", u
"528");
384 assertXPath(pDoc
, "/metafile/line[3]", "dashcount", u
"1");
385 assertXPath(pDoc
, "/metafile/line[3]", "dotlen", u
"176");
386 assertXPath(pDoc
, "/metafile/line[3]", "dotcount", u
"1");
387 assertXPath(pDoc
, "/metafile/line[3]", "distance", u
"176");
388 assertXPath(pDoc
, "/metafile/line[3]", "join", u
"miter");
389 assertXPath(pDoc
, "/metafile/line[3]", "cap", u
"butt");
391 assertXPath(pDoc
, "/metafile/line[4]", "style", u
"dash");
392 assertXPath(pDoc
, "/metafile/line[4]", "dashlen", u
"528");
393 assertXPath(pDoc
, "/metafile/line[4]", "dashcount", u
"1");
394 assertXPath(pDoc
, "/metafile/line[4]", "dotlen", u
"176");
395 assertXPath(pDoc
, "/metafile/line[4]", "dotcount", u
"2");
396 assertXPath(pDoc
, "/metafile/line[4]", "distance", u
"176");
397 assertXPath(pDoc
, "/metafile/line[4]", "join", u
"miter");
398 assertXPath(pDoc
, "/metafile/line[4]", "cap", u
"butt");
401 void WmfTest::testWorldTransformFontSize()
403 SvFileStream
aFileStream(getFullUrl(u
"image1.emf"), StreamMode::READ
);
404 GDIMetaFile aGDIMetaFile
;
405 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
407 MetafileXmlDump dumper
;
408 dumper
.filterAllActionTypes();
409 dumper
.filterActionType(MetaActionType::FONT
, false);
410 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
412 CPPUNIT_ASSERT(pDoc
);
414 assertXPath(pDoc
, "/metafile/font", 9);
416 assertXPath(pDoc
, "/metafile/font[1]", "color", u
"#595959");
417 assertXPath(pDoc
, "/metafile/font[1]", "width", u
"0");
418 assertXPath(pDoc
, "/metafile/font[1]", "height", u
"389");
419 assertXPath(pDoc
, "/metafile/font[1]", "orientation", u
"0");
420 assertXPath(pDoc
, "/metafile/font[1]", "weight", u
"bold");
422 assertXPath(pDoc
, "/metafile/font[3]", "color", u
"#000000");
423 assertXPath(pDoc
, "/metafile/font[3]", "width", u
"0");
424 assertXPath(pDoc
, "/metafile/font[3]", "height", u
"389");
425 assertXPath(pDoc
, "/metafile/font[3]", "orientation", u
"0");
426 assertXPath(pDoc
, "/metafile/font[3]", "weight", u
"bold");
428 // World transform should not affect font size. Rotating text for 90 degrees
429 // should not exchange font width and height.
430 assertXPath(pDoc
, "/metafile/font[4]", "color", u
"#000000");
431 assertXPath(pDoc
, "/metafile/font[4]", "width", u
"0");
432 assertXPath(pDoc
, "/metafile/font[4]", "height", u
"530");
433 assertXPath(pDoc
, "/metafile/font[4]", "orientation", u
"900");
434 assertXPath(pDoc
, "/metafile/font[4]", "weight", u
"normal");
437 void WmfTest::testBigPPI()
439 // Test that PPI is reduced from 2540 to 96 (width from META_SETWINDOWEXT) to make the graphic
441 SvFileStream
aFileStream(getFullUrl(u
"TestBigPPI.wmf"), StreamMode::READ
);
442 GDIMetaFile aGDIMetaFile
;
443 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
445 MetafileXmlDump dumper
;
446 dumper
.filterAllActionTypes();
447 dumper
.filterActionType(MetaActionType::FONT
, false);
448 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
450 CPPUNIT_ASSERT(pDoc
);
452 // If the PPI was not reduced the width and height would be <100 which is too small
453 // Related: tdf#150888
454 assertXPath(pDoc
, "/metafile", "width", u
"2540");
455 assertXPath(pDoc
, "/metafile", "height", u
"2143");
458 void WmfTest::testTdf93750()
460 SvFileStream
aFileStream(getFullUrl(u
"tdf93750.emf"), StreamMode::READ
);
461 GDIMetaFile aGDIMetaFile
;
462 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
464 MetafileXmlDump dumper
;
465 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
467 CPPUNIT_ASSERT(pDoc
);
469 assertXPath(pDoc
, "/metafile/push[1]/comment[2]", "datasize", u
"28");
470 assertXPath(pDoc
, "/metafile/push[1]/comment[3]", "datasize", u
"72");
473 void WmfTest::testTdf99402()
475 // Symbol font should arrive with RTL_TEXTENCODING_SYMBOL encoding,
476 // even if charset is OEM_CHARSET/DEFAULT_CHARSET in WMF
477 emfio::LOGFONTW logfontw
;
478 logfontw
.lfHeight
= 0;
479 logfontw
.lfWidth
= 0;
480 logfontw
.lfEscapement
= 0;
481 logfontw
.lfWeight
= 0;
482 logfontw
.lfItalic
= 0;
483 logfontw
.lfUnderline
= 0;
484 logfontw
.lfStrikeOut
= 0;
485 logfontw
.lfCharSet
= emfio::CharacterSet::OEM_CHARSET
;
486 logfontw
.lfPitchAndFamily
= emfio::FamilyFont::FF_ROMAN
<< 4 | emfio::PitchFont::DEFAULT_PITCH
;
487 logfontw
.alfFaceName
= "Symbol";
489 emfio::WinMtfFontStyle
fontStyle(logfontw
);
491 CPPUNIT_ASSERT_EQUAL(RTL_TEXTENCODING_SYMBOL
, fontStyle
.aFont
.GetCharSet());
494 void WmfTest::testTdf39894Wmf()
496 SvFileStream
aFileStream(getFullUrl(u
"tdf39894.wmf"), StreamMode::READ
);
497 GDIMetaFile aGDIMetaFile
;
498 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
500 MetafileXmlDump dumper
;
501 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
503 CPPUNIT_ASSERT(pDoc
);
505 // The x position of the second text must take into account
506 // the previous text's last Dx (previously was ~300)
507 auto x
= getXPath(pDoc
, "/metafile/push[2]/textarray[2]", "x");
508 CPPUNIT_ASSERT_GREATER(sal_Int32(2700), x
.toInt32());
511 void WmfTest::testTdf39894Emf()
513 SvFileStream
aFileStream(getFullUrl(u
"tdf39894.emf"), StreamMode::READ
);
514 GDIMetaFile aGDIMetaFile
;
515 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
517 MetafileXmlDump dumper
;
518 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
520 CPPUNIT_ASSERT(pDoc
);
522 // The x position of the second text must take into account
523 // the previous text's last Dx (previously was ~300)
524 auto x
= getXPath(pDoc
, "/metafile/push[2]/textarray[2]", "x");
525 CPPUNIT_ASSERT_GREATER(sal_Int32(2700), x
.toInt32());
528 void WmfTest::testETO_PDYWmf()
530 SvFileStream
aFileStream(getFullUrl(u
"ETO_PDY.wmf"), StreamMode::READ
);
531 GDIMetaFile aGDIMetaFile
;
532 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
534 MetafileXmlDump dumper
;
535 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
537 CPPUNIT_ASSERT(pDoc
);
539 // The y position of following text
540 // must be smaller than that of previous
541 auto y1
= getXPath(pDoc
, "/metafile/push[2]/textarray[1]", "y");
542 auto y2
= getXPath(pDoc
, "/metafile/push[2]/textarray[2]", "y");
543 auto y3
= getXPath(pDoc
, "/metafile/push[2]/textarray[3]", "y");
544 CPPUNIT_ASSERT(y2
.toInt32() < y1
.toInt32());
545 CPPUNIT_ASSERT(y3
.toInt32() < y2
.toInt32());
548 void WmfTest::testETO_PDYEmf()
550 SvFileStream
aFileStream(getFullUrl(u
"ETO_PDY.emf"), StreamMode::READ
);
551 GDIMetaFile aGDIMetaFile
;
552 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
554 MetafileXmlDump dumper
;
555 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
557 CPPUNIT_ASSERT(pDoc
);
559 // The y position of following text
560 // must be smaller than that of previous
561 auto y1
= getXPath(pDoc
, "/metafile/push[2]/textarray[1]", "y");
562 auto y2
= getXPath(pDoc
, "/metafile/push[2]/textarray[2]", "y");
563 auto y3
= getXPath(pDoc
, "/metafile/push[2]/textarray[3]", "y");
564 CPPUNIT_ASSERT(y2
.toInt32() < y1
.toInt32());
565 CPPUNIT_ASSERT(y3
.toInt32() < y2
.toInt32());
568 void WmfTest::testStockObject()
570 SvFileStream
aFileStream(getFullUrl(u
"stockobject.emf"), StreamMode::READ
);
571 GDIMetaFile aGDIMetaFile
;
572 ReadWindowMetafile(aFileStream
, aGDIMetaFile
);
574 MetafileXmlDump dumper
;
575 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, aGDIMetaFile
);
577 CPPUNIT_ASSERT(pDoc
);
579 // Without the fix in place, this test would have failed with
582 // - In <>, XPath '/metafile/push[2]/fillcolor[2]' number of nodes is incorrect
583 assertXPath(pDoc
, "/metafile/push[2]/fillcolor[2]", "color", u
"#000000");
586 CPPUNIT_TEST_SUITE_REGISTRATION(WmfTest
);
588 CPPUNIT_PLUGIN_IMPLEMENT();
590 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */