fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sdext / source / pdfimport / test / pdf2xml.cxx
blob518b0ef2c9380c1cab2ba1798c53e857ab5975c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
28 #include <sal/main.h>
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)
39 if( argc < 4 )
40 return 1;
42 try
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();
53 else
54 return 1;
56 osl_getProcessWorkingDir(&aBaseURL.pData);
57 osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[2]).pData,
58 &aTmpURL.pData );
59 osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aSrcURL.pData);
61 osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[3]).pData,
62 &aTmpURL.pData );
63 osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aDstURL.pData);
65 // bootstrap UNO
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;
73 aEnv.setUp();
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);
82 return 1;
84 catch (const std::exception& e)
86 SAL_WARN("vcl.app", "Fatal exception: " << e.what());
87 return 1;
90 return 0;
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */