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 "WpftFilterTestBase.hxx"
12 #include <com/sun/star/document/XFilter.hpp>
14 #include <tools/urlobj.hxx>
16 #include "WpftLoader.hxx"
18 namespace uno
= com::sun::star::uno
;
20 namespace writerperfect
24 WpftFilterTestBase::WpftFilterTestBase(const OUString
& rFactoryURL
)
25 : ::test::FiltersTest()
27 , m_aFactoryURL(rFactoryURL
)
28 , m_pOptionalMap(nullptr)
32 bool WpftFilterTestBase::load(const OUString
&, const OUString
& rURL
, const OUString
&,
33 SfxFilterFlags
, SotClipboardFormatId
, unsigned int)
37 // first check if this test file is supported by the used version of the library
38 const INetURLObject
aUrl(rURL
);
39 const WpftOptionalMap_t::const_iterator
it(m_pOptionalMap
->find(aUrl
.getName()));
40 if ((it
!= m_pOptionalMap
->end()) && !it
->second
)
41 return true; // skip the file
44 const WpftLoader
aLoader(rURL
, m_xFilter
, m_aFactoryURL
, m_xDesktop
, m_xTypeMap
, m_xContext
);
45 return aLoader
.getDocument().is();
48 void WpftFilterTestBase::doTest(const OUString
& rFilter
, const OUString
& rPath
)
50 m_xFilter
.set(m_xFactory
->createInstanceWithContext(rFilter
, m_xContext
), uno::UNO_QUERY_THROW
);
51 testDir(OUString(), m_directories
.getURLFromSrc(rPath
));
54 void WpftFilterTestBase::doTest(const OUString
& rFilter
, const OUString
& rPath
,
55 const WpftOptionalMap_t
& rOptionalMap
)
57 m_xFilter
.set(m_xFactory
->createInstanceWithContext(rFilter
, m_xContext
), uno::UNO_QUERY_THROW
);
58 m_pOptionalMap
= &rOptionalMap
;
59 testDir(OUString(), m_directories
.getURLFromSrc(rPath
));
60 m_pOptionalMap
= nullptr;
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */