From a900a4d70bb465e24c49a0183c60087328860e83 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 1 Oct 2012 11:46:24 +0200 Subject: Fail early if getPackageLocation fails; plus clean-up Change-Id: Ifa7d589e7854fed9cd9ca2a3f3c987179b60199f --- sdext/source/pdfimport/wrapper/wrapper.cxx | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'sdext') diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 2d76fff27419..77ce15bf531e 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -44,7 +44,7 @@ #include "com/sun/star/io/XInputStream.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/awt/FontDescriptor.hpp" -#include "com/sun/star/deployment/XPackageInformationProvider.hpp" +#include "com/sun/star/deployment/PackageInformationProvider.hpp" #include "com/sun/star/beans/XMaterialHolder.hpp" #include "com/sun/star/rendering/PathCapType.hpp" #include "com/sun/star/rendering/PathJoinType.hpp" @@ -999,24 +999,21 @@ bool xpdf_ImportFromFile( const ::rtl::OUString& rUR if( checkEncryption( aSysUPath, xIHdl, aPwd, bIsEncrypted, aDocName ) == false ) return false; - rtl::OUStringBuffer converterURL = rtl::OUString("xpdfimport"); - - // retrieve package location url (xpdfimport executable is located there) - // --------------------------------------------------- - uno::Reference xProvider( - xContext->getValueByName( - rtl::OUString("/singletons/com.sun.star.deployment.PackageInformationProvider")), - uno::UNO_QUERY); - if( xProvider.is() ) - { - converterURL.insert( - 0, - rtl::OUString("/")); - converterURL.insert( - 0, - xProvider->getPackageLocation( - rtl::OUString::createFromAscii(PDFI_IMPL_IDENTIFIER))); + // Retrieve package location URL, xpdfimport executable is located there: + OUString location( + deployment::PackageInformationProvider::get(xContext)-> + getPackageLocation(PDFI_IMPL_IDENTIFIER)); + if (location.isEmpty()) { + SAL_WARN( + "sdext.pdfimport", + "getPackageLocation(" PDFI_IMPL_IDENTIFIER ") failed"); + return false; + } + rtl::OUStringBuffer converterURL(location); + if (!location.endsWith("/")) { + converterURL.append('/'); } + converterURL.append("xpdfimport"); // spawn separate process to keep LGPL/GPL code apart. // --------------------------------------------------- -- cgit