summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-02-08 18:06:06 +0300
committerAron Budea <aron.budea@collabora.com>2018-02-09 15:44:10 +0100
commite189dd061bb0817e1f9e872c9b8dc82b72bfffc5 (patch)
tree0dcd15c79b7fc00208fa22d33d31dcfd540cf3d9 /uui
parent6c5af47fc25aecc624e68af174c7e1d9ca2392f9 (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> Reviewed-on: https://gerrit.libreoffice.org/49470 Reviewed-by: Aron Budea <aron.budea@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'uui')
-rw-r--r--uui/source/iahndl-locking.cxx13
-rw-r--r--uui/source/iahndl.cxx9
-rw-r--r--uui/source/ids.hrc69
-rw-r--r--uui/source/openlocked.cxx22
-rw-r--r--uui/source/openlocked.hxx2
-rw-r--r--uui/source/openlocked.src6
6 files changed, 67 insertions, 54 deletions
diff --git a/uui/source/iahndl-locking.cxx b/uui/source/iahndl-locking.cxx
index 48312637bb21..d1c00706d769 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 <osl/mutex.hxx>
#include <vcl/svapp.hxx>
@@ -68,7 +69,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;
@@ -91,11 +94,15 @@ handleLockedDocumentRequest_(
? aInfo
: ResId( STR_UNKNOWNUSER,
*xManager.get() ).toString() );
+ aArguments.push_back( xRetry.is()
+ ? ResId( STR_OPENLOCKED_ALLOWIGNORE_MSG,
+ *xManager.get() ).toString()
+ : "" );
aMessage = ResId(STR_OPENLOCKED_MSG, *xManager.get()).toString();
aMessage = UUIInteractionHelper::replaceMessageWithArguments(
aMessage, aArguments );
- ScopedVclPtrInstance< OpenLockedQueryBox > xDialog(pParent, xManager.get(), aMessage);
+ ScopedVclPtrInstance< OpenLockedQueryBox > xDialog(pParent, xManager.get(), aMessage, xRetry.is());
nResult = xDialog->Execute();
}
else if ( nMode == UUI_DOC_SAVE_LOCK )
@@ -133,6 +140,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 57ed634b24c1..f98757d89fd2 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -244,10 +244,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/ids.hrc b/uui/source/ids.hrc
index d06457dbcbe2..d3f2a80f2d59 100644
--- a/uui/source/ids.hrc
+++ b/uui/source/ids.hrc
@@ -36,41 +36,42 @@
#define STR_UNKNOWNUSER (RID_UUI_START + 31)
#define STR_OPENLOCKED_TITLE (RID_UUI_START + 32)
#define STR_OPENLOCKED_MSG (RID_UUI_START + 33)
-#define STR_OPENLOCKED_OPENREADONLY_BTN (RID_UUI_START + 34)
-#define STR_OPENLOCKED_OPENCOPY_BTN (RID_UUI_START + 35)
-#define STR_FILECHANGED_TITLE (RID_UUI_START + 36)
-#define STR_FILECHANGED_MSG (RID_UUI_START + 37)
-#define STR_FILECHANGED_SAVEANYWAY_BTN (RID_UUI_START + 38)
-#define STR_ALREADYOPEN_TITLE (RID_UUI_START + 39)
-#define STR_ALREADYOPEN_MSG (RID_UUI_START + 40)
-#define STR_ALREADYOPEN_READONLY_BTN (RID_UUI_START + 41)
-#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_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_OPENLOCKED_ALLOWIGNORE_MSG (RID_UUI_START + 34)
+#define STR_OPENLOCKED_OPENREADONLY_BTN (RID_UUI_START + 35)
+#define STR_OPENLOCKED_OPENCOPY_BTN (RID_UUI_START + 36)
+#define STR_FILECHANGED_TITLE (RID_UUI_START + 37)
+#define STR_FILECHANGED_MSG (RID_UUI_START + 38)
+#define STR_FILECHANGED_SAVEANYWAY_BTN (RID_UUI_START + 39)
+#define STR_ALREADYOPEN_TITLE (RID_UUI_START + 40)
+#define STR_ALREADYOPEN_MSG (RID_UUI_START + 41)
+#define STR_ALREADYOPEN_READONLY_BTN (RID_UUI_START + 42)
+#define STR_ALREADYOPEN_OPEN_BTN (RID_UUI_START + 43)
+#define STR_LOCKFAILED_TITLE (RID_UUI_START + 44)
+#define STR_LOCKFAILED_MSG (RID_UUI_START + 45)
+#define STR_LOCKFAILED_OPENREADONLY_BTN (RID_UUI_START + 46)
+#define STR_LOCKCORRUPT_TITLE (RID_UUI_START + 47)
+#define STR_LOCKCORRUPT_MSG (RID_UUI_START + 48)
+#define STR_LOCKCORRUPT_OPENREADONLY_BTN (RID_UUI_START + 49)
+#define STR_TRYLATER_TITLE (RID_UUI_START + 50)
+#define STR_TRYLATER_MSG (RID_UUI_START + 51)
+#define STR_TRYLATER_RETRYSAVING_BTN (RID_UUI_START + 52)
+#define STR_TRYLATER_SAVEAS_BTN (RID_UUI_START + 53)
+#define STR_ALREADYOPEN_SAVE_MSG (RID_UUI_START + 54)
+#define STR_ALREADYOPEN_RETRY_SAVE_BTN (RID_UUI_START + 55)
+#define STR_ALREADYOPEN_SAVE_BTN (RID_UUI_START + 56)
-#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 STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE (RID_UUI_START + 57)
+#define STR_WARNING_BROKENSIGNATURE_TITLE (RID_UUI_START + 58)
+#define STR_ENTER_PASSWORD_TO_OPEN (RID_UUI_START + 59)
+#define STR_ENTER_PASSWORD_TO_MODIFY (RID_UUI_START + 60)
+#define STR_RENAME_OR_REPLACE (RID_UUI_START + 61)
+#define STR_NAME_CLASH_RENAME_ONLY (RID_UUI_START + 62)
+#define STR_SAME_NAME_USED (RID_UUI_START + 63)
+#define STR_ENTER_SIMPLE_PASSWORD (RID_UUI_START + 64)
+#define STR_CONFIRM_SIMPLE_PASSWORD (RID_UUI_START + 65)
+#define STR_TITLE_CREATE_PASSWORD (RID_UUI_START + 66)
+#define STR_TITLE_ENTER_PASSWORD (RID_UUI_START + 67)
+#define STR_PASSWORD_MISMATCH (RID_UUI_START + 68)
#define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0)
#define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1)
diff --git a/uui/source/openlocked.cxx b/uui/source/openlocked.cxx
index 4de71b54c2ca..90d7ad8bff68 100644
--- a/uui/source/openlocked.cxx
+++ b/uui/source/openlocked.cxx
@@ -20,7 +20,7 @@
#include "ids.hrc"
#include "openlocked.hxx"
-OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, ResMgr* pResMgr, const OUString& aMessage ) :
+OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, ResMgr* pResMgr, const OUString& aMessage, bool bEnableOverride ) :
MessBox(pParent, 0,
ResId(STR_OPENLOCKED_TITLE, *pResMgr).toString(),
aMessage )
@@ -29,21 +29,19 @@ OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, ResMgr* pResMgr, c
AddButton(ResId(STR_OPENLOCKED_OPENREADONLY_BTN, *pResMgr).toString(), RET_YES,
ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
+ SetButtonHelpText(RET_YES, OUString());
AddButton(ResId(STR_OPENLOCKED_OPENCOPY_BTN, *pResMgr).toString(), RET_NO);
+ SetButtonHelpText(RET_NO, OUString());
+
+ if (bEnableOverride)
+ {
+ // Present option to ignore the (stale?) lock file and open the document
+ AddButton(ResId(STR_ALREADYOPEN_OPEN_BTN, *pResMgr).toString(), RET_IGNORE);
+ SetButtonHelpText(RET_IGNORE, OUString());
+ }
AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
- SetButtonHelpText( RET_YES, OUString() );
- SetButtonHelpText( RET_NO, OUString() );
-
-#ifdef _WIN32
- // bnc#656566
- // Yes, it is silly to do this only for this dialog but not the
- // other similar ones. But hey, it was about this dialog that the
- // customer complained. You who read this and feel the itch, feel
- // free to fix the problem in a better way.
- EnableAlwaysOnTop();
-#endif
}
OpenLockedQueryBox::~OpenLockedQueryBox()
diff --git a/uui/source/openlocked.hxx b/uui/source/openlocked.hxx
index 40c50e403e00..73c435fa6c11 100644
--- a/uui/source/openlocked.hxx
+++ b/uui/source/openlocked.hxx
@@ -24,7 +24,7 @@
class OpenLockedQueryBox : public MessBox
{
public:
- OpenLockedQueryBox( vcl::Window* pParent, ResMgr* pResMgr, const OUString& aMessage );
+ OpenLockedQueryBox( vcl::Window* pParent, ResMgr* pResMgr, const OUString& aMessage, bool bEnableOverride );
virtual ~OpenLockedQueryBox() override;
};
diff --git a/uui/source/openlocked.src b/uui/source/openlocked.src
index 8aee0a643bf9..d0069ce97ee6 100644
--- a/uui/source/openlocked.src
+++ b/uui/source/openlocked.src
@@ -27,7 +27,11 @@ String STR_OPENLOCKED_TITLE
};
String STR_OPENLOCKED_MSG
{
- Text [ en-US ] = "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";
+ Text [ en-US ] = "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)";
+};
+String STR_OPENLOCKED_ALLOWIGNORE_MSG
+{
+ Text [ en-US ] = "You may also ignore the file locking and open the document for editing.\n\n";
};
String STR_OPENLOCKED_OPENREADONLY_BTN
{