Bump version to 5.0-14
[LibreOffice.git] / filter / qa / cppunit / filters-pict-test.cxx
blobbdfa9c2134b97b41adf84576b43a10927da8a7e5
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/.
8 */
10 #include <unotest/filters-test.hxx>
11 #include <test/bootstrapfixture.hxx>
12 #include <vcl/FilterConfigItem.hxx>
13 #include <test/mtfxmldump.hxx>
14 #include <test/xmltesttools.hxx>
15 #include <tools/stream.hxx>
16 #include <vcl/graph.hxx>
17 #include <vcl/metaactiontypes.hxx>
19 #include <osl/file.hxx>
20 #include <osl/process.h>
22 #include "../../source/graphicfilter/ipict/ipict.hxx"
24 extern "C"
26 SAL_DLLPUBLIC_EXPORT bool SAL_CALL
27 GraphicImport(SvStream & rStream, Graphic & rGraphic,
28 FilterConfigItem*);
31 using namespace ::com::sun::star;
33 /* Implementation of Filters test */
35 class PictFilterTest
36 : public test::FiltersTest
37 , public test::BootstrapFixture
38 , public XmlTestTools
40 public:
41 PictFilterTest() : BootstrapFixture(true, false) {}
43 virtual bool load(const OUString &,
44 const OUString &rURL, const OUString &,
45 SfxFilterFlags, SotClipboardFormatId, unsigned int) SAL_OVERRIDE;
47 OUString pictURL()
49 return getURLFromSrc("/filter/qa/cppunit/data/pict/");
52 /**
53 * Ensure CVEs remain unbroken
55 void testCVEs();
57 void testDontClipTooMuch();
59 CPPUNIT_TEST_SUITE(PictFilterTest);
60 CPPUNIT_TEST(testCVEs);
61 CPPUNIT_TEST(testDontClipTooMuch);
62 CPPUNIT_TEST_SUITE_END();
65 bool PictFilterTest::load(const OUString &,
66 const OUString &rURL, const OUString &,
67 SfxFilterFlags, SotClipboardFormatId, unsigned int)
69 SvFileStream aFileStream(rURL, StreamMode::READ);
70 Graphic aGraphic;
71 return GraphicImport(aFileStream, aGraphic, NULL);
74 void PictFilterTest::testCVEs()
76 testDir(OUString(),
77 pictURL(),
78 OUString());
81 void PictFilterTest::testDontClipTooMuch()
83 SvFileStream aFileStream(pictURL() + "clipping-problem.pct", StreamMode::READ);
84 GDIMetaFile aGDIMetaFile;
85 pict::ReadPictFile(aFileStream, aGDIMetaFile);
87 MetafileXmlDump dumper;
88 dumper.filterAllActionTypes();
89 dumper.filterActionType(MetaActionType::CLIPREGION, false);
90 xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
92 CPPUNIT_ASSERT (pDoc);
94 assertXPath(pDoc, "/metafile/clipregion[5]", "top", "0");
95 assertXPath(pDoc, "/metafile/clipregion[5]", "left", "0");
96 assertXPath(pDoc, "/metafile/clipregion[5]", "bottom", "-32767");
97 assertXPath(pDoc, "/metafile/clipregion[5]", "right", "-32767");
100 CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest);
102 CPPUNIT_PLUGIN_IMPLEMENT();
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */