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 #include <osl/file.hxx>
17 #include <osl/process.h>
19 using namespace ::com::sun::star
;
22 * Unit test invoking the Writer RTF import filter.
24 * This does only minimal testing, checking if the filter crashes and returns
25 * the expected bool value for given inputs. More fine-grained tests can be
26 * found under sw/qa/extras/rtfimport/.
29 : public test::FiltersTest
30 , public test::BootstrapFixture
34 virtual void setUp() SAL_OVERRIDE
;
36 virtual bool load(const OUString
&,
37 const OUString
& rURL
, const OUString
&,
38 SfxFilterFlags
, SotClipboardFormatId
, unsigned int) SAL_OVERRIDE
;
42 CPPUNIT_TEST_SUITE(RtfTest
);
44 CPPUNIT_TEST_SUITE_END();
46 uno::Reference
<document::XFilter
> m_xFilter
;
51 test::BootstrapFixture::setUp();
53 m_xFilter
= uno::Reference
< document::XFilter
>(m_xSFactory
->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW
);
56 bool RtfTest::load(const OUString
&,
57 const OUString
& rURL
, const OUString
&,
58 SfxFilterFlags
, SotClipboardFormatId
, unsigned int)
60 uno::Sequence
< beans::PropertyValue
> aDescriptor
=
62 beans::PropertyValue("URL", sal_Int32(0), uno::makeAny(rURL
), beans::PropertyState_DIRECT_VALUE
)
66 return m_xFilter
->filter(aDescriptor
);
68 catch (const lang::WrappedTargetRuntimeException
& rWrapped
)
70 io::WrongFormatException e
;
71 if (rWrapped
.TargetException
>>= e
)
81 #ifndef DISABLE_CVE_TESTS
83 getURLFromSrc("/writerfilter/qa/cppunittests/rtftok/data/"),
88 CPPUNIT_TEST_SUITE_REGISTRATION(RtfTest
);
90 CPPUNIT_PLUGIN_IMPLEMENT();
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */