bump product version to 5.0.4.1
[LibreOffice.git] / vcl / qa / cppunit / wmf / wmfimporttest.cxx
blob6e595c070c8c3c23b926a77083a6ad19c9743d6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <test/bootstrapfixture.hxx>
21 #include <test/xmltesttools.hxx>
22 #include <test/mtfxmldump.hxx>
23 #include <vcl/wmf.hxx>
24 #include <vcl/metaact.hxx>
26 using namespace css;
28 class WmfTest : public test::BootstrapFixture, public XmlTestTools
30 OUString maDataUrl;
32 OUString getFullUrl(const OUString& sFileName)
34 return getURLFromSrc(maDataUrl) + sFileName;
37 public:
38 WmfTest() :
39 BootstrapFixture(true, false),
40 maDataUrl("/vcl/qa/cppunit/wmf/data/")
43 void testNonPlaceableWmf();
44 void testSine();
45 void testEmfProblem();
46 void testWorldTransformFontSize();
47 void testTdf93750();
49 CPPUNIT_TEST_SUITE(WmfTest);
50 CPPUNIT_TEST(testNonPlaceableWmf);
51 CPPUNIT_TEST(testSine);
52 CPPUNIT_TEST(testEmfProblem);
53 CPPUNIT_TEST(testWorldTransformFontSize);
54 CPPUNIT_TEST(testTdf93750);
56 CPPUNIT_TEST_SUITE_END();
59 void WmfTest::testNonPlaceableWmf()
61 SvFileStream aFileStream(getFullUrl("visio_import_source.wmf"), StreamMode::READ);
62 GDIMetaFile aGDIMetaFile;
63 ReadWindowMetafile(aFileStream, aGDIMetaFile);
65 MetafileXmlDump dumper;
66 dumper.filterAllActionTypes();
67 dumper.filterActionType(MetaActionType::POLYLINE, false);
68 xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
70 CPPUNIT_ASSERT (pDoc);
72 assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "x", "16798");
73 assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "y", "1003");
75 assertXPath(pDoc, "/metafile/polyline[1]/point[2]", "x", "16798");
76 assertXPath(pDoc, "/metafile/polyline[1]/point[2]", "y", "7507");
78 assertXPath(pDoc, "/metafile/polyline[1]/point[3]", "x", "26090");
79 assertXPath(pDoc, "/metafile/polyline[1]/point[3]", "y", "7507");
81 assertXPath(pDoc, "/metafile/polyline[1]/point[4]", "x", "26090");
82 assertXPath(pDoc, "/metafile/polyline[1]/point[4]", "y", "1003");
84 assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "x", "16798");
85 assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "y", "1003");
88 void WmfTest::testSine()
90 SvFileStream aFileStream(getFullUrl("sine_wave.emf"), StreamMode::READ);
91 GDIMetaFile aGDIMetaFile;
92 ReadWindowMetafile(aFileStream, aGDIMetaFile);
94 MetafileXmlDump dumper;
95 dumper.filterAllActionTypes();
96 dumper.filterActionType(MetaActionType::ISECTRECTCLIPREGION, false);
97 xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
99 CPPUNIT_ASSERT (pDoc);
101 assertXPath(pDoc, "/metafile/sectrectclipregion", 0);
104 void WmfTest::testEmfProblem()
106 SvFileStream aFileStream(getFullUrl("computer_mail.emf"), StreamMode::READ);
107 GDIMetaFile aGDIMetaFile;
108 ReadWindowMetafile(aFileStream, aGDIMetaFile);
110 MetafileXmlDump dumper;
111 dumper.filterAllActionTypes();
112 dumper.filterActionType(MetaActionType::ISECTRECTCLIPREGION, false);
113 xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
115 CPPUNIT_ASSERT (pDoc);
117 assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "427");
118 assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "740");
119 assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "2823");
120 assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876");
123 void WmfTest::testWorldTransformFontSize()
125 SvFileStream aFileStream(getFullUrl("image1.emf"), StreamMode::READ);
126 GDIMetaFile aGDIMetaFile;
127 ReadWindowMetafile(aFileStream, aGDIMetaFile);
129 MetafileXmlDump dumper;
130 dumper.filterAllActionTypes();
131 dumper.filterActionType(MetaActionType::FONT, false);
132 xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
134 CPPUNIT_ASSERT (pDoc);
136 assertXPath(pDoc, "/metafile/font", 8);
138 assertXPath(pDoc, "/metafile/font[1]", "color", "#595959");
139 assertXPath(pDoc, "/metafile/font[1]", "width", "0");
140 assertXPath(pDoc, "/metafile/font[1]", "height", "389");
141 assertXPath(pDoc, "/metafile/font[1]", "orientation", "0");
142 assertXPath(pDoc, "/metafile/font[1]", "weight", "bold");
144 // World transform should not affect font size. Rotating text for 90 degrees
145 // should not exchange font width and height.
146 assertXPath(pDoc, "/metafile/font[3]", "color", "#000000");
147 assertXPath(pDoc, "/metafile/font[3]", "width", "0");
148 assertXPath(pDoc, "/metafile/font[3]", "height", "530");
149 assertXPath(pDoc, "/metafile/font[3]", "orientation", "900");
150 assertXPath(pDoc, "/metafile/font[3]", "weight", "normal");
153 void WmfTest::testTdf93750()
155 SvFileStream aFileStream(getFullUrl("tdf93750.emf"), StreamMode::READ);
156 GDIMetaFile aGDIMetaFile;
157 ReadWindowMetafile(aFileStream, aGDIMetaFile);
159 MetafileXmlDump dumper;
160 xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
162 CPPUNIT_ASSERT (pDoc);
164 assertXPath(pDoc, "/metafile/push[1]/comment[2]", "datasize", "28");
165 assertXPath(pDoc, "/metafile/push[1]/comment[3]", "datasize", "72");
168 CPPUNIT_TEST_SUITE_REGISTRATION(WmfTest);
170 CPPUNIT_PLUGIN_IMPLEMENT();
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */