summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-02-08 18:06:06 +0300
committerAndras Timar <andras.timar@collabora.com>2018-03-25 18:28:35 +0200
commit32e187572335e6490b356d2535c0c6792094a023 (patch)
tree05e59e4f1aa115c447bc5f807c6f7264e829e45d /uui
parent318f4e7d06681a664e7cb52589f130fa5628a350 (diff)
tdf#108210: Allow to ignore a lock file if there's no filesystem lock
Two cases are handled: when a file is being opened, and when it was opened read-only already, and one tries to reopen it in edit mode. The option to ignore locking and open the file anyway is only offered when there is no filesystem lock present on the file. Change-Id: I377d3cae4c949ae64d449634acea8fb3f68a5700 Reviewed-on: https://gerrit.libreoffice.org/49448 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 2a7057250c8f73fdfb4c65a7525d17e9770459df)
Diffstat (limited to 'uui')
-rw-r--r--uui/inc/strings.hrc3
-rw-r--r--uui/source/iahndl-locking.cxx12
-rw-r--r--uui/source/iahndl.cxx9
-rw-r--r--uui/source/openlocked.cxx14
-rw-r--r--uui/source/openlocked.hxx2
5 files changed, 28 insertions, 12 deletions
diff --git a/uui/inc/strings.hrc b/uui/inc/strings.hrc
index 760402c1d57b..590a582eba06 100644
--- a/uui/inc/strings.hrc
+++ b/uui/inc/strings.hrc
@@ -47,7 +47,8 @@
#define STR_LOCKFAILED_OPENREADONLY_BTN NC_("STR_LOCKFAILED_OPENREADONLY_BTN", "Open ~Read-Only")
#define STR_OPENLOCKED_TITLE NC_("STR_OPENLOCKED_TITLE", "Document in Use")
-#define STR_OPENLOCKED_MSG NC_("STR_OPENLOCKED_MSG", "Document file '$(ARG1)' is locked for editing by:\n\n$(ARG2)\n\nOpen document read-only or open a copy of the document for editing.\n\n")
+#define STR_OPENLOCKED_MSG NC_("STR_OPENLOCKED_MSG", "Document file '$(ARG1)' is locked for editing by:\n\n$(ARG2)\n\nOpen document read-only or open a copy of the document for editing.\n\n$(ARG3)")
+#define STR_OPENLOCKED_ALLOWIGNORE_MSG NC_("STR_OPENLOCKED_ALLOWIGNORE_MSG", "You may also ignore the file locking and open the document for editing.\n\n")
#define STR_OPENLOCKED_OPENREADONLY_BTN NC_("STR_OPENLOCKED_OPENREADONLY_BTN", "Open ~Read-Only")
#define STR_OPENLOCKED_OPENCOPY_BTN NC_("STR_OPENLOCKED_OPENCOPY_BTN", "Open ~Copy")
#define STR_UNKNOWNUSER NC_("STR_UNKNOWNUSER", "Unknown User")
diff --git a/uui/source/iahndl-locking.cxx b/uui/source/iahndl-locking.cxx
index 53b0e6a2fc77..08b5b5c7fd99 100644
--- a/uui/source/iahndl-locking.cxx
+++ b/uui/source/iahndl-locking.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/task/XInteractionDisapprove.hpp>
#include <com/sun/star/task/XInteractionAbort.hpp>
#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/task/XInteractionRetry.hpp>
#include <unotools/resmgr.hxx>
#include <vcl/svapp.hxx>
@@ -66,7 +67,9 @@ handleLockedDocumentRequest_(
uno::Reference< task::XInteractionApprove > xApprove;
uno::Reference< task::XInteractionDisapprove > xDisapprove;
uno::Reference< task::XInteractionAbort > xAbort;
- getContinuations(rContinuations, &xApprove, &xDisapprove, &xAbort);
+ // In case an option to ignore lock and open the file is available
+ uno::Reference< task::XInteractionRetry > xRetry;
+ getContinuations(rContinuations, &xApprove, &xDisapprove, &xAbort, &xRetry);
if ( !xApprove.is() || !xDisapprove.is() || !xAbort.is() )
return;
@@ -86,11 +89,14 @@ handleLockedDocumentRequest_(
aArguments.push_back( !aInfo.isEmpty()
? aInfo
: Translate::get( STR_UNKNOWNUSER, aResLocale) );
+ aArguments.push_back( xRetry.is()
+ ? Translate::get( STR_OPENLOCKED_ALLOWIGNORE_MSG, aResLocale )
+ : "" );
aMessage = Translate::get(STR_OPENLOCKED_MSG, aResLocale);
aMessage = UUIInteractionHelper::replaceMessageWithArguments(
aMessage, aArguments );
- ScopedVclPtrInstance< OpenLockedQueryBox > xDialog(pParent, aResLocale, aMessage);
+ ScopedVclPtrInstance< OpenLockedQueryBox > xDialog(pParent, aResLocale, aMessage, xRetry.is());
nResult = xDialog->Execute();
}
else if ( nMode == UUI_DOC_SAVE_LOCK )
@@ -128,6 +134,8 @@ handleLockedDocumentRequest_(
xApprove->select();
else if ( nResult == RET_NO )
xDisapprove->select();
+ else if ( nResult == RET_IGNORE && xRetry.is() )
+ xRetry->select();
else
xAbort->select();
}
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 67f28e089e51..2d7be0930178 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -246,10 +246,11 @@ UUIInteractionHelper::replaceMessageWithArguments(
OUString aMessage = _aMessage;
SAL_WARN_IF(rArguments.size() == 0, "uui", "replaceMessageWithArguments: No arguments passed!");
- if (rArguments.size() > 0)
- aMessage = aMessage.replaceAll("$(ARG1)", rArguments[0]);
- if (rArguments.size() > 1)
- aMessage = aMessage.replaceAll("$(ARG2)", rArguments[1]);
+ for (size_t i = 0; i < rArguments.size(); ++i)
+ {
+ const OUString sReplaceTemplate = "$(ARG" + OUString::number(i+1) + ")";
+ aMessage = aMessage.replaceAll(sReplaceTemplate, rArguments[i]);
+ }
return aMessage;
}
diff --git a/uui/source/openlocked.cxx b/uui/source/openlocked.cxx
index 074242b964b8..3267610b78d1 100644
--- a/uui/source/openlocked.cxx
+++ b/uui/source/openlocked.cxx
@@ -21,7 +21,7 @@
#include "openlocked.hxx"
#include <unotools/resmgr.hxx>
-OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage ) :
+OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage, bool bEnableOverride ) :
MessBox(pParent, MessBoxStyle::NONE, 0,
Translate::get(STR_OPENLOCKED_TITLE, rResLocale),
aMessage )
@@ -30,13 +30,19 @@ OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, const std::locale&
AddButton(Translate::get(STR_OPENLOCKED_OPENREADONLY_BTN, rResLocale), RET_YES,
ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
+ SetButtonHelpText(RET_YES, OUString());
AddButton(Translate::get(STR_OPENLOCKED_OPENCOPY_BTN, rResLocale), RET_NO);
+ SetButtonHelpText(RET_NO, OUString());
- AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
- SetButtonHelpText( RET_YES, OUString() );
- SetButtonHelpText( RET_NO, OUString() );
+ if (bEnableOverride)
+ {
+ // Present option to ignore the (stale?) lock file and open the document
+ AddButton(Translate::get(STR_ALREADYOPEN_OPEN_BTN, rResLocale), RET_IGNORE);
+ SetButtonHelpText(RET_IGNORE, OUString());
+ }
+ AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
}
OpenLockedQueryBox::~OpenLockedQueryBox()
diff --git a/uui/source/openlocked.hxx b/uui/source/openlocked.hxx
index 8584c45c2c7e..bb80a3c64146 100644
--- a/uui/source/openlocked.hxx
+++ b/uui/source/openlocked.hxx
@@ -24,7 +24,7 @@
class OpenLockedQueryBox : public MessBox
{
public:
- OpenLockedQueryBox(vcl::Window* pParent, const std::locale& rResLocale, const OUString& rMessage);
+ OpenLockedQueryBox(vcl::Window* pParent, const std::locale& rResLocale, const OUString& rMessage, bool bEnableOverride);
virtual ~OpenLockedQueryBox() override;
};