[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - include/sfx2 include/svl l10ntools/source offapi/com offapi/UnoApi_offapi.mk sfx2/source svl/source uui/AllLangResTarget_uui.mk uui/Library_uui.mk uui/source

Juergen Funk juergen.funk_ml at cib.de
Fri Feb 9 14:43:56 UTC 2018


 include/sfx2/docfile.hxx                                |    4 
 include/svl/documentlockfile.hxx                        |    3 
 l10ntools/source/gRun.sh                                |    2 
 offapi/UnoApi_offapi.mk                                 |    1 
 offapi/com/sun/star/document/LockFileCorruptRequest.idl |   43 ++++
 sfx2/source/doc/docfile.cxx                             |  148 ++++++++++------
 svl/source/misc/documentlockfile.cxx                    |    7 
 uui/AllLangResTarget_uui.mk                             |    1 
 uui/Library_uui.mk                                      |    1 
 uui/source/iahndl-locking.cxx                           |   42 +++-
 uui/source/iahndl.cxx                                   |    2 
 uui/source/iahndl.hxx                                   |    2 
 uui/source/ids.hrc                                      |   43 ++--
 uui/source/lockcorrupt.cxx                              |   44 ++++
 uui/source/lockcorrupt.hxx                              |   33 +++
 uui/source/lockcorrupt.src                              |   37 ++++
 uui/source/lockfailed.cxx                               |    5 
 uui/source/lockfailed.src                               |    6 
 18 files changed, 335 insertions(+), 89 deletions(-)

New commits:
commit e5dc12d37bfea357aeb6f71e876dd4f93833d1c9
Author: Juergen Funk <juergen.funk_ml at cib.de>
Date:   Wed Apr 12 11:26:10 2017 +0200

    tdf#106942 Wrong message when lock file is empty or corrupt
    
    1. Erase empty or corrupt lockfile, when reading it fails and
       skip "Locked Document Dialog" in that case
    2. Show Dialog (use LockFileIgnoreRequest -> LockFailedQueryBox)
       when create lock file is not possible.
       Two Dialogs:  "lock file create error" and
                     "empty lockfile is present"
       Set the document to read-only when creating lockfile is not
       possible. If lockfile is corrupt or empty, inform the user.
       They can interrupt loading the document or open it read-only,
       which also erases the corrupt lock file after closing
       the document
    3. Handling for the two Dialogs
       Use LockFileIgnoreRequst for create lockfile error and
       add a new LockFileCorruptRequest, (lock file is corrupt).
       Change and generate new messages for both dialogs in english
    
    Change-Id: I35c377f85b5113e8ffb89d83b9544b8ebc81d89f
    Reviewed-on: https://gerrit.libreoffice.org/36658
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/49468
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>

diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 7a4e34013195..3a9c8978774f 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -164,8 +164,10 @@ public:
     bool                IsStorage();
 
     enum class ShowLockResult { NoLock, Succeeded,Try };
-    ShowLockResult      ShowLockedDocumentDialog( const LockFileEntry& aData, bool bIsLoading, bool bOwnLock );
+    ShowLockResult      ShowLockedDocumentDialog( const LockFileEntry& aData, bool bIsLoading, bool bOwnLock, bool bHandleSysLocked);
     void                LockOrigFileOnDemand( bool bLoading, bool bNoUI );
+    enum class MessageDlg    { LockFileIgnore, LockFileCorrupt };
+    bool                ShowLockFileProblemDialog(MessageDlg nWhichDlg);
     void                DisableUnlockWebDAV( bool bDisableUnlockWebDAV = true );
     void                UnlockFile( bool bReleaseLockStream );
     /// Lets Transfer_Impl() not fsync the output file.
diff --git a/include/svl/documentlockfile.hxx b/include/svl/documentlockfile.hxx
index 98dde757cf7b..ec94f1f22dde 100644
--- a/include/svl/documentlockfile.hxx
+++ b/include/svl/documentlockfile.hxx
@@ -48,7 +48,10 @@ public:
     bool CreateOwnLockFile();
     LockFileEntry GetLockData();
     bool OverwriteOwnLockFile();
+    /// Delete the Lockfile, if current user is the owner
     void RemoveFile();
+    /// Only delete lockfile, disregarding ownership
+    void RemoveFileDirectly();
 
     static bool IsInteractionAllowed() { return m_bAllowInteraction; }
 };
diff --git a/l10ntools/source/gRun.sh b/l10ntools/source/gRun.sh
index e8a622cf9903..bf7ef98a27d7 100755
--- a/l10ntools/source/gRun.sh
+++ b/l10ntools/source/gRun.sh
@@ -490,7 +490,7 @@ ${MYCMD} --base sw/source/uibase/utlui --files attrdesc.src initui.src navipi.sr
 
 ${MYCMD} --files sw/source/uibase/wrtsh/wrtsh.src
 
-${MYCMD} --base uui/source --files alreadyopen.src filechanged.src ids.src lockfailed.src nameclashdlg.src openlocked.src passworddlg.src passworderrs.src trylater.src
+${MYCMD} --base uui/source --files alreadyopen.src filechanged.src ids.src lockfailed.src lockcorrupt.src nameclashdlg.src openlocked.src passworddlg.src passworderrs.src trylater.src
 
 ${MYCMD} --files vcl/source/edit/textundo.src
 
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index c53b2d938392..416d64faca88 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2199,6 +2199,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/document,\
 	FilterOptionsRequest \
 	LinkUpdateModes \
 	LockFileIgnoreRequest \
+	LockFileCorruptRequest \
 	LockedDocumentRequest \
 	LockedOnSavingRequest \
 	MacroExecMode \
diff --git a/offapi/com/sun/star/document/LockFileCorruptRequest.idl b/offapi/com/sun/star/document/LockFileCorruptRequest.idl
new file mode 100644
index 000000000000..7780414723e2
--- /dev/null
+++ b/offapi/com/sun/star/document/LockFileCorruptRequest.idl
@@ -0,0 +1,43 @@
+/* -*- 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 __com_sun_star_document_LockFileCorruptRequest_idl__
+#define __com_sun_star_document_LockFileCorruptRequest_idl__
+
+#include <com/sun/star/io/IOException.idl>
+#include <com/sun/star/beans/PropertyValue.idl>
+#include <com/sun/star/frame/XModel.idl>
+
+
+module com { module sun { module star { module document {
+
+/** Is used for interaction handle to query user's decision
+    when the lock file is corrupt.
+
+    @since OOo 5.5
+*/
+exception LockFileCorruptRequest : ::com::sun::star::io::IOException
+{
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 68f85eff772c..431f9d2e78dc 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/document/LockedDocumentRequest.hpp>
 #include <com/sun/star/document/OwnLockOnDocumentRequest.hpp>
 #include <com/sun/star/document/LockFileIgnoreRequest.hpp>
+#include <com/sun/star/document/LockFileCorruptRequest.hpp>
 #include <com/sun/star/document/ChangedByOthersRequest.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/embed/XTransactedObject.hpp>
@@ -123,6 +124,8 @@
 #include <officecfg/Office/Common.hxx>
 #include <comphelper/propertysequence.hxx>
 
+#include <com/sun/star/io/WrongFormatException.hpp>
+
 #include <memory>
 
 using namespace ::com::sun::star;
@@ -846,12 +849,12 @@ void SfxMedium::SetEncryptionDataToStorage_Impl()
 // not for some URL scheme belongs in UCB, not here.
 
 
-SfxMedium::ShowLockResult SfxMedium::ShowLockedDocumentDialog( const LockFileEntry& aData, bool bIsLoading, bool bOwnLock )
+SfxMedium::ShowLockResult SfxMedium::ShowLockedDocumentDialog( const LockFileEntry& aData, bool bIsLoading, bool bOwnLock, bool bHandleSysLocked )
 {
     ShowLockResult nResult = ShowLockResult::NoLock;
 
-    // tdf#92817: Simple check for empty lock file that needs to be deleted
-    if( aData[LockFileComponent::OOOUSERNAME].isEmpty() && aData[LockFileComponent::SYSUSERNAME].isEmpty() )
+    // tdf#92817: Simple check for empty lock file that needs to be deleted, when system locking is enabled
+    if( aData[LockFileComponent::OOOUSERNAME].isEmpty() && aData[LockFileComponent::SYSUSERNAME].isEmpty() && !bHandleSysLocked )
         bOwnLock=true;
 
     // show the interaction regarding the document opening
@@ -945,6 +948,51 @@ SfxMedium::ShowLockResult SfxMedium::ShowLockedDocumentDialog( const LockFileEnt
     return nResult;
 }
 
+
+bool SfxMedium::ShowLockFileProblemDialog(MessageDlg nWhichDlg)
+{
+    // system file locking is not active, ask user whether he wants to open the document without any locking
+    uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
+
+    if (xHandler.is())
+    {
+        ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl;
+
+        switch (nWhichDlg)
+        {
+            case MessageDlg::LockFileIgnore:
+                xIgnoreRequestImpl = new ::ucbhelper::InteractionRequest(uno::makeAny( document::LockFileIgnoreRequest() ));
+                break;
+            case MessageDlg::LockFileCorrupt:
+                xIgnoreRequestImpl = new ::ucbhelper::InteractionRequest(uno::makeAny( document::LockFileCorruptRequest() ));
+                break;
+        }
+
+        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations(2);
+        aContinuations[0] = new ::ucbhelper::InteractionAbort(xIgnoreRequestImpl.get());
+        aContinuations[1] = new ::ucbhelper::InteractionApprove(xIgnoreRequestImpl.get());
+        xIgnoreRequestImpl->setContinuations(aContinuations);
+
+        xHandler->handle(xIgnoreRequestImpl.get());
+
+        ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
+        bool bReadOnly = uno::Reference< task::XInteractionApprove >(xSelected.get(), uno::UNO_QUERY).is();
+
+        if (bReadOnly)
+        {
+            GetItemSet()->Put(SfxBoolItem(SID_DOC_READONLY, true));
+        }
+        else
+        {
+            SetError( ERRCODE_ABORT, OSL_LOG_PREFIX );
+        }
+
+        return bReadOnly;
+    }
+
+    return false;
+}
+
 namespace
 {
     bool isSuitableProtocolForLocking(const OUString & rLogicName)
@@ -1040,7 +1088,7 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI )
 
                             if ( !bResult && !bNoUI )
                             {
-                                bUIStatus = ShowLockedDocumentDialog( aLockData, bLoading, false );
+                                bUIStatus = ShowLockedDocumentDialog( aLockData, bLoading, false , false );
                             }
                         }
                         catch( ucb::InteractiveNetworkWriteException& )
@@ -1181,59 +1229,34 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI )
                         try
                         {
                             ::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName );
-                            if ( !bHandleSysLocked )
+                            bool  bIoErr = false;
+
+                            if (!bHandleSysLocked)
                             {
                                 try
                                 {
                                     bResult = aLockFile.CreateOwnLockFile();
                                 }
-                                catch ( const ucb::InteractiveIOException& e )
+                                catch (const ucb::InteractiveIOException&)
                                 {
-                                    // exception means that the lock file can not be successfully accessed
-                                    // in this case it should be ignored if system file locking is anyway active
-                                    if ( bUseSystemLock || !IsOOoLockFileUsed() )
+                                    if (bLoading && !bNoUI)
                                     {
-                                        bResult = true;
-                                        // take the ownership over the lock file
-                                        aLockFile.OverwriteOwnLockFile();
-                                    }
-                                    else if ( e.Code == IOErrorCode_INVALID_PARAMETER )
-                                    {
-                                        // system file locking is not active, ask user whether he wants to open the document without any locking
-                                        uno::Reference< task::XInteractionHandler > xHandler = GetInteractionHandler();
-
-                                        if ( xHandler.is() )
-                                        {
-                                            ::rtl::Reference< ::ucbhelper::InteractionRequest > xIgnoreRequestImpl
-                                                = new ::ucbhelper::InteractionRequest( uno::makeAny( document::LockFileIgnoreRequest() ) );
-
-                                            uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
-                                            aContinuations[0] = new ::ucbhelper::InteractionAbort( xIgnoreRequestImpl.get() );
-                                            aContinuations[1] = new ::ucbhelper::InteractionApprove( xIgnoreRequestImpl.get() );
-                                            xIgnoreRequestImpl->setContinuations( aContinuations );
-
-                                            xHandler->handle( xIgnoreRequestImpl.get() );
-
-                                            ::rtl::Reference< ::ucbhelper::InteractionContinuation > xSelected = xIgnoreRequestImpl->getSelection();
-                                            bResult = uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is();
-                                        }
+                                        bIoErr = true;
+                                        bResult = ShowLockFileProblemDialog(MessageDlg::LockFileIgnore);
                                     }
                                 }
-                                catch ( const uno::Exception& )
+                                catch (const uno::Exception&)
                                 {
-                                    // exception means that the lock file can not be successfully accessed
-                                    // in this case it should be ignored if system file locking is anyway active
-                                    if ( bUseSystemLock || !IsOOoLockFileUsed() )
+                                    if (bLoading && !bNoUI)
                                     {
-                                        bResult = true;
-                                        // take the ownership over the lock file
-                                        aLockFile.OverwriteOwnLockFile();
+                                        bIoErr = true;
+                                        bResult = ShowLockFileProblemDialog(MessageDlg::LockFileIgnore);
                                     }
                                 }
 
                                 // in case OOo locking is turned off the lock file is still written if possible
                                 // but it is ignored while deciding whether the document should be opened for editing or not
-                                if ( !bResult && !IsOOoLockFileUsed() )
+                                if (!bResult && !IsOOoLockFileUsed() && !bIoErr)
                                 {
                                     bResult = true;
                                     // take the ownership over the lock file
@@ -1241,46 +1264,54 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI )
                                 }
                             }
 
-
                             if ( !bResult )
                             {
                                 LockFileEntry aData;
                                 try
                                 {
-                                    // impossibility to get data is no real problem
                                     aData = aLockFile.GetLockData();
                                 }
+                                catch (const io::WrongFormatException&)
+                                {
+                                    // we get empty or corrupt data
+                                    // info to the user
+                                    if (!bIoErr && bLoading && !bNoUI )
+                                        bResult = ShowLockFileProblemDialog(MessageDlg::LockFileCorrupt);
+
+                                    // not show the Lock Document Dialog
+                                    bIoErr = true;
+                                }
                                 catch( const uno::Exception& )
                                 {
+                                    // show the Lock Document Dialog, when locked from other app
+                                    bIoErr = !bHandleSysLocked;
                                 }
 
                                 bool bOwnLock = false;
 
-                                if ( !bHandleSysLocked )
+                                if (!bHandleSysLocked)
                                 {
                                     LockFileEntry aOwnData = svt::LockFileCommon::GenerateOwnEntry();
-                                    bOwnLock = aOwnData[LockFileComponent::SYSUSERNAME].equals( aData[LockFileComponent::SYSUSERNAME] );
+                                    bOwnLock = aOwnData[LockFileComponent::SYSUSERNAME].equals(aData[LockFileComponent::SYSUSERNAME]);
 
-                                    if ( bOwnLock
-                                      && aOwnData[LockFileComponent::LOCALHOST].equals( aData[LockFileComponent::LOCALHOST] )
-                                      && aOwnData[LockFileComponent::USERURL].equals( aData[LockFileComponent::USERURL] ) )
+                                    if (bOwnLock
+                                        && aOwnData[LockFileComponent::LOCALHOST].equals(aData[LockFileComponent::LOCALHOST])
+                                        && aOwnData[LockFileComponent::USERURL].equals(aData[LockFileComponent::USERURL]))
                                     {
                                         // this is own lock from the same installation, it could remain because of crash
                                         bResult = true;
                                     }
                                 }
 
-                                if ( !bResult && !bNoUI )
+                                if ( !bResult && !bNoUI && !bIoErr)
                                 {
-                                    bUIStatus = ShowLockedDocumentDialog( aData, bLoading, bOwnLock );
+                                    bUIStatus = ShowLockedDocumentDialog( aData, bLoading, bOwnLock, bHandleSysLocked );
                                     if ( bUIStatus == ShowLockResult::Succeeded )
                                     {
                                         // take the ownership over the lock file
                                         bResult = aLockFile.OverwriteOwnLockFile();
                                     }
                                 }
-
-                                bHandleSysLocked = false;
                             }
                         }
                         catch( const uno::Exception& )
@@ -2798,13 +2829,24 @@ void SfxMedium::UnlockFile( bool bReleaseLockStream )
 
     if ( pImpl->m_bLocked )
     {
+        ::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName );
+
         try
         {
             pImpl->m_bLocked = false;
-            ::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName );
             // TODO/LATER: A warning could be shown in case the file is not the own one
             aLockFile.RemoveFile();
         }
+        catch( const io::WrongFormatException& )
+        {
+            try
+            {
+                // erase the empty or corrupt file
+                aLockFile.RemoveFileDirectly();
+            }
+            catch( const uno::Exception& )
+            {}
+        }
         catch( const uno::Exception& )
         {}
     }
diff --git a/svl/source/misc/documentlockfile.cxx b/svl/source/misc/documentlockfile.cxx
index 6dcd09b0ca62..d8c3fe1cd9c3 100644
--- a/svl/source/misc/documentlockfile.cxx
+++ b/svl/source/misc/documentlockfile.cxx
@@ -207,12 +207,19 @@ void DocumentLockFile::RemoveFile()
       || !aFileData[LockFileComponent::USERURL].equals( aNewEntry[LockFileComponent::USERURL] ) )
         throw io::IOException(); // not the owner, access denied
 
+    RemoveFileDirectly();
+}
+
+void DocumentLockFile::RemoveFileDirectly()
+{
     uno::Reference < css::ucb::XCommandEnvironment > xEnv;
     ::ucbhelper::Content aCnt(m_aURL, xEnv, comphelper::getProcessComponentContext());
     aCnt.executeCommand("delete",
         uno::makeAny(true));
 }
 
+
+
 } // namespace svt
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/AllLangResTarget_uui.mk b/uui/AllLangResTarget_uui.mk
index 2cd36571b0e8..fe59c93c6201 100644
--- a/uui/AllLangResTarget_uui.mk
+++ b/uui/AllLangResTarget_uui.mk
@@ -25,6 +25,7 @@ $(eval $(call gb_SrsTarget_add_files,uui/res,\
 	uui/source/filechanged.src \
 	uui/source/ids.src \
 	uui/source/lockfailed.src \
+	uui/source/lockcorrupt.src \
 	uui/source/nameclashdlg.src \
 	uui/source/openlocked.src \
 	uui/source/passworddlg.src \
diff --git a/uui/Library_uui.mk b/uui/Library_uui.mk
index c1054aa47a81..80eadf84cf1f 100644
--- a/uui/Library_uui.mk
+++ b/uui/Library_uui.mk
@@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,uui,\
 	uui/source/iahndl-ssl \
 	uui/source/interactionhandler \
 	uui/source/lockfailed \
+	uui/source/lockcorrupt \
 	uui/source/logindlg \
 	uui/source/masterpasscrtdlg \
 	uui/source/masterpassworddlg \
diff --git a/uui/source/iahndl-locking.cxx b/uui/source/iahndl-locking.cxx
index f3793819471a..48312637bb21 100644
--- a/uui/source/iahndl-locking.cxx
+++ b/uui/source/iahndl-locking.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/document/LockedDocumentRequest.hpp>
 #include <com/sun/star/document/LockedOnSavingRequest.hpp>
 #include <com/sun/star/document/LockFileIgnoreRequest.hpp>
+#include <com/sun/star/document/LockFileCorruptRequest.hpp>
 #include <com/sun/star/document/OwnLockOnDocumentRequest.hpp>
 #include <com/sun/star/task/XInteractionApprove.hpp>
 #include <com/sun/star/task/XInteractionDisapprove.hpp>
@@ -40,6 +41,7 @@
 #include "alreadyopen.hxx"
 #include "filechanged.hxx"
 #include "lockfailed.hxx"
+#include "lockcorrupt.hxx"
 
 #include "iahndl.hxx"
 
@@ -174,11 +176,16 @@ handleChangedByOthersRequest_(
     }
 }
 
+const sal_uInt16  UUI_DOC_CreateErrDlg  = 0;
+const sal_uInt16  UUI_DOC_CorruptErrDlg = 1;
+
+
+
 void
-handleLockFileIgnoreRequest_(
+handleLockFileProblemRequest_(
     vcl::Window * pParent,
     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
-        rContinuations )
+        rContinuations, sal_uInt16 nWhichDlg )
 {
     uno::Reference< task::XInteractionApprove > xApprove;
     uno::Reference< task::XInteractionAbort > xAbort;
@@ -194,8 +201,19 @@ handleLockFileIgnoreRequest_(
         if (!xManager.get())
             return;
 
-        ScopedVclPtrInstance< LockFailedQueryBox > xDialog(pParent, xManager.get());
-        sal_Int32 nResult = xDialog->Execute();
+        sal_Int32 nResult;
+
+        if (nWhichDlg == UUI_DOC_CreateErrDlg)
+        {
+            ScopedVclPtrInstance< LockFailedQueryBox > xDialog(pParent, xManager.get());
+            nResult = xDialog->Execute();
+        }
+        else
+        {
+            ScopedVclPtrInstance< LockCorruptQueryBox > xDialog(pParent, xManager.get());
+            nResult = xDialog->Execute();
+        }
+
 
         if ( nResult == RET_OK )
             xApprove->select();
@@ -269,8 +287,9 @@ UUIInteractionHelper::handleChangedByOthersRequest(
     return false;
 }
 
+
 bool
-UUIInteractionHelper::handleLockFileIgnoreRequest(
+UUIInteractionHelper::handleLockFileProblemRequest(
     uno::Reference< task::XInteractionRequest > const & rRequest)
 {
     uno::Any aAnyRequest(rRequest->getRequest());
@@ -278,10 +297,19 @@ UUIInteractionHelper::handleLockFileIgnoreRequest(
     document::LockFileIgnoreRequest aLockFileIgnoreRequest;
     if (aAnyRequest >>= aLockFileIgnoreRequest )
     {
-        handleLockFileIgnoreRequest_( getParentProperty(),
-                                      rRequest->getContinuations() );
+        handleLockFileProblemRequest_( getParentProperty(),
+                                      rRequest->getContinuations(), UUI_DOC_CreateErrDlg );
         return true;
     }
+
+    document::LockFileCorruptRequest aLockFileCorruptRequest;
+    if (aAnyRequest >>= aLockFileCorruptRequest )
+    {
+        handleLockFileProblemRequest_( getParentProperty(),
+                                      rRequest->getContinuations(), UUI_DOC_CorruptErrDlg );
+        return true;
+    }
+
     return false;
 }
 
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index e587a831e457..57ed634b24c1 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -822,7 +822,7 @@ UUIInteractionHelper::handleRequest_impl(
             if ( handleChangedByOthersRequest( rRequest ) )
                 return true;
 
-            if ( handleLockFileIgnoreRequest( rRequest ) )
+            if ( handleLockFileProblemRequest( rRequest ) )
                 return true;
 
             task::DocumentMacroConfirmationRequest aMacroConfirmRequest;
diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx
index 6543b345247f..1f4801314065 100644
--- a/uui/source/iahndl.hxx
+++ b/uui/source/iahndl.hxx
@@ -232,7 +232,7 @@ private:
         css::uno::Reference<
             css::task::XInteractionRequest > const & rRequest);
 
-    bool handleLockFileIgnoreRequest(
+    bool handleLockFileProblemRequest(
         css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
 
     bool handleCustomRequest(
diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc
index e70c7a84300d..d06457dbcbe2 100644
--- a/uui/source/ids.hrc
+++ b/uui/source/ids.hrc
@@ -47,27 +47,30 @@
 #define STR_ALREADYOPEN_OPEN_BTN                        (RID_UUI_START + 42)
 #define STR_LOCKFAILED_TITLE                            (RID_UUI_START + 43)
 #define STR_LOCKFAILED_MSG                              (RID_UUI_START + 44)
-#define STR_LOCKFAILED_DONTSHOWAGAIN                    (RID_UUI_START + 45)
-#define STR_TRYLATER_TITLE                              (RID_UUI_START + 46)
-#define STR_TRYLATER_MSG                                (RID_UUI_START + 47)
-#define STR_TRYLATER_RETRYSAVING_BTN                    (RID_UUI_START + 48)
-#define STR_TRYLATER_SAVEAS_BTN                         (RID_UUI_START + 49)
-#define STR_ALREADYOPEN_SAVE_MSG                        (RID_UUI_START + 50)
-#define STR_ALREADYOPEN_RETRY_SAVE_BTN                  (RID_UUI_START + 51)
-#define STR_ALREADYOPEN_SAVE_BTN                        (RID_UUI_START + 52)
+#define STR_LOCKFAILED_OPENREADONLY_BTN                 (RID_UUI_START + 45)
+#define STR_LOCKCORRUPT_TITLE                           (RID_UUI_START + 46)
+#define STR_LOCKCORRUPT_MSG                             (RID_UUI_START + 47)
+#define STR_LOCKCORRUPT_OPENREADONLY_BTN                (RID_UUI_START + 48)
+#define STR_TRYLATER_TITLE                              (RID_UUI_START + 49)
+#define STR_TRYLATER_MSG                                (RID_UUI_START + 50)
+#define STR_TRYLATER_RETRYSAVING_BTN                    (RID_UUI_START + 51)
+#define STR_TRYLATER_SAVEAS_BTN                         (RID_UUI_START + 52)
+#define STR_ALREADYOPEN_SAVE_MSG                        (RID_UUI_START + 53)
+#define STR_ALREADYOPEN_RETRY_SAVE_BTN                  (RID_UUI_START + 54)
+#define STR_ALREADYOPEN_SAVE_BTN                        (RID_UUI_START + 55)
 
-#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE         (RID_UUI_START + 54)
-#define STR_WARNING_BROKENSIGNATURE_TITLE               (RID_UUI_START + 55)
-#define STR_ENTER_PASSWORD_TO_OPEN                      (RID_UUI_START + 56)
-#define STR_ENTER_PASSWORD_TO_MODIFY                    (RID_UUI_START + 57)
-#define STR_RENAME_OR_REPLACE                           (RID_UUI_START + 58)
-#define STR_NAME_CLASH_RENAME_ONLY                      (RID_UUI_START + 59)
-#define STR_SAME_NAME_USED                              (RID_UUI_START + 60)
-#define STR_ENTER_SIMPLE_PASSWORD                       (RID_UUI_START + 61)
-#define STR_CONFIRM_SIMPLE_PASSWORD                     (RID_UUI_START + 62)
-#define STR_TITLE_CREATE_PASSWORD                       (RID_UUI_START + 63)
-#define STR_TITLE_ENTER_PASSWORD                        (RID_UUI_START + 64)
-#define STR_PASSWORD_MISMATCH                           (RID_UUI_START + 65)
+#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE         (RID_UUI_START + 56)
+#define STR_WARNING_BROKENSIGNATURE_TITLE               (RID_UUI_START + 57)
+#define STR_ENTER_PASSWORD_TO_OPEN                      (RID_UUI_START + 58)
+#define STR_ENTER_PASSWORD_TO_MODIFY                    (RID_UUI_START + 59)
+#define STR_RENAME_OR_REPLACE                           (RID_UUI_START + 60)
+#define STR_NAME_CLASH_RENAME_ONLY                      (RID_UUI_START + 61)
+#define STR_SAME_NAME_USED                              (RID_UUI_START + 62)
+#define STR_ENTER_SIMPLE_PASSWORD                       (RID_UUI_START + 63)
+#define STR_CONFIRM_SIMPLE_PASSWORD                     (RID_UUI_START + 64)
+#define STR_TITLE_CREATE_PASSWORD                       (RID_UUI_START + 65)
+#define STR_TITLE_ENTER_PASSWORD                        (RID_UUI_START + 66)
+#define STR_PASSWORD_MISMATCH                           (RID_UUI_START + 67)
 
 #define ERRCODE_UUI_IO_ABORT                                    (ERRCODE_AREA_UUI + 0)
 #define ERRCODE_UUI_IO_ACCESSDENIED                             (ERRCODE_AREA_UUI + 1)
diff --git a/uui/source/lockcorrupt.cxx b/uui/source/lockcorrupt.cxx
new file mode 100644
index 000000000000..a22ad863ccc0
--- /dev/null
+++ b/uui/source/lockcorrupt.cxx
@@ -0,0 +1,44 @@
+/* -*- 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 "ids.hrc"
+#include "lockcorrupt.hxx"
+
+#include <vcl/button.hxx>
+
+LockCorruptQueryBox::LockCorruptQueryBox( vcl::Window* pParent, ResMgr* pResMgr ) :
+    MessBox(pParent, 0,
+            ResId(STR_LOCKCORRUPT_TITLE, *pResMgr).toString(),
+            OUString() )
+{
+    SetImage( ErrorBox::GetStandardImage() );
+
+    AddButton(ResId(STR_LOCKCORRUPT_OPENREADONLY_BTN, *pResMgr).toString(), RET_OK,
+        ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
+
+    AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
+
+    SetMessText(ResId(STR_LOCKCORRUPT_MSG, *pResMgr ).toString());
+}
+
+LockCorruptQueryBox::~LockCorruptQueryBox()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/source/lockcorrupt.hxx b/uui/source/lockcorrupt.hxx
new file mode 100644
index 000000000000..b83d94084d8c
--- /dev/null
+++ b/uui/source/lockcorrupt.hxx
@@ -0,0 +1,33 @@
+/* -*- 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_UUI_SOURCE_LOCKCORRUPT_HXX
+#define INCLUDED_UUI_SOURCE_LOCKCORRUPT_HXX
+
+#include <vcl/msgbox.hxx>
+
+class LockCorruptQueryBox : public MessBox
+{
+public:
+    LockCorruptQueryBox( vcl::Window* pParent, ResMgr* pResMgr );
+    virtual ~LockCorruptQueryBox() override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/source/lockcorrupt.src b/uui/source/lockcorrupt.src
new file mode 100644
index 000000000000..e26535f3f925
--- /dev/null
+++ b/uui/source/lockcorrupt.src
@@ -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 .
+ */
+
+#define __RSC
+
+#include "ids.hrc"
+
+String STR_LOCKCORRUPT_TITLE
+{
+    Text [ en-US ] = "Lock file is corrupted";
+};
+String STR_LOCKCORRUPT_MSG
+{
+    Text [ en-US ] = "The lock file is corrupted and probably empty. Opening the document read-only and closing it again removes the corrupted lock file.";
+};
+String STR_LOCKCORRUPT_OPENREADONLY_BTN
+{
+    Text [ en-US ] = "Open ~Read-Only";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/source/lockfailed.cxx b/uui/source/lockfailed.cxx
index 77ceb7e8d625..63ad3a76f2a0 100644
--- a/uui/source/lockfailed.cxx
+++ b/uui/source/lockfailed.cxx
@@ -29,11 +29,12 @@ LockFailedQueryBox::LockFailedQueryBox( vcl::Window* pParent, ResMgr* pResMgr )
 {
     SetImage( ErrorBox::GetStandardImage() );
 
-    AddButton( StandardButtonType::OK, RET_OK, ButtonDialogFlags::OK );
+    AddButton(ResId(STR_LOCKFAILED_OPENREADONLY_BTN, *pResMgr).toString(), RET_OK,
+        ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
+
     AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
 
     SetMessText(ResId(STR_LOCKFAILED_MSG, *pResMgr ).toString());
-    SetCheckBoxText(ResId(STR_LOCKFAILED_DONTSHOWAGAIN, *pResMgr).toString());
 }
 
 LockFailedQueryBox::~LockFailedQueryBox()
diff --git a/uui/source/lockfailed.src b/uui/source/lockfailed.src
index 2384e43e0ed7..5eeba410e23f 100644
--- a/uui/source/lockfailed.src
+++ b/uui/source/lockfailed.src
@@ -27,11 +27,11 @@ String STR_LOCKFAILED_TITLE
 };
 String STR_LOCKFAILED_MSG
 {
-    Text [ en-US ] = "The file could not be locked for exclusive access by %PRODUCTNAME, due to missing permission to create a lock file on that file location.";
+    Text [ en-US ] = "The lock file could not be created for exclusive access by %PRODUCTNAME, due to missing permission to create a lock file on that file location or lack of free disk space.";
 };
-String STR_LOCKFAILED_DONTSHOWAGAIN
+String STR_LOCKFAILED_OPENREADONLY_BTN
 {
-    Text [ en-US ] = "~Do not show this message again";
+    Text [ en-US ] = "Open ~Read-Only";
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list