summaryrefslogtreecommitdiffstats
path: root/writerperfect/qa/unit/WpftFilterTestBase.cxx
blob: 1c5989c792bbf6818837988fb57fc255f98114e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "WpftFilterTestBase.hxx"

#include <com/sun/star/document/XFilter.hpp>

#include <tools/urlobj.hxx>

#include "WpftLoader.hxx"

namespace uno = com::sun::star::uno;

namespace writerperfect::test
{
WpftFilterTestBase::WpftFilterTestBase(const OUString& rFactoryURL)
    : ::test::FiltersTest()
    , WpftFilterFixture()
    , m_aFactoryURL(rFactoryURL)
    , m_pOptionalMap(nullptr)
{
}

bool WpftFilterTestBase::load(const OUString&, const OUString& rURL, const OUString&,
                              SfxFilterFlags, SotClipboardFormatId, unsigned int)
{
    if (m_pOptionalMap)
    {
        // first check if this test file is supported by the used version of the library
        const INetURLObject aUrl(rURL);
        const WpftOptionalMap_t::const_iterator it(m_pOptionalMap->find(aUrl.getName()));
        if ((it != m_pOptionalMap->end()) && !it->second)
            return true; // skip the file
    }

    const WpftLoader aLoader(rURL, m_xFilter, m_aFactoryURL, m_xDesktop, m_xTypeMap, m_xContext);
    return aLoader.getDocument().is();
}

void WpftFilterTestBase::doTest(const OUString& rFilter, const OUString& rPath)
{
    m_xFilter.set(m_xFactory->createInstanceWithContext(rFilter, m_xContext), uno::UNO_QUERY_THROW);
    testDir(OUString(), m_directories.getURLFromSrc(rPath));
}

void WpftFilterTestBase::doTest(const OUString& rFilter, const OUString& rPath,
                                const WpftOptionalMap_t& rOptionalMap)
{
    m_xFilter.set(m_xFactory->createInstanceWithContext(rFilter, m_xContext), uno::UNO_QUERY_THROW);
    m_pOptionalMap = &rOptionalMap;
    testDir(OUString(), m_directories.getURLFromSrc(rPath));
    m_pOptionalMap = nullptr;
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */