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/.
10 #include <sal/config.h>
11 #include <unotest/filters-test.hxx>
12 #include <test/bootstrapfixture.hxx>
13 #include <com/sun/star/lang/XComponent.hpp>
15 #include <sfx2/docfilt.hxx>
16 #include <sfx2/docfile.hxx>
18 #include <drawdoc.hxx>
19 #include <DrawDocShell.hxx>
21 using namespace ::com::sun::star
;
23 /// Test loading of files to assure they do not crash on load.
25 : public test::FiltersTest
26 , public test::BootstrapFixture
31 virtual bool load( const OUString
&rFilter
,
32 const OUString
&rURL
, const OUString
&rUserData
,
33 SfxFilterFlags nFilterFlags
, SotClipboardFormatId nClipboardID
,
34 unsigned int nFilterVersion
) override
;
36 virtual void setUp() override
;
37 virtual void tearDown() override
;
39 // Ensure CVEs remain unbroken
42 CPPUNIT_TEST_SUITE(SdFiltersTest
);
43 CPPUNIT_TEST(testCVEs
);
44 CPPUNIT_TEST_SUITE_END();
47 uno::Reference
<uno::XInterface
> m_xDrawComponent
;
50 bool SdFiltersTest::load(const OUString
&rFilter
, const OUString
&rURL
,
51 const OUString
&rUserData
, SfxFilterFlags nFilterFlags
, SotClipboardFormatId nClipboardID
,
52 unsigned int nFilterVersion
)
54 std::shared_ptr
<const SfxFilter
> pFilter(new SfxFilter(
56 OUString(), nFilterFlags
, nClipboardID
, OUString(), OUString(),
57 rUserData
, OUString() ));
58 const_cast<SfxFilter
*>(pFilter
.get())->SetVersion(nFilterVersion
);
60 ::sd::DrawDocShellRef xDocShRef
= new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED
, false, DocumentType::Impress
);
61 SfxMedium
* pSrcMed
= new SfxMedium(rURL
, StreamMode::STD_READ
);
62 pSrcMed
->SetFilter(pFilter
);
63 bool bLoaded
= xDocShRef
->DoLoad(pSrcMed
);
68 void SdFiltersTest::testCVEs()
70 #ifndef DISABLE_CVE_TESTS
71 testDir("MS PowerPoint 97",
72 m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/"),
75 testDir("Impress Office Open XML",
76 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/"),
77 "", (SfxFilterFlags::IMPORT
| SfxFilterFlags::ALIEN
| SfxFilterFlags::STARONEFILTER
));
80 m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/"),
84 m_directories
.getURLFromSrc("/sd/qa/unit/data/odg/"),
87 testDir("CGM - Computer Graphics Metafile",
88 m_directories
.getURLFromSrc("/sd/qa/unit/data/cgm/"),
93 SdFiltersTest::SdFiltersTest()
97 void SdFiltersTest::setUp()
99 test::BootstrapFixture::setUp();
101 // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
102 // which is a private symbol to us, gets called
104 getMultiServiceFactory()->createInstance("com.sun.star.comp.Draw.PresentationDocument");
105 CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent
.is());
108 void SdFiltersTest::tearDown()
110 uno::Reference
< lang::XComponent
>( m_xDrawComponent
, uno::UNO_QUERY_THROW
)->dispose();
111 test::BootstrapFixture::tearDown();
114 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest
);
116 CPPUNIT_PLUGIN_IMPLEMENT();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */