uui/inc/strings.hrc | 1 uui/source/iahndl-errorhandler.cxx | 39 +++++++++++++++++++++++++++++++++++++ uui/source/iahndl.cxx | 11 ++++++++++ uui/source/iahndl.hxx | 5 ++++ 4 files changed, 56 insertions(+)
New commits: commit 81fa0ab10b9acabe9b7f8ce9a8d7b1c0765bfdfc Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Sep 6 10:27:12 2023 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Sep 15 16:06:03 2023 +0200 uui: implement "handleLoadReadOnlyRequest" Is used for interaction handle to query user decision regarding to open the document read only. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: Ia6792ca540b5c62f4c9de8a5793ef45de3740484 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156622 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Ashod Nakashian <a...@collabora.com> 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 c03d518108f3..5e758da9515c 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 ce5dfffa88db..7bd3fb7104d4 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -813,6 +813,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