From 7f8a4db4e387cbbde7cbcd9bd4d341817c0669cc Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 18 Aug 2015 15:24:24 +0200 Subject: Simplify from ucbhelper::getSystemPathFromFileURL & v. v. to osl::FileBase (vnd.sun.star.wfs is long gone); pending further clean up Change-Id: Ie532c1d945c20a31f7758fbc0438e6b1f5d5c843 --- unotools/source/ucbhelper/localfilehelper.cxx | 76 ++++++++------------------- 1 file changed, 21 insertions(+), 55 deletions(-) diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx index d5ff1e4ef5e5..3efc99b7ee36 100644 --- a/unotools/source/ucbhelper/localfilehelper.cxx +++ b/unotools/source/ucbhelper/localfilehelper.cxx @@ -20,11 +20,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -38,76 +36,44 @@ using namespace ::com::sun::star::ucb; namespace utl { -bool LocalFileHelper::ConvertSystemPathToURL( const OUString& rName, const OUString& rBaseURL, OUString& rReturn ) +bool LocalFileHelper::ConvertSystemPathToURL( const OUString& rName, const OUString&, OUString& rReturn ) { - rReturn.clear(); - - Reference< XUniversalContentBroker > pBroker( - UniversalContentBroker::create( - comphelper::getProcessComponentContext() ) ); - try - { - rReturn = ::ucbhelper::getFileURLFromSystemPath( pBroker, rBaseURL, rName ); + bool ok = osl::FileBase::getFileURLFromSystemPath(rName, rReturn) + == osl::FileBase::E_None; + if (!ok) { + rReturn.clear(); } - catch ( ::com::sun::star::uno::RuntimeException& ) - { - return false; - } - - return !rReturn.isEmpty(); + return ok; } bool LocalFileHelper::ConvertURLToSystemPath( const OUString& rName, OUString& rReturn ) { - rReturn.clear(); - Reference< XUniversalContentBroker > pBroker( - UniversalContentBroker::create( - comphelper::getProcessComponentContext() ) ); - try - { - rReturn = ::ucbhelper::getSystemPathFromFileURL( pBroker, rName ); + bool ok = osl::FileBase::getSystemPathFromFileURL(rName, rReturn) + == osl::FileBase::E_None; + if (!ok) { + rReturn.clear(); } - catch ( ::com::sun::star::uno::RuntimeException& ) - { - } - - return !rReturn.isEmpty(); + return ok; } bool LocalFileHelper::ConvertPhysicalNameToURL(const OUString& rName, OUString& rReturn) { - rReturn.clear(); - Reference< XUniversalContentBroker > pBroker( - UniversalContentBroker::create( - comphelper::getProcessComponentContext() ) ); - try - { - rReturn = ::ucbhelper::getFileURLFromSystemPath( pBroker, "file:///", rName ); + bool ok = osl::FileBase::getFileURLFromSystemPath(rName, rReturn) + == osl::FileBase::E_None; + if (!ok) { + rReturn.clear(); } - catch (const ::com::sun::star::uno::RuntimeException&) - { - } - - return !rReturn.isEmpty(); + return ok; } bool LocalFileHelper::ConvertURLToPhysicalName(const OUString& rName, OUString& rReturn) { - rReturn.clear(); - Reference< XUniversalContentBroker > pBroker( - UniversalContentBroker::create( - comphelper::getProcessComponentContext() ) ); - try - { - INetURLObject aObj( rName ); - if ( aObj.GetProtocol() == INetProtocol::File ) - rReturn = ::ucbhelper::getSystemPathFromFileURL( pBroker, rName ); + bool ok = osl::FileBase::getSystemPathFromFileURL(rName, rReturn) + == osl::FileBase::E_None; + if (!ok) { + rReturn.clear(); } - catch (const ::com::sun::star::uno::RuntimeException&) - { - } - - return !rReturn.isEmpty(); + return ok; } bool LocalFileHelper::IsLocalFile(const OUString& rName) -- cgit