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 <unotest/filters-test.hxx>
11 #include <test/bootstrapfixture.hxx>
12 #include <com/sun/star/document/XFilter.hpp>
13 #include <com/sun/star/io/WrongFormatException.hpp>
14 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
16 using namespace ::com::sun::star
;
19 * Unit test invoking writerfilter/ only.
21 * This does only minimal testing, checking if the filter crashes and returns
22 * the expected bool value for given inputs. More fine-grained tests can be
23 * found under sw/qa/extras/rtfimport/.
25 class RtfTest
: public test::FiltersTest
, public test::BootstrapFixture
28 virtual void setUp() override
;
30 virtual bool load(const OUString
&, const OUString
& rURL
, const OUString
&, SfxFilterFlags
,
31 SotClipboardFormatId
, unsigned int) override
;
34 uno::Reference
<document::XFilter
> m_xFilter
;
39 test::BootstrapFixture::setUp();
41 m_xFilter
.set(m_xSFactory
->createInstance("com.sun.star.comp.Writer.RtfFilter"),
42 uno::UNO_QUERY_THROW
);
45 bool RtfTest::load(const OUString
&, const OUString
& rURL
, const OUString
&, SfxFilterFlags
,
46 SotClipboardFormatId
, unsigned int)
48 uno::Sequence
<beans::PropertyValue
> aDescriptor
= { beans::PropertyValue(
49 "URL", sal_Int32(0), uno::Any(rURL
), beans::PropertyState_DIRECT_VALUE
) };
52 return m_xFilter
->filter(aDescriptor
);
54 catch (const lang::WrappedTargetRuntimeException
& rWrapped
)
56 io::WrongFormatException e
;
57 if (rWrapped
.TargetException
>>= e
)
63 catch (const std::exception
&)
69 CPPUNIT_TEST_FIXTURE(RtfTest
, testFilter
)
71 #ifndef DISABLE_CVE_TESTS
73 m_directories
.getURLFromSrc(u
"/writerfilter/qa/cppunittests/filters-test/data/"));
77 CPPUNIT_PLUGIN_IMPLEMENT();
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */