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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "outputwrap.hxx"
22 #include "contentsink.hxx"
23 #include "pdfihelper.hxx"
24 #include "wrapper.hxx"
25 #include "pdfparse.hxx"
26 #include "../pdfiadaptor.hxx"
29 #include <osl/process.h>
30 #include <unotest/bootstrapfixturebase.hxx>
31 #include <comphelper/processfactory.hxx>
32 #include <cppuhelper/bootstrap.hxx>
34 using namespace ::pdfi
;
35 using namespace ::com::sun::star
;
37 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc
, argv
)
44 OUString aBaseURL
, aTmpURL
, aSrcURL
, aDstURL
;
46 TreeVisitorFactorySharedPtr pTreeFactory
;
47 if( rtl_str_compare(argv
[1], "-writer") == 0 )
48 pTreeFactory
= createWriterTreeVisitorFactory();
49 else if( rtl_str_compare(argv
[1], "-draw") == 0 )
50 pTreeFactory
= createDrawTreeVisitorFactory();
51 else if( rtl_str_compare(argv
[1], "-impress") == 0 )
52 pTreeFactory
= createImpressTreeVisitorFactory();
56 osl_getProcessWorkingDir(&aBaseURL
.pData
);
57 osl_getFileURLFromSystemPath( OUString::createFromAscii(argv
[2]).pData
,
59 osl_getAbsoluteFileURL(aBaseURL
.pData
,aTmpURL
.pData
,&aSrcURL
.pData
);
61 osl_getFileURLFromSystemPath( OUString::createFromAscii(argv
[3]).pData
,
63 osl_getAbsoluteFileURL(aBaseURL
.pData
,aTmpURL
.pData
,&aDstURL
.pData
);
66 uno::Reference
< uno::XComponentContext
> xContext(
67 cppu::defaultBootstrap_InitialComponentContext() );
68 uno::Reference
<lang::XMultiComponentFactory
> xFactory(xContext
->getServiceManager());
69 uno::Reference
<lang::XMultiServiceFactory
> xSM(xFactory
, uno::UNO_QUERY_THROW
);
70 comphelper::setProcessServiceFactory(xSM
);
72 test::BootstrapFixtureBase aEnv
;
75 pdfi::PDFIRawAdaptor
aAdaptor( OUString(), aEnv
.getComponentContext() );
76 aAdaptor
.setTreeVisitorFactory(pTreeFactory
);
77 aAdaptor
.odfConvert( aSrcURL
, new OutputWrap(aDstURL
), NULL
);
79 catch (const uno::Exception
& e
)
81 SAL_WARN("vcl.app", "Fatal exception: " << e
.Message
);
84 catch (const std::exception
& e
)
86 SAL_WARN("vcl.app", "Fatal exception: " << e
.what());
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */