desktop/source/lib/lokinteractionhandler.cxx | 117 +++++++-------------------- desktop/source/lib/lokinteractionhandler.hxx | 6 - 2 files changed, 34 insertions(+), 89 deletions(-)
New commits: commit 6a71bb8069debd0f163a74bc6ce5cc53aaccc8e3 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Aug 2 20:40:40 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Aug 2 18:54:38 2025 +0200 LOK: Simplify fallback to standard interaction handler This will make adding more similar cases easier. Change-Id: I66e96da9fd40b3d527b19a98ea3f35fffad6d126 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188829 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx index de1e26e8f163..723a87fb934b 100644 --- a/desktop/source/lib/lokinteractionhandler.cxx +++ b/desktop/source/lib/lokinteractionhandler.cxx @@ -140,6 +140,38 @@ void selectApproved(uno::Sequence<uno::Reference<task::XInteractionContinuation> } } +bool ShouldFallbackToStandard(const uno::Reference<task::XInteractionRequest>& xRequest) +{ + uno::Any const request(xRequest->getRequest()); + + if (task::DocumentMacroConfirmationRequest aStruct; request >>= aStruct) + return true; + + if (document::BrokenPackageRequest aStruct; request >>= aStruct) + return true; + + if (document::FilterOptionsRequest aStruct; request >>= aStruct) + return true; + + if (beans::NamedValue aStruct; request >>= aStruct) + if (aStruct.Name == "LoadReadOnlyRequest") + if (OUString aFileName; aStruct.Value >>= aFileName) + return true; + + return false; +} + +bool FallbackToStandard(const uno::Reference<task::XInteractionRequest>& xRequest) +{ + auto xInteraction(task::InteractionHandler::createWithParent( + comphelper::getProcessComponentContext(), nullptr)); + + if (xInteraction.is()) + xInteraction->handleInteractionRequest(xRequest); + + return true; +} + } bool LOKInteractionHandler::handleIOException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest) @@ -335,78 +367,6 @@ bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence<uno::Refer return true; } -bool LOKInteractionHandler::handleMacroConfirmationRequest(const uno::Reference<task::XInteractionRequest>& xRequest) -{ - uno::Any const request(xRequest->getRequest()); - - task::DocumentMacroConfirmationRequest aConfirmRequest; - if (request >>= aConfirmRequest) - { - auto xInteraction(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr)); - - if (xInteraction.is()) - xInteraction->handleInteractionRequest(xRequest); - - return true; - } - return false; -} - -bool LOKInteractionHandler::handlePackageReparationRequest(const uno::Reference<task::XInteractionRequest>& xRequest) -{ - uno::Any const request(xRequest->getRequest()); - - document::BrokenPackageRequest aBrokenPackageRequest; - if (request >>= aBrokenPackageRequest) - { - auto xInteraction(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr)); - - if (xInteraction.is()) - xInteraction->handleInteractionRequest(xRequest); - - return true; - } - return false; -} - -bool LOKInteractionHandler::handleLoadReadOnlyRequest(const uno::Reference<task::XInteractionRequest>& xRequest) -{ - uno::Any const request(xRequest->getRequest()); - - OUString aFileName; - beans::NamedValue aLoadReadOnlyRequest; - if ((request >>= aLoadReadOnlyRequest) && - aLoadReadOnlyRequest.Name == "LoadReadOnlyRequest" && - (aLoadReadOnlyRequest.Value >>= aFileName)) - { - auto xInteraction(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr)); - - if (xInteraction.is()) - xInteraction->handleInteractionRequest(xRequest); - - return true; - } - return false; -} - -bool LOKInteractionHandler::handleFilterOptionsRequest(const uno::Reference<task::XInteractionRequest>& xRequest) -{ - document::FilterOptionsRequest aFilterOptionsRequest; - uno::Any const request(xRequest->getRequest()); - if (request >>= aFilterOptionsRequest) - { - uno::Reference< task::XInteractionHandler2 > xInteraction( - task::InteractionHandler::createWithParent( - ::comphelper::getProcessComponentContext(), nullptr)); - - if (xInteraction.is()) - xInteraction->handleInteractionRequest(xRequest); - - return true; - } - return false; -} - sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest( const uno::Reference<task::XInteractionRequest>& xRequest) { @@ -422,17 +382,8 @@ sal_Bool SAL_CALL LOKInteractionHandler::handleInteractionRequest( if (handlePasswordRequest(aContinuations, request)) return true; - if (handleFilterOptionsRequest(xRequest)) - return true; - - if (handleMacroConfirmationRequest(xRequest)) - return true; - - if (handlePackageReparationRequest(xRequest)) - return true; - - if (handleLoadReadOnlyRequest(xRequest)) - return true; + if (ShouldFallbackToStandard(xRequest)) + return FallbackToStandard(xRequest); // TODO: perform more interactions 'for real' like the above selectApproved(aContinuations); diff --git a/desktop/source/lib/lokinteractionhandler.hxx b/desktop/source/lib/lokinteractionhandler.hxx index 06aa62b9bcca..cb4345832aa3 100644 --- a/desktop/source/lib/lokinteractionhandler.hxx +++ b/desktop/source/lib/lokinteractionhandler.hxx @@ -74,12 +74,6 @@ private: bool handleIOException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest); bool handleNetworkException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest); bool handlePasswordRequest(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest); - static bool handleMacroConfirmationRequest(const css::uno::Reference<css::task::XInteractionRequest>& xRequest); - - static bool handleFilterOptionsRequest(const css::uno::Reference<css::task::XInteractionRequest>& Request); - static bool handlePackageReparationRequest(const css::uno::Reference<css::task::XInteractionRequest>& xRequest); - - static bool handleLoadReadOnlyRequest(const css::uno::Reference<css::task::XInteractionRequest>& xRequest); public: void SetPassword(char const* pPassword);