From 7ddfa141d3de8f2a431b5844254f23f7b7aeb1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 5 Nov 2014 10:38:32 +0000 Subject: [PATCH] coverity#1019393 Uncaught exception Change-Id: I818a91a3090392efed46700b5e2d77d7f1e3bdb9 --- sdext/source/pdfimport/test/pdf2xml.cxx | 72 ++++++++++++++----------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/sdext/source/pdfimport/test/pdf2xml.cxx b/sdext/source/pdfimport/test/pdf2xml.cxx index 88b3535bfff1..f081097c52d0 100644 --- a/sdext/source/pdfimport/test/pdf2xml.cxx +++ b/sdext/source/pdfimport/test/pdf2xml.cxx @@ -39,40 +39,48 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) if( argc < 4 ) return 1; - OUString aBaseURL, aTmpURL, aSrcURL, aDstURL; + try + { + OUString aBaseURL, aTmpURL, aSrcURL, aDstURL; - TreeVisitorFactorySharedPtr pTreeFactory; - if( rtl_str_compare(argv[1], "-writer") == 0 ) - pTreeFactory = createWriterTreeVisitorFactory(); - else if( rtl_str_compare(argv[1], "-draw") == 0 ) - pTreeFactory = createDrawTreeVisitorFactory(); - else if( rtl_str_compare(argv[1], "-impress") == 0 ) - pTreeFactory = createImpressTreeVisitorFactory(); - else + TreeVisitorFactorySharedPtr pTreeFactory; + if( rtl_str_compare(argv[1], "-writer") == 0 ) + pTreeFactory = createWriterTreeVisitorFactory(); + else if( rtl_str_compare(argv[1], "-draw") == 0 ) + pTreeFactory = createDrawTreeVisitorFactory(); + else if( rtl_str_compare(argv[1], "-impress") == 0 ) + pTreeFactory = createImpressTreeVisitorFactory(); + else + return 1; + + osl_getProcessWorkingDir(&aBaseURL.pData); + osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[2]).pData, + &aTmpURL.pData ); + osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aSrcURL.pData); + + osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[3]).pData, + &aTmpURL.pData ); + osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aDstURL.pData); + + // bootstrap UNO + uno::Reference< uno::XComponentContext > xContext( + cppu::defaultBootstrap_InitialComponentContext() ); + uno::Reference xFactory(xContext->getServiceManager()); + uno::Reference xSM(xFactory, uno::UNO_QUERY_THROW); + comphelper::setProcessServiceFactory(xSM); + + test::BootstrapFixtureBase aEnv; + aEnv.setUp(); + + pdfi::PDFIRawAdaptor aAdaptor( aEnv.getComponentContext() ); + aAdaptor.setTreeVisitorFactory(pTreeFactory); + aAdaptor.odfConvert( aSrcURL, new OutputWrap(aDstURL), NULL ); + } + catch (const uno::Exception& e) + { + SAL_WARN("vcl.app", "Fatal exception: " << e.Message); return 1; - - osl_getProcessWorkingDir(&aBaseURL.pData); - osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[2]).pData, - &aTmpURL.pData ); - osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aSrcURL.pData); - - osl_getFileURLFromSystemPath( OUString::createFromAscii(argv[3]).pData, - &aTmpURL.pData ); - osl_getAbsoluteFileURL(aBaseURL.pData,aTmpURL.pData,&aDstURL.pData); - - // bootstrap UNO - uno::Reference< uno::XComponentContext > xContext( - cppu::defaultBootstrap_InitialComponentContext() ); - uno::Reference xFactory(xContext->getServiceManager()); - uno::Reference xSM(xFactory, uno::UNO_QUERY_THROW); - comphelper::setProcessServiceFactory(xSM); - - test::BootstrapFixtureBase aEnv; - aEnv.setUp(); - - pdfi::PDFIRawAdaptor aAdaptor( aEnv.getComponentContext() ); - aAdaptor.setTreeVisitorFactory(pTreeFactory); - aAdaptor.odfConvert( aSrcURL, new OutputWrap(aDstURL), NULL ); + } return 0; }