1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pdf2xml.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "outputwrap.hxx"
36 #include "contentsink.hxx"
37 #include "pdfihelper.hxx"
38 #include "wrapper.hxx"
39 #include "pdfparse.hxx"
40 #include "../pdfiadaptor.hxx"
43 #include <osl/process.h>
44 #include <rtl/bootstrap.hxx>
46 #include <cppuhelper/bootstrap.hxx>
47 #include <cppuhelper/servicefactory.hxx>
48 #include <comphelper/processfactory.hxx>
50 using namespace ::pdfi
;
51 using namespace ::com::sun::star
;
53 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc
, argv
)
58 ::rtl::OUString aBaseURL
, aTmpURL
, aSrcURL
, aDstURL
, aIniUrl
;
60 TreeVisitorFactorySharedPtr pTreeFactory
;
61 if( rtl_str_compare(argv
[1], "-writer") == 0 )
62 pTreeFactory
= createWriterTreeVisitorFactory();
63 else if( rtl_str_compare(argv
[1], "-draw") == 0 )
64 pTreeFactory
= createDrawTreeVisitorFactory();
65 else if( rtl_str_compare(argv
[1], "-impress") == 0 )
66 pTreeFactory
= createImpressTreeVisitorFactory();
70 osl_getProcessWorkingDir(&aBaseURL
.pData
);
71 osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv
[2]).pData
,
73 osl_getAbsoluteFileURL(aBaseURL
.pData
,aTmpURL
.pData
,&aSrcURL
.pData
);
75 osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv
[3]).pData
,
77 osl_getAbsoluteFileURL(aBaseURL
.pData
,aTmpURL
.pData
,&aDstURL
.pData
);
79 osl_getFileURLFromSystemPath( rtl::OUString::createFromAscii(argv
[4]).pData
,
81 osl_getAbsoluteFileURL(aBaseURL
.pData
,aTmpURL
.pData
,&aIniUrl
.pData
);
84 uno::Reference
< lang::XMultiServiceFactory
> xFactory
;
85 uno::Reference
< uno::XComponentContext
> xCtx
;
88 xCtx
= ::cppu::defaultBootstrap_InitialComponentContext(aIniUrl
);
89 xFactory
= uno::Reference
< lang::XMultiServiceFactory
>( xCtx
->getServiceManager(),
92 ::comphelper::setProcessServiceFactory( xFactory
);
94 catch( uno::Exception
& )
100 OSL_TRACE( "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
104 pdfi::PDFIRawAdaptor
aAdaptor( xCtx
);
105 aAdaptor
.setTreeVisitorFactory(pTreeFactory
);
106 aAdaptor
.odfConvert( aSrcURL
, new OutputWrap(aDstURL
), NULL
);