diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-08-19 12:24:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-08-19 12:24:37 +0200 |
commit | 5da0dce19caaf87a6fe53750a7e9ea5d564d6a12 (patch) | |
tree | 52028a1384c5074886fdd1722f71c32f3970146f | |
parent | 520053459aa6a34b6d9ad52d97704399e5138d3d (diff) |
Consolidate isFileUrl checks
Change-Id: I1b74fdfaa09c4d0d6c296253958e83e78b546a9a
28 files changed, 114 insertions, 60 deletions
diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk index 2192217a4338..6f2cc4c8f137 100644 --- a/comphelper/Library_comphelper.mk +++ b/comphelper/Library_comphelper.mk @@ -89,6 +89,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\ comphelper/source/misc/documentiologring \ comphelper/source/misc/evtlistenerhlp \ comphelper/source/misc/evtmethodhelper \ + comphelper/source/misc/fileurl \ comphelper/source/misc/getexpandeduri \ comphelper/source/misc/instancelocker \ comphelper/source/misc/interaction \ diff --git a/comphelper/source/misc/fileurl.cxx b/comphelper/source/misc/fileurl.cxx new file mode 100644 index 000000000000..9abf1a97f62d --- /dev/null +++ b/comphelper/source/misc/fileurl.cxx @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <comphelper/fileurl.hxx> +#include <rtl/ustring.hxx> + +bool comphelper::isFileUrl(OUString const & url) { + return url.startsWithIgnoreAsciiCase("file:"); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx index 044eeaa59287..7ba751c0951b 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx @@ -32,6 +32,7 @@ #include <osl/file.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/theMacroExpander.hpp> +#include <comphelper/fileurl.hxx> #include "officeinstallationdirectories.hxx" @@ -46,7 +47,7 @@ using namespace comphelper; static bool makeCanonicalFileURL( OUString & rURL ) { - OSL_ENSURE(rURL.startsWithIgnoreAsciiCase("file:"), "File URL expected!"); + OSL_ENSURE(comphelper::isFileUrl(rURL), "File URL expected!"); OUString aNormalizedURL; if ( osl::FileBase::getAbsoluteFileURL( OUString(), diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 861cb3ff2bd2..798b69552ab3 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -77,6 +77,7 @@ #include <sal/log.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <comphelper/configuration.hxx> +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <unotools/bootstrap.hxx> #include <unotools/configmgr.hxx> @@ -2429,7 +2430,7 @@ OUString GetURL_Impl( // dont touch file urls, those should already be in internal form // they won't get better here (#112849#) - if (rName.startsWith("file:")) + if (comphelper::isFileUrl(rName)) { return rName; } diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx index 863e7a3dcf8a..a11f1a635227 100644 --- a/extensions/source/plugin/base/context.cxx +++ b/extensions/source/plugin/base/context.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/frame/Desktop.hpp> +#include <comphelper/fileurl.hxx> #include <tools/urlobj.hxx> #include <osl/file.hxx> @@ -139,7 +140,7 @@ void XPluginContext_Impl::getURL(const Reference< ::com::sun::star::plugin::XPlu plugin->provideNewStream( OUString(), Reference< XActiveDataSource >(), aUrl, - 0, 0, aUrl.startsWith("file:") ); + 0, 0, comphelper::isFileUrl(aUrl) ); return; } diff --git a/extensions/source/plugin/base/manager.cxx b/extensions/source/plugin/base/manager.cxx index c78cb0f928b0..688a0b2eacff 100644 --- a/extensions/source/plugin/base/manager.cxx +++ b/extensions/source/plugin/base/manager.cxx @@ -40,6 +40,7 @@ #include <cstdarg> +#include <comphelper/fileurl.hxx> #include <comphelper/string.hxx> #include <comphelper/processfactory.hxx> @@ -220,7 +221,7 @@ Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::createPlugi pImpl->provideNewStream( pImpl->getDescription().Mimetype, Reference< com::sun::star::io::XActiveDataSource >(), url, - 0, 0, url.startsWith("file:") ); + 0, 0, comphelper::isFileUrl(url) ); if( ! pImpl->getPluginComm() ) { diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx index db644ec087f7..eab48cd11979 100644 --- a/extensions/source/plugin/base/xplugin.cxx +++ b/extensions/source/plugin/base/xplugin.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/plugin/PluginManager.hpp> #include <cppuhelper/queryinterface.hxx> +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <plugin/impl.hxx> #include <sal/log.hxx> @@ -451,7 +452,7 @@ void XPlugin_Impl::modelChanged() provideNewStream( m_aDescription.Mimetype, uno::Reference< XActiveDataSource >(), aURL, - 0, 0, aURL.startsWith("file:") ); + 0, 0, comphelper::isFileUrl(aURL) ); m_nProvidingState = PROVIDING_NONE; } @@ -787,7 +788,7 @@ sal_Bool XPlugin_Impl::provideNewStream(const OUString& mimetype, if( isfile && stype == NP_ASFILEONLY ) { OString aFileName; - if( url.startsWith("file:") ) + if( comphelper::isFileUrl(url) ) { OUString aSysName; osl_getSystemPathFromFileURL( url.pData, &aSysName.pData ); diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index 42b609c09bab..16f204d95bab 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -31,7 +31,7 @@ #include <rtl/ustrbuf.hxx> #include <framework/interaction.hxx> #include <tools/urlobj.hxx> -#include <unotools/localfilehelper.hxx> +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> @@ -1136,7 +1136,7 @@ void TypeDetection::impl_openStream(utl::MediaDescriptor& rDescriptor) bool bSuccess = false; OUString sURL = rDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL(), OUString() ); bool bRequestedReadOnly = rDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_READONLY(), false ); - if ( utl::LocalFileHelper::IsFileUrl( sURL ) ) + if ( comphelper::isFileUrl( sURL ) ) { // OOo uses own file locking mechanics in case of local file bSuccess = rDescriptor.addInputStreamOwnLock(); diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index afd728eb411a..56db0c1cc2ea 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/style/XStyleLoader.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequenceashashmap.hxx> #include <unotools/mediadescriptor.hxx> @@ -141,7 +142,7 @@ bool SAL_CALL XmlFilterAdaptor::importImpl( const Sequence< ::com::sun::star::be Sequence<com::sun::star::beans::PropertyValue> pValue=xstyleLoader->getStyleLoaderOptions(); //Load the Styles from the Template URL Supplied in the TypeDetection file - if(msTemplateName.indexOf("file:")==-1) + if(!comphelper::isFileUrl(msTemplateName)) { SvtPathOptions aOptions; OUString PathString = aOptions.SubstituteVariable(OUString("$(progurl)")); diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx index 59523ce4b8ec..9db846a8b6e2 100644 --- a/filter/source/xsltdialog/xmlfiltercommon.hxx +++ b/filter/source/xsltdialog/xmlfiltercommon.hxx @@ -33,12 +33,6 @@ extern OUString string_encode( const OUString & rText ); extern OUString string_decode( const OUString & rText ); - - -extern bool isFileURL( const OUString & rURL ); - - - bool copyStreams( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xIS, ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOS ); bool createDirectory( OUString& rURL ); diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 7fcbaaae7ac0..c937e3f4029a 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -1622,11 +1622,6 @@ OUString string_decode( const OUString & rText ) return Uri::decode( rText, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); } -bool isFileURL( const OUString & rURL ) -{ - return rURL.startsWith("file:"); -} - bool copyStreams( Reference< XInputStream > xIS, Reference< XOutputStream > xOS ) { try diff --git a/filter/source/xsltdialog/xmlfiltertabdialog.cxx b/filter/source/xsltdialog/xmlfiltertabdialog.cxx index 9309ef173b1b..1511f12ba39f 100644 --- a/filter/source/xsltdialog/xmlfiltertabdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltertabdialog.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/fileurl.hxx> #include <tools/resid.hxx> #include <vcl/layout.hxx> #include <osl/file.hxx> @@ -193,7 +194,7 @@ bool XMLFilterTabDialog::onOk() if( 0 == nErrorId ) { // 4. see if the export xslt is valid - if( (mpNewInfo->maExportXSLT != mpOldInfo->maExportXSLT) && isFileURL( mpNewInfo->maExportXSLT ) ) + if( (mpNewInfo->maExportXSLT != mpOldInfo->maExportXSLT) && comphelper::isFileUrl( mpNewInfo->maExportXSLT ) ) { osl::File aFile( mpNewInfo->maExportXSLT ); osl::File::RC aRC = aFile.open( osl_File_OpenFlag_Read ); @@ -209,7 +210,7 @@ bool XMLFilterTabDialog::onOk() if( 0 == nErrorId ) { // 5. see if the import xslt is valid - if( (mpNewInfo->maImportXSLT != mpOldInfo->maImportXSLT) && isFileURL( mpNewInfo->maImportXSLT ) ) + if( (mpNewInfo->maImportXSLT != mpOldInfo->maImportXSLT) && comphelper::isFileUrl( mpNewInfo->maImportXSLT ) ) { osl::File aFile( mpNewInfo->maImportXSLT ); osl::File::RC aRC = aFile.open( osl_File_OpenFlag_Read ); @@ -233,7 +234,7 @@ bool XMLFilterTabDialog::onOk() if( 0 == nErrorId ) { // 6. see if the import template is valid - if( (mpNewInfo->maImportTemplate != mpOldInfo->maImportTemplate) && isFileURL( mpNewInfo->maImportTemplate ) ) + if( (mpNewInfo->maImportTemplate != mpOldInfo->maImportTemplate) && comphelper::isFileUrl( mpNewInfo->maImportTemplate ) ) { osl::File aFile( mpNewInfo->maImportTemplate ); osl::File::RC aRC = aFile.open( osl_File_OpenFlag_Read ); diff --git a/include/comphelper/fileurl.hxx b/include/comphelper/fileurl.hxx new file mode 100644 index 000000000000..9275d4abbfc4 --- /dev/null +++ b/include/comphelper/fileurl.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_COMPHELPER_FILEURL_HXX +#define INCLUDED_COMPHELPER_FILEURL_HXX + +#include <sal/config.h> + +#include <comphelper/comphelperdllapi.h> +#include <rtl/ustring.hxx> + +namespace comphelper { + +// Return true iff url is an absolute URL of "file" scheme: +COMPHELPER_DLLPUBLIC bool isFileUrl(OUString const & url); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/localfilehelper.hxx b/include/unotools/localfilehelper.hxx index 7c1be21b7e5c..31cd395db6d8 100644 --- a/include/unotools/localfilehelper.hxx +++ b/include/unotools/localfilehelper.hxx @@ -29,8 +29,6 @@ namespace utl class UNOTOOLS_DLLPUBLIC LocalFileHelper { public: - static bool IsFileUrl(const OUString& rUrl); - static ::com::sun::star::uno::Sequence< OUString > GetFolderContents( const OUString& rFolder, bool bFolder ); }; diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 95a638a22b74..1f2747b160ae 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/ucb/IOErrorCode.hpp> +#include <comphelper/fileurl.hxx> #include <ucbhelper/content.hxx> #include <cppuhelper/factory.hxx> #include <cppuhelper/exc_hlp.hxx> @@ -173,7 +174,7 @@ ZipPackage::~ZipPackage() bool ZipPackage::isLocalFile() const { - return m_aURL.startsWithIgnoreAsciiCase("file:"); + return comphelper::isFileUrl(m_aURL); } void ZipPackage::parseManifest() diff --git a/sdext/Library_pdfimport.mk b/sdext/Library_pdfimport.mk index ca7d5ac80920..dec3c3aa75c1 100644 --- a/sdext/Library_pdfimport.mk +++ b/sdext/Library_pdfimport.mk @@ -20,6 +20,7 @@ $(eval $(call gb_Library_set_include,pdfimport,\ $(eval $(call gb_Library_use_libraries,pdfimport,\ basegfx \ + comphelper \ vcl \ cppu \ cppuhelper \ diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx index 23bb0c91ab24..e966529f7eb2 100644 --- a/sdext/source/pdfimport/filterdet.cxx +++ b/sdext/source/pdfimport/filterdet.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/io/XStream.hpp> #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/io/TempFile.hpp> +#include <comphelper/fileurl.hxx> #include <cppuhelper/supportsservice.hxx> #include <boost/scoped_ptr.hpp> #include <string.h> @@ -256,7 +257,7 @@ OUString SAL_CALL PDFDetector::detect( uno::Sequence< beans::PropertyValue >& rF // check for hybrid PDF oslFileHandle aFile = NULL; if( bSuccess && - ( aURL.isEmpty() || !aURL.startsWith( "file:" ) ) + ( aURL.isEmpty() || !comphelper::isFileUrl(aURL) ) ) { sal_uInt64 nWritten = 0; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 464b098bf9bb..fd1f6799a277 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -43,7 +43,7 @@ #include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> - +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/stillreadwriteinteraction.hxx> @@ -53,7 +53,6 @@ #include <vcl/help.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbhelper.hxx> -#include <unotools/localfilehelper.hxx> #include <osl/file.hxx> #include <osl/mutex.hxx> #include <osl/security.hxx> @@ -1963,7 +1962,7 @@ void FileDialogHelper_Impl::saveConfig() if ( ! mbIsSaveDlg ) { OUString aPath = getPath(); - if ( utl::LocalFileHelper::IsFileUrl( aPath ) ) + if ( comphelper::isFileUrl( aPath ) ) { SetToken( aUserData, 1, ' ', aPath ); bWriteConfig = true; diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index cb7b20bc79a8..284c581f362b 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -66,6 +66,7 @@ #include <com/sun/star/security/DocumentDigitalSignatures.hpp> #include <tools/urlobj.hxx> #include <unotools/tempfile.hxx> +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/interaction.hxx> #include <framework/interaction.hxx> @@ -94,7 +95,6 @@ #include <svtools/asynclink.hxx> #include <svl/inettype.hxx> #include <ucbhelper/commandenvironment.hxx> -#include <unotools/localfilehelper.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbhelper.hxx> #include <unotools/progresshandlerwrap.hxx> @@ -1027,7 +1027,7 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI ) sal_Int8 bUIStatus = LOCK_UI_NOLOCK; // check whether system file locking has been used, the default value is false - bool bUseSystemLock = ::utl::LocalFileHelper::IsFileUrl( pImp->m_aLogicName ) && IsSystemFileLockingUsed(); + bool bUseSystemLock = comphelper::isFileUrl( pImp->m_aLogicName ) && IsSystemFileLockingUsed(); // TODO/LATER: This implementation does not allow to detect the system lock on saving here, actually this is no big problem // if system lock is used the writeable stream should be available @@ -1861,7 +1861,7 @@ void SfxMedium::Transfer_Impl() OUString aDestURL( aDest.GetMainURL( INetURLObject::NO_DECODE ) ); - if ( ::utl::LocalFileHelper::IsFileUrl( aDestURL ) || !aDest.removeSegment() ) + if ( comphelper::isFileUrl( aDestURL ) || !aDest.removeSegment() ) { TransactedTransferForFS_Impl( aSource, aDest, xComEnv ); diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 6ed6fe8eec42..503318cb9cbc 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/embed/ElementModes.hpp> +#include <comphelper/fileurl.hxx> #include <vcl/msgbox.hxx> #include <svl/style.hxx> #include <vcl/wrkwin.hxx> @@ -46,7 +47,6 @@ #include <unotools/saveopt.hxx> #include <unotools/useroptions.hxx> -#include <unotools/localfilehelper.hxx> #include <vcl/virdev.hxx> #include <vcl/oldprintadaptor.hxx> #include <vcl/settings.hxx> @@ -387,7 +387,7 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) if ( !pFile ) return; - if ( !::utl::LocalFileHelper::IsFileUrl( pFile->GetName() ) ) + if ( !comphelper::isFileUrl( pFile->GetName() ) ) // update only for documents loaded from the local file system return; @@ -532,7 +532,7 @@ void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, const OUS // TODO/REFACTOR: // Title? - if( ::utl::LocalFileHelper::IsFileUrl( rFileName ) ) + if( comphelper::isFileUrl( rFileName ) ) { OUString aFoundName; if( SfxGetpApp()->Get_Impl()->GetDocumentTemplates()->GetFull( OUString(), rTemplateName, aFoundName ) ) diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx index 625cd951379f..14543b6ec21b 100644 --- a/svl/source/fsstor/fsstorage.cxx +++ b/svl/source/fsstor/fsstorage.cxx @@ -42,7 +42,7 @@ #include <com/sun/star/sdbc/XResultSet.hpp> #include <com/sun/star/sdbc/XRow.hpp> - +#include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> #include <cppuhelper/queryinterface.hxx> @@ -61,13 +61,6 @@ using namespace ::com::sun::star; - -// TODO: move to a standard helper -bool isLocalFile_Impl( const OUString& aURL ) -{ - return aURL.startsWithIgnoreAsciiCase("file:"); -} - struct FSStorage_Impl { OUString m_aURL; @@ -403,7 +396,7 @@ uno::Reference< io::XStream > SAL_CALL FSStorage::openStreamElement( { if ( nOpenMode & embed::ElementModes::WRITE ) { - if ( isLocalFile_Impl( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) + if ( aFileURL.GetProtocol() == INetProtocol::File ) { uno::Reference<ucb::XSimpleFileAccess3> xSimpleFileAccess( ucb::SimpleFileAccess::create( m_pImpl->m_xContext ) ); @@ -1351,7 +1344,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamEl { if ( nOpenMode & embed::ElementModes::WRITE ) { - if ( isLocalFile_Impl( aFileURL ) ) + if ( comphelper::isFileUrl( aFileURL ) ) { uno::Reference<ucb::XSimpleFileAccess3> xSimpleFileAccess( ucb::SimpleFileAccess::create( m_pImpl->m_xContext ) ); diff --git a/sw/source/ui/chrdlg/chardlg.cxx b/sw/source/ui/chrdlg/chardlg.cxx index 35ae0d0eaef5..fc1bb7f79155 100644 --- a/sw/source/ui/chrdlg/chardlg.cxx +++ b/sw/source/ui/chrdlg/chardlg.cxx @@ -19,6 +19,7 @@ #include <hintids.hxx> +#include <comphelper/fileurl.hxx> #include <vcl/msgbox.hxx> #include <svl/urihelper.hxx> #include <svl/stritem.hxx> @@ -255,7 +256,7 @@ bool SwCharURLPage::FillItemSet(SfxItemSet* rSet) { sURL = URIHelper::SmartRel2Abs(INetURLObject(), sURL, Link<OUString *, bool>(), false ); // #i100683# file URLs should be normalized in the UI - if ( sURL.startsWith("file:") ) + if ( comphelper::isFileUrl(sURL) ) sURL = URIHelper::simpleNormalizedMakeRelative(OUString(), sURL); } diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx index f49b152d9f6b..86127c6eeb37 100644 --- a/ucb/source/ucp/file/bc.cxx +++ b/ucb/source/ucp/file/bc.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/beans/PropertySetInfoChange.hpp> #include <com/sun/star/ucb/ContentAction.hpp> #include <com/sun/star/ucb/NameClash.hpp> +#include <comphelper/fileurl.hxx> #include <cppuhelper/supportsservice.hxx> #include "filglob.hxx" #include "filid.hxx" @@ -1065,7 +1066,7 @@ BaseContent::transfer( sal_Int32 nMyCommandIdentifier, if( m_nState & Deleted ) return; - if( !aTransferInfo.SourceURL.startsWith( "file:" ) ) + if( !comphelper::isFileUrl(aTransferInfo.SourceURL) ) { m_pMyShell->installError( nMyCommandIdentifier, TASKHANDLING_TRANSFER_INVALIDSCHEME ); diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx index 9afcd8a33f41..8865f99a4567 100644 --- a/unotools/source/ucbhelper/localfilehelper.cxx +++ b/unotools/source/ucbhelper/localfilehelper.cxx @@ -36,11 +36,6 @@ using namespace ::com::sun::star::ucb; namespace utl { -bool LocalFileHelper::IsFileUrl(const OUString& rUrl) -{ - return rUrl.startsWithIgnoreAsciiCase("file:"); -} - typedef ::std::vector< OUString* > StringList_Impl; ::com::sun::star::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUString& rFolder, bool bFolder ) diff --git a/uui/source/iahndl-ioexceptions.cxx b/uui/source/iahndl-ioexceptions.cxx index 029ba1dd8895..9da345ff1ed6 100644 --- a/uui/source/iahndl-ioexceptions.cxx +++ b/uui/source/iahndl-ioexceptions.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> +#include <comphelper/fileurl.hxx> #include "ids.hrc" @@ -80,9 +81,7 @@ getResourceNameRequestArgument(uno::Sequence< uno::Any > const & rArguments, if (!getStringRequestArgument(rArguments, "Uri", pValue)) return false; // Use the resource name only for file URLs, to avoid confusion: - //TODO! work with ucp locality concept instead of hardcoded "file"? - if (pValue - && pValue->matchIgnoreAsciiCase("file:")) + if (pValue && comphelper::isFileUrl(*pValue)) getStringRequestArgument(rArguments, "ResourceName", pValue); return true; } diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx index 044206698d66..8c1a10a82c26 100644 --- a/vcl/generic/print/genprnpsp.cxx +++ b/vcl/generic/print/genprnpsp.cxx @@ -36,6 +36,7 @@ # include <sys/stat.h> #endif +#include <comphelper/fileurl.hxx> #include "rtl/ustring.hxx" #include "vcl/button.hxx" @@ -1124,7 +1125,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo else osl_createTempFile( NULL, NULL, &aPDFUrl.pData ); // normalize to file URL - if( !aPDFUrl.startsWith( "file:" ) ) + if( !comphelper::isFileUrl(aPDFUrl) ) { // this is not a file URL, but it should // form it into a osl friendly file URL diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index 58fdbf9f4e9b..3882c4023824 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -19,6 +19,7 @@ #include <string> +#include <comphelper/fileurl.hxx> #include "rtl/ustrbuf.hxx" #include "osl/file.h" @@ -323,7 +324,7 @@ void AquaSalFrame::SetRepresentedURL( const OUString& i_rDocURL ) // #i113170# may not be the main thread if called from UNO API SalData::ensureThreadAutoreleasePool(); - if( i_rDocURL.startsWith( "file:" ) ) + if( comphelper::isFileUrl(i_rDocURL) ) { OUString aSysPath; osl_getSystemPathFromFileURL( i_rDocURL.pData, &aSysPath.pData ); diff --git a/xmlhelp/source/cxxhelp/provider/db.hxx b/xmlhelp/source/cxxhelp/provider/db.hxx index bdfaa38d84dd..1fc09e47f45d 100644 --- a/xmlhelp/source/cxxhelp/provider/db.hxx +++ b/xmlhelp/source/cxxhelp/provider/db.hxx @@ -20,7 +20,7 @@ #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_DB_HXX #include <com/sun/star/ucb/XSimpleFileAccess3.hpp> - +#include <comphelper/fileurl.hxx> #include <osl/diagnose.h> #include <rtl/string.hxx> #include <unordered_map> @@ -95,7 +95,7 @@ namespace helpdatafileproxy { , m_nItRead( -1 ) , m_iItPos( -1 ) { - OSL_ASSERT(rFileURL.startsWith("file:")); + OSL_ASSERT(comphelper::isFileUrl(rFileURL)); } ~Hdf() { releaseHashMap(); } |