summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-09-06 10:27:12 -0400
committerHenry Castro <hcastro@collabora.com>2023-10-09 13:42:45 +0200
commit7fee80fdf4625af4bb8c4273e2cab7bf8b9b46df (patch)
tree331d1477a4a1947c87224779a2599db9728486ab /uui
parent20eed0f37d6d4f444387ab30f6d583fbb6dfad7f (diff)
uui: implement "handleLoadReadOnlyRequest"
Is used for interaction handle to query user decision regarding to open the document read only. Signed-off-by: Henry Castro <hcastro@collabora.com> Change-Id: Ia6792ca540b5c62f4c9de8a5793ef45de3740484 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156622 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Ashod Nakashian <ash@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157660 Tested-by: Jenkins
Diffstat (limited to 'uui')
-rw-r--r--uui/inc/strings.hrc1
-rw-r--r--uui/source/iahndl-errorhandler.cxx39
-rw-r--r--uui/source/iahndl.cxx11
-rw-r--r--uui/source/iahndl.hxx5
4 files changed, 56 insertions, 0 deletions
diff --git a/uui/inc/strings.hrc b/uui/inc/strings.hrc
index 98bd94ef8484..b6daff517f51 100644
--- a/uui/inc/strings.hrc
+++ b/uui/inc/strings.hrc
@@ -78,5 +78,6 @@
#define STR_RELOADEDITABLE_TITLE NC_("STR_RELOADEDITABLE_TITLE", "Document is now editable")
#define STR_RELOADEDITABLE_MSG NC_("STR_RELOADEDITABLE_MSG", "Document file '$(ARG1)' is now editable \n\nReload this document for editing?")
#define STR_RELOADEDITABLE_BTN NC_("STR_RELOADEDITABLE_BTN", "~Reload")
+#define STR_LOADREADONLY_MSG NC_("STR_LOADREADONLY_MSG", "The author would like you to open '$(ARG1)' as read-only unless you need to make changes. Open as read-only?.")
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/source/iahndl-errorhandler.cxx b/uui/source/iahndl-errorhandler.cxx
index 74e3253c5220..c89e66b93c35 100644
--- a/uui/source/iahndl-errorhandler.cxx
+++ b/uui/source/iahndl-errorhandler.cxx
@@ -33,6 +33,7 @@
#include <rtl/ustrbuf.hxx>
#include <ids.hrc>
+#include <strings.hrc>
#include "getcontinuations.hxx"
#include "iahndl.hxx"
@@ -290,4 +291,42 @@ UUIInteractionHelper::handleErrorHandlerRequest(
}
}
+void
+UUIInteractionHelper::handleLoadReadOnlyRequest(
+ const OUString& sDocumentURL,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations)
+{
+ std::locale aLocale(Translate::Create("uui"));
+ std::vector<OUString> aArguments = { sDocumentURL };
+ uno::Reference<task::XInteractionRetry> xRetry;
+ uno::Reference<task::XInteractionAbort> xAbort;
+ uno::Reference<task::XInteractionApprove> xApprove;
+ uno::Reference<task::XInteractionDisapprove> xDisapprove;
+ uno::Reference<awt::XWindow> xParent = getParentXWindow();
+ OUString aMessage(Translate::get(STR_LOADREADONLY_MSG, aLocale));
+
+ aMessage = replaceMessageWithArguments(aMessage, aArguments);
+ getContinuations(rContinuations, &xApprove, &xDisapprove, &xRetry, &xAbort);
+
+ std::unique_ptr<weld::MessageDialog> xBox(
+ Application::CreateMessageDialog(Application::GetFrameWeld(xParent),
+ VclMessageType::Question,
+ VclButtonsType::YesNo,
+ aMessage,
+ GetpApp()));
+
+ if (xBox->run() == RET_YES)
+ {
+ if (xApprove.is())
+ xApprove->select();
+ }
+ else
+ {
+ if (xDisapprove.is())
+ xDisapprove->select();
+ }
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 3eed5811f202..bc6f12742b47 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -810,6 +810,17 @@ UUIInteractionHelper::handleRequest_impl(
return true;
}
+ OUString aFileName;
+ beans::NamedValue aLoadReadOnlyRequest;
+ if ((aAnyRequest >>= aLoadReadOnlyRequest) &&
+ aLoadReadOnlyRequest.Name == "LoadReadOnlyRequest" &&
+ (aLoadReadOnlyRequest.Value >>= aFileName))
+ {
+ handleLoadReadOnlyRequest(aFileName,
+ rRequest->getContinuations());
+ return true;
+ }
+
// Last chance: interaction handlers registered in the configuration
diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx
index 78d283d6bf0e..cf468f57dbcf 100644
--- a/uui/source/iahndl.hxx
+++ b/uui/source/iahndl.hxx
@@ -238,6 +238,11 @@ private:
const OUString & instructions,
const OUString & url,
css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > const & rContinuations );
+
+ void
+ handleLoadReadOnlyRequest(
+ const OUString& sDocumentURL,
+ css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > const & rContinuations);
};
class ErrorResource