From b0da8f00a0d41f2b17639fcee4ed4956421e55c5 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Tue, 30 Apr 2013 00:33:23 +0200 Subject: [PATCH] Make pdf2xml usable at least from within buildenv again. Seems this had bitrotted quite a lot. Calling it now like a cppunit test works again. Change-Id: I27479c3c3e1c1fe0639629e9bf8844456e0b0515 --- sdext/Executable_pdf2xml.mk | 2 ++ sdext/source/pdfimport/test/pdf2xml.cxx | 38 +++++++------------------ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/sdext/Executable_pdf2xml.mk b/sdext/Executable_pdf2xml.mk index 6cd93a097f1e..38a591d41c00 100644 --- a/sdext/Executable_pdf2xml.mk +++ b/sdext/Executable_pdf2xml.mk @@ -26,6 +26,8 @@ $(eval $(call gb_Executable_use_libraries,pdf2xml,\ vcl \ comphelper \ cppu \ + unotest \ + test \ cppuhelper \ sal \ )) diff --git a/sdext/source/pdfimport/test/pdf2xml.cxx b/sdext/source/pdfimport/test/pdf2xml.cxx index d18bfa07c210..666781b206a4 100644 --- a/sdext/source/pdfimport/test/pdf2xml.cxx +++ b/sdext/source/pdfimport/test/pdf2xml.cxx @@ -27,17 +27,16 @@ #include #include -#include - -#include +#include #include +#include using namespace ::pdfi; using namespace ::com::sun::star; SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { - if( argc != 5 ) + if( argc < 4 ) return 1; OUString aBaseURL, aTmpURL, aSrcURL, aDstURL, aIniUrl; @@ -61,32 +60,17 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) &aTmpURL.pData ); osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aDstURL.pData); - osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[4]).pData, - &aTmpURL.pData ); - osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aIniUrl.pData); - // bootstrap UNO - uno::Reference< lang::XMultiServiceFactory > xFactory; - uno::Reference< uno::XComponentContext > xCtx; - try - { - xCtx = ::cppu::defaultBootstrap_InitialComponentContext(aIniUrl); - xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(), - uno::UNO_QUERY ); - if( xFactory.is() ) - ::comphelper::setProcessServiceFactory( xFactory ); - } - catch( uno::Exception& ) - { - } + uno::Reference< uno::XComponentContext > xContext( + cppu::defaultBootstrap_InitialComponentContext() ); + uno::Reference xFactory(xContext->getServiceManager()); + uno::Reference xSM(xFactory, uno::UNO_QUERY_THROW); + comphelper::setProcessServiceFactory(xSM); - if( !xFactory.is() ) - { - OSL_TRACE( "Could not bootstrap UNO, installation must be in disorder. Exiting." ); - return 1; - } + test::BootstrapFixtureBase aEnv; + aEnv.setUp(); - pdfi::PDFIRawAdaptor aAdaptor( xCtx ); + pdfi::PDFIRawAdaptor aAdaptor( aEnv.getComponentContext() ); aAdaptor.setTreeVisitorFactory(pTreeFactory); aAdaptor.odfConvert( aSrcURL, new OutputWrap(aDstURL), NULL );