[Libreoffice-commits] core.git: filter/source include/unotools sfx2/source unotools/source
Stephan Bergmann
sbergman at redhat.com
Wed Aug 19 00:13:56 PDT 2015
filter/source/config/cache/typedetection.cxx | 2 +-
include/unotools/localfilehelper.hxx | 2 +-
sfx2/source/dialog/filedlghelper.cxx | 3 +--
sfx2/source/doc/docfile.cxx | 19 ++++++++++---------
sfx2/source/doc/objcont.cxx | 4 ++--
unotools/source/ucbhelper/localfilehelper.cxx | 5 ++---
6 files changed, 17 insertions(+), 18 deletions(-)
New commits:
commit 6d64afb31eefcbd8f1413aa30d952338e35771e4
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Aug 19 09:06:21 2015 +0200
Replace utl::LocalFileHelper::IsLocalFile -> ...::IsFileUrl
...given that vnd.sun.star.wfs is long gone. Note that the old code could have
behaved differently in that for one it could have worked for relative URL input
(as osl_getSystemPathFromFileURL is allowed to accept relative URLs) and for
another could have failed for some file URLs (for which
osl_getSystemPathFromFileURL would return something other than osl_File_E_None
for whatever reason), but it looks plausible to assume that what the call sites
are really interested in is whether a given URL is a file URL.
Simplifies those call sites that already have a INetURLObject instance even
further.
Change-Id: Iaee4595d933a760b8321e42414a9ef0865311833
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index af80416..42b609c 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -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 ( !sURL.isEmpty() && ::utl::LocalFileHelper::IsLocalFile( INetURLObject( sURL ).GetMainURL( INetURLObject::NO_DECODE ) ) )
+ if ( utl::LocalFileHelper::IsFileUrl( sURL ) )
{
// OOo uses own file locking mechanics in case of local file
bSuccess = rDescriptor.addInputStreamOwnLock();
diff --git a/include/unotools/localfilehelper.hxx b/include/unotools/localfilehelper.hxx
index 8d93bf0..d53115b 100644
--- a/include/unotools/localfilehelper.hxx
+++ b/include/unotools/localfilehelper.hxx
@@ -44,7 +44,7 @@ namespace utl
*/
static bool ConvertURLToPhysicalName( const OUString& rName, OUString& rReturn );
- static bool IsLocalFile(const OUString& rName);
+ static bool IsFileUrl(const OUString& rUrl);
static ::com::sun::star::uno::Sequence< OUString >
GetFolderContents( const OUString& rFolder, bool bFolder );
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 2ed3a4b..464b098 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1963,8 +1963,7 @@ void FileDialogHelper_Impl::saveConfig()
if ( ! mbIsSaveDlg )
{
OUString aPath = getPath();
- if ( !aPath.isEmpty() &&
- utl::LocalFileHelper::IsLocalFile( aPath ) )
+ if ( utl::LocalFileHelper::IsFileUrl( aPath ) )
{
SetToken( aUserData, 1, ' ', aPath );
bWriteConfig = true;
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 845ed0e..e04b3ce 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -383,7 +383,7 @@ void SfxMedium::CheckFileDate( const util::DateTime& aInitDate )
bool SfxMedium::DocNeedsFileDateCheck() const
{
- return ( !IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
+ return !IsReadOnly() && GetURLObject().GetProtocol() == INetProtocol::File;
}
util::DateTime SfxMedium::GetInitFileDate( bool bIgnoreOldValue )
@@ -733,7 +733,7 @@ void SfxMedium::StorageBackup_Impl()
bool bBasedOnOriginalFile = ( !pImp->pTempFile && !( !pImp->m_aLogicName.isEmpty() && pImp->m_bSalvageMode )
&& !GetURLObject().GetMainURL( INetURLObject::NO_DECODE ).isEmpty()
- && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
+ && GetURLObject().GetProtocol() == INetProtocol::File
&& ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) );
if ( bBasedOnOriginalFile && pImp->m_aBackupURL.isEmpty()
@@ -948,7 +948,8 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI )
try
{
- if ( pImp->m_bLocked && bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
+ if ( pImp->m_bLocked && bLoading
+ && GetURLObject().GetProtocol() == INetProtocol::File )
{
// if the document is already locked the system locking might be temporarely off after storing
// check whether the system file locking should be taken again
@@ -967,7 +968,7 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI )
if ( !bResult && !IsReadOnly() )
{
bool bContentReadonly = false;
- if ( bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
+ if ( bLoading && GetURLObject().GetProtocol() == INetProtocol::File )
{
// let the original document be opened to check the possibility to open it for editing
// and to let the writable stream stay open to hold the lock on the document
@@ -1024,7 +1025,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::IsLocalFile( pImp->m_aLogicName ) && IsSystemFileLockingUsed();
+ bool bUseSystemLock = ::utl::LocalFileHelper::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
@@ -1857,7 +1858,7 @@ void SfxMedium::Transfer_Impl()
OUString aDestURL( aDest.GetMainURL( INetURLObject::NO_DECODE ) );
- if ( ::utl::LocalFileHelper::IsLocalFile( aDestURL ) || !aDest.removeSegment() )
+ if ( ::utl::LocalFileHelper::IsFileUrl( aDestURL ) || !aDest.removeSegment() )
{
TransactedTransferForFS_Impl( aSource, aDest, xComEnv );
@@ -2180,7 +2181,7 @@ void SfxMedium::ClearBackup_Impl()
void SfxMedium::GetLockingStream_Impl()
{
- if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
+ if ( GetURLObject().GetProtocol() == INetProtocol::File
&& !pImp->m_xLockingStream.is() )
{
SFX_ITEMSET_ARG( pImp->m_pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, false);
@@ -2293,7 +2294,7 @@ void SfxMedium::GetMedium_Impl()
aMedium.erase( utl::MediaDescriptor::PROP_READONLY() );
aMedium.addInputStream();
}
- else if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
+ else if ( GetURLObject().GetProtocol() == INetProtocol::File )
{
// use the special locking approach only for file URLs
aMedium.addInputStreamOwnLock();
@@ -3254,7 +3255,7 @@ void SfxMedium::CreateTempFile( bool bReplace )
bool bTransferSuccess = false;
if ( GetContent().is()
- && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
+ && GetURLObject().GetProtocol() == INetProtocol::File
&& ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
{
// if there is already such a document, we should copy it
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 53fd6f2..6ed6fe8 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -387,7 +387,7 @@ void SfxObjectShell::UpdateFromTemplate_Impl( )
if ( !pFile )
return;
- if ( !::utl::LocalFileHelper::IsLocalFile( pFile->GetName() ) )
+ if ( !::utl::LocalFileHelper::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::IsLocalFile( rFileName ) )
+ if( ::utl::LocalFileHelper::IsFileUrl( rFileName ) )
{
OUString aFoundName;
if( SfxGetpApp()->Get_Impl()->GetDocumentTemplates()->GetFull( OUString(), rTemplateName, aFoundName ) )
diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx
index 52fb373..bf46273 100644
--- a/unotools/source/ucbhelper/localfilehelper.cxx
+++ b/unotools/source/ucbhelper/localfilehelper.cxx
@@ -56,10 +56,9 @@ bool LocalFileHelper::ConvertURLToPhysicalName(const OUString& rName, OUString&
return ok;
}
-bool LocalFileHelper::IsLocalFile(const OUString& rName)
+bool LocalFileHelper::IsFileUrl(const OUString& rUrl)
{
- OUString aTmp;
- return ConvertURLToPhysicalName(rName, aTmp);
+ return rUrl.startsWithIgnoreAsciiCase("file:");
}
typedef ::std::vector< OUString* > StringList_Impl;
More information about the Libreoffice-commits
mailing list