[Libreoffice-commits] .: sfx2/source

Caolán McNamara caolan at kemper.freedesktop.org
Fri Jan 14 07:39:52 PST 2011


 sfx2/source/doc/docfile.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 3a991451cdff7ca92f4da84808abcf58ca26290e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 14 10:16:50 2011 +0000

    Resolves: rhbz#668057 lock sftp urls too

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index f76f878..44469f0 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -1006,6 +1006,16 @@ sal_Int8 SfxMedium::ShowLockedDocumentDialog( const uno::Sequence< ::rtl::OUStri
     return nResult;
 }
 
+namespace
+{
+    bool isSuitableProtocolForLocking(const String & rLogicName)
+    {
+        INetURLObject aUrl( rLogicName );
+        INetProtocol eProt = aUrl.GetProtocol();
+        return eProt == INET_PROT_FILE || eProt == INET_PROT_SFTP;
+    }
+}
+
 //------------------------------------------------------------------
 sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
 {
@@ -1076,8 +1086,8 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
             // do further checks only if the file not readonly in fs
             if ( !bContentReadonly )
             {
-                // the special file locking should be used only for file URLs
-                if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
+                // the special file locking should be used only for suitable URLs
+                if ( isSuitableProtocolForLocking( aLogicName ) )
                 {
 
                     // in case of storing the document should request the output before locking
@@ -1090,7 +1100,7 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
                     sal_Int8 bUIStatus = LOCK_UI_NOLOCK;
 
                     // check whether system file locking has been used, the default value is false
-                    sal_Bool bUseSystemLock = IsSystemFileLockingUsed();
+                    sal_Bool bUseSystemLock = ::utl::LocalFileHelper::IsLocalFile( 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


More information about the Libreoffice-commits mailing list