10#ifndef INCLUDED_TEST_TESTINTERACTIONHANDLER_HXX
11#define INCLUDED_TEST_TESTINTERACTIONHANDLER_HXX
15#include <com/sun/star/lang/XServiceInfo.hpp>
16#include <com/sun/star/lang/XInitialization.hpp>
17#include <com/sun/star/task/XInteractionHandler2.hpp>
18#include <com/sun/star/task/XInteractionAbort.hpp>
19#include <com/sun/star/task/XInteractionApprove.hpp>
20#include <com/sun/star/task/XInteractionPassword2.hpp>
21#include <com/sun/star/task/DocumentPasswordRequest2.hpp>
22#include <com/sun/star/task/DocumentMSPasswordRequest2.hpp>
28 css::lang::XInitialization,
29 css::task::XInteractionHandler2>
50 return "com.sun.star.comp.uui.TestInteractionHandler";
60 return {
"com.sun.star.task.InteractionHandler",
62 "com.sun.star.configuration.backend.InteractionHandler",
64 "com.sun.star.uui.InteractionHandler" };
67 virtual void SAL_CALL
initialize(css::uno::Sequence<css::uno::Any>
const & )
override
70 virtual void SAL_CALL
handle(css::uno::Reference<css::task::XInteractionRequest>
const & rRequest)
override
79 css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>>
const &rContinuations = rRequest->getContinuations();
80 css::uno::Any
const aRequest(rRequest->getRequest());
85 for (
auto const & cont : rContinuations)
87 css::uno::Reference<css::task::XInteractionApprove> xApprove(cont, css::uno::UNO_QUERY);
95 bool handlePasswordRequest(
const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations,
96 const css::uno::Any& rRequest)
98 bool bPasswordRequestFound =
false;
99 bool bIsRequestPasswordToModify =
false;
100 css::task::PasswordRequestMode
mode{};
102 css::task::DocumentPasswordRequest2 passwordRequest2;
103 if (rRequest >>= passwordRequest2)
105 bIsRequestPasswordToModify = passwordRequest2.IsRequestPasswordToModify;
106 mode = passwordRequest2.Mode;
107 bPasswordRequestFound =
true;
109 css::task::DocumentMSPasswordRequest2 passwordMSRequest2;
110 if (rRequest >>= passwordMSRequest2)
112 bIsRequestPasswordToModify = passwordMSRequest2.IsRequestPasswordToModify;
113 mode = passwordMSRequest2.Mode;
114 bPasswordRequestFound =
true;
117 if (!bPasswordRequestFound)
124 for (
auto const & cont : rContinuations)
126 if (
mode == css::task::PasswordRequestMode_PASSWORD_REENTER)
128 css::uno::Reference<css::task::XInteractionAbort>
const xAbort(cont, css::uno::UNO_QUERY);
132 else if (bIsRequestPasswordToModify)
134 css::uno::Reference<css::task::XInteractionPassword2>
const xIPW2(cont, css::uno::UNO_QUERY);
140 css::uno::Reference<css::task::XInteractionPassword>
const xIPW(cont, css::uno::UNO_QUERY);
virtual sal_Bool SAL_CALL handleInteractionRequest(const css::uno::Reference< css::task::XInteractionRequest > &rRequest) override
virtual OUString SAL_CALL getImplementationName() override
bool wasPasswordRequested()
bool handlePasswordRequest(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &rContinuations, const css::uno::Any &rRequest)
virtual sal_Bool SAL_CALL supportsService(OUString const &rServiceName) override
virtual void SAL_CALL handle(css::uno::Reference< css::task::XInteractionRequest > const &rRequest) override
virtual void SAL_CALL initialize(css::uno::Sequence< css::uno::Any > const &) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
TestInteractionHandler(const OUString &sPassword)
TestInteractionHandler(const TestInteractionHandler &)=delete
TestInteractionHandler & operator=(const TestInteractionHandler &)=delete
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)