/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include using namespace css; class WmfTest : public test::BootstrapFixture, public XmlTestTools { OUString maDataUrl; OUString getFullUrl(const OUString& sFileName) { return getURLFromSrc(maDataUrl) + sFileName; } public: WmfTest() : BootstrapFixture(true, false), maDataUrl("/vcl/qa/cppunit/wmf/data/") {} void testNonPlaceableWmf(); void testSine(); void testEmfProblem(); CPPUNIT_TEST_SUITE(WmfTest); CPPUNIT_TEST(testNonPlaceableWmf); CPPUNIT_TEST(testSine); CPPUNIT_TEST(testEmfProblem); CPPUNIT_TEST_SUITE_END(); }; void WmfTest::testNonPlaceableWmf() { SvFileStream aFileStream(getFullUrl("visio_import_source.wmf"), STREAM_READ); GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); SvMemoryStream aStream; MetafileXmlDump dumper(aStream); dumper.filterAllActionTypes(); dumper.filterActionType(META_POLYLINE_ACTION, false); dumper.dump(aGDIMetaFile); aStream.Seek(STREAM_SEEK_TO_BEGIN); xmlDocPtr pDoc = parseXmlStream(&aStream); CPPUNIT_ASSERT (pDoc); assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "x", "16798"); assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "y", "1003"); assertXPath(pDoc, "/metafile/polyline[1]/point[2]", "x", "16798"); assertXPath(pDoc, "/metafile/polyline[1]/point[2]", "y", "7507"); assertXPath(pDoc, "/metafile/polyline[1]/point[3]", "x", "26090"); assertXPath(pDoc, "/metafile/polyline[1]/point[3]", "y", "7507"); assertXPath(pDoc, "/metafile/polyline[1]/point[4]", "x", "26090"); assertXPath(pDoc, "/metafile/polyline[1]/point[4]", "y", "1003"); assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "x", "16798"); assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "y", "1003"); } void WmfTest::testSine() { SvFileStream aFileStream(getFullUrl("sine_wave.emf"), STREAM_READ); GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); SvMemoryStream aStream; MetafileXmlDump dumper(aStream); dumper.filterAllActionTypes(); dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false); dumper.dump(aGDIMetaFile); aStream.Seek(STREAM_SEEK_TO_BEGIN); xmlDocPtr pDoc = parseXmlStream(&aStream); CPPUNIT_ASSERT (pDoc); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "0"); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "0"); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "1155947"); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1155378"); assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "top", "1411"); assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "left", "2962"); assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "bottom", "16651"); assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "right", "20698"); } void WmfTest::testEmfProblem() { SvFileStream aFileStream(getFullUrl("computer_mail.emf"), STREAM_READ); GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); SvMemoryStream aStream; MetafileXmlDump dumper(aStream); dumper.filterAllActionTypes(); dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false); dumper.dump(aGDIMetaFile); aStream.Seek(STREAM_SEEK_TO_BEGIN); xmlDocPtr pDoc = parseXmlStream(&aStream); CPPUNIT_ASSERT (pDoc); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "427"); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "740"); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "2823"); assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876"); } CPPUNIT_TEST_SUITE_REGISTRATION(WmfTest); CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */