summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-02-21 00:45:04 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-02-26 20:44:54 +0100
commita30f8c4daaab5bfc850c18b2b0bce3fdb2281a1f (patch)
tree298de6ac22a862775fb4aaf675281b138c5246ac /uui
parent5a1fabb9969772242f2c2aef34b10bed17adebb6 (diff)
tdf#115742: allow ignoring stale lockfile on save
This change reuses TryLaterQueryBox, but only uses the new option to ignore the lock and save. Other options ("Try Again" and "Save As") are not used, because this functionality is not implemented currently (TODO/LATER). Change-Id: Idf825be23cf97d2b338c0cf5d532f8460843bf48 Reviewed-on: https://gerrit.libreoffice.org/50371 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'uui')
-rw-r--r--uui/inc/strings.hrc1
-rw-r--r--uui/source/iahndl-locking.cxx5
-rw-r--r--uui/source/trylater.cxx29
-rw-r--r--uui/source/trylater.hxx2
4 files changed, 27 insertions, 10 deletions
diff --git a/uui/inc/strings.hrc b/uui/inc/strings.hrc
index 590a582eba06..a47412520bca 100644
--- a/uui/inc/strings.hrc
+++ b/uui/inc/strings.hrc
@@ -59,6 +59,7 @@
#define STR_TRYLATER_TITLE NC_("STR_TRYLATER_TITLE", "Document in Use")
#define STR_TRYLATER_MSG NC_("STR_TRYLATER_MSG", "Document file '$(ARG1)' is locked for editing by:\n\n$(ARG2)\n\nTry again later to save document or save a copy of that document.\n\n")
+#define STR_OVERWRITE_IGNORELOCK_MSG NC_("STR_OVERWRITE_IGNORELOCK_MSG", "Document file '$(ARG1)' is locked for editing by:\n\n$(ARG2)\n\nYou may try to ignore the file locking and overwrite the existing document.\n\n")
#define STR_TRYLATER_RETRYSAVING_BTN NC_("STR_TRYLATER_RETRYSAVING_BTN", "~Retry Saving")
#define STR_TRYLATER_SAVEAS_BTN NC_("STR_TRYLATER_SAVEAS_BTN", "~Save As...")
diff --git a/uui/source/iahndl-locking.cxx b/uui/source/iahndl-locking.cxx
index 08b5b5c7fd99..ecd49ea55baf 100644
--- a/uui/source/iahndl-locking.cxx
+++ b/uui/source/iahndl-locking.cxx
@@ -105,11 +105,12 @@ handleLockedDocumentRequest_(
? aInfo
: Translate::get( STR_UNKNOWNUSER,
aResLocale ) );
- aMessage = Translate::get(STR_TRYLATER_MSG, aResLocale);
+ aMessage = Translate::get(xRetry.is() ? STR_OVERWRITE_IGNORELOCK_MSG : STR_TRYLATER_MSG,
+ aResLocale);
aMessage = UUIInteractionHelper::replaceMessageWithArguments(
aMessage, aArguments );
- ScopedVclPtrInstance< TryLaterQueryBox > xDialog(pParent, aResLocale, aMessage);
+ ScopedVclPtrInstance< TryLaterQueryBox > xDialog(pParent, aResLocale, aMessage, xRetry.is());
nResult = xDialog->Execute();
}
else if ( nMode == UUI_DOC_OWN_LOAD_LOCK ||
diff --git a/uui/source/trylater.cxx b/uui/source/trylater.cxx
index aa9bc08cf603..cacc68bc7d7c 100644
--- a/uui/source/trylater.cxx
+++ b/uui/source/trylater.cxx
@@ -21,18 +21,33 @@
#include <strings.hrc>
#include "trylater.hxx"
-TryLaterQueryBox::TryLaterQueryBox(vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage)
+TryLaterQueryBox::TryLaterQueryBox(vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage, bool bEnableOverride)
: MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_TRYLATER_TITLE, rResLocale), aMessage)
{
SetImage(GetStandardQueryBoxImage());
- AddButton(Translate::get(STR_TRYLATER_RETRYSAVING_BTN, rResLocale), RET_YES,
- ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
- AddButton(Translate::get(STR_TRYLATER_SAVEAS_BTN, rResLocale), RET_NO);
- AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
+ // Currently we don't have the retry/save-as functionality implemented for cases when file is locked.
+ // So threat them mutually exclusive with overwrite here. TODO/LATER: just add the overwrite option
+ // as third option when retrying and saving with another name would be possible along with overwriting
+ if (bEnableOverride)
+ {
+ AddButton(Translate::get(STR_FILECHANGED_SAVEANYWAY_BTN, rResLocale), RET_IGNORE,
+ ButtonDialogFlags::OK);
+ AddButton(StandardButtonType::Cancel, RET_CANCEL,
+ ButtonDialogFlags::Default | ButtonDialogFlags::Cancel | ButtonDialogFlags::Focus);
- SetButtonHelpText( RET_YES, OUString() );
- SetButtonHelpText( RET_NO, OUString() );
+ SetButtonHelpText(RET_IGNORE, OUString());
+ }
+ else
+ {
+ AddButton(Translate::get(STR_TRYLATER_RETRYSAVING_BTN, rResLocale), RET_YES,
+ ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
+ AddButton(Translate::get(STR_TRYLATER_SAVEAS_BTN, rResLocale), RET_NO);
+ AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel );
+
+ SetButtonHelpText( RET_YES, OUString() );
+ SetButtonHelpText( RET_NO, OUString() );
+ }
}
TryLaterQueryBox::~TryLaterQueryBox()
diff --git a/uui/source/trylater.hxx b/uui/source/trylater.hxx
index 23d0a0c78841..f03f3cf92187 100644
--- a/uui/source/trylater.hxx
+++ b/uui/source/trylater.hxx
@@ -24,7 +24,7 @@
class TryLaterQueryBox : public MessBox
{
public:
- TryLaterQueryBox(vcl::Window* pParent, const std::locale& rLocale, const OUString& aMessage);
+ TryLaterQueryBox(vcl::Window* pParent, const std::locale& rLocale, const OUString& aMessage, bool bEnableOverride);
virtual ~TryLaterQueryBox() override;
};