25#include <com/sun/star/task/XInteractionAbort.hpp>
26#include <com/sun/star/task/XInteractionApprove.hpp>
27#include <com/sun/star/task/XInteractionPassword2.hpp>
28#include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
29#include <com/sun/star/task/InteractionHandler.hpp>
30#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
31#include <com/sun/star/ucb/InteractiveNetworkOffLineException.hpp>
33#include <com/sun/star/ucb/InteractiveIOException.hpp>
34#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
35#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
36#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
38#include <com/sun/star/task/DocumentPasswordRequest2.hpp>
39#include <com/sun/star/task/DocumentMSPasswordRequest2.hpp>
41#include <com/sun/star/document/FilterOptionsRequest.hpp>
43#include "../../inc/lib/init.hxx"
45#include <LibreOfficeKit/LibreOfficeKitEnums.h>
60 , m_pLOKDocument(pLOKDocument)
61 , m_command(
std::move(command))
62 , m_usePassword(false)
73 return "com.sun.star.comp.uui.LOKInteractionHandler";
83 return {
"com.sun.star.task.InteractionHandler",
85 "com.sun.star.configuration.backend.InteractionHandler",
87 "com.sun.star.uui.InteractionHandler" };
103 std::string classification =
"error";
106 case task::InteractionClassification_ERROR:
break;
107 case task::InteractionClassification_WARNING: classification =
"warning";
break;
108 case task::InteractionClassification_INFO: classification =
"info";
break;
109 case task::InteractionClassification_QUERY: classification =
"query";
break;
110 default: assert(
false);
break;
115 aJson.
put(
"classification", classification);
117 aJson.
put(
"kind", kind);
118 aJson.
put(
"code",
static_cast<sal_uInt32
>(
code));
119 aJson.
put(
"message", message.toUtf8());
133 for (
auto const & c : rContinuations)
145 ucb::InteractiveIOException aIoException;
146 if (!(rRequest >>= aIoException))
149 static ErrCode const aErrorCode[
int(ucb::IOErrorCode_WRONG_VERSION) + 1] =
189 postError(aIoException.Classification,
"io", aErrorCode[
static_cast<int>(aIoException.Code)],
"");
190 selectApproved(rContinuations);
197 ucb::InteractiveNetworkException aNetworkException;
198 if (!(rRequest >>= aNetworkException))
204 ucb::InteractiveNetworkOffLineException aOffLineException;
205 ucb::InteractiveNetworkResolveNameException aResolveNameException;
206 ucb::InteractiveNetworkConnectException aConnectException;
207 ucb::InteractiveNetworkReadException aReadException;
208 ucb::InteractiveNetworkWriteException aWriteException;
209 if (rRequest >>= aOffLineException)
213 else if (rRequest >>= aResolveNameException)
216 aMessage = aResolveNameException.Server;
218 else if (rRequest >>= aConnectException)
221 aMessage = aConnectException.Server;
223 else if (rRequest >>= aReadException)
226 aMessage = aReadException.Diagnostic;
228 else if (rRequest >>= aWriteException)
231 aMessage = aWriteException.Diagnostic;
238 postError(aNetworkException.Classification,
"network", nErrorCode, aMessage);
239 selectApproved(rContinuations);
246 bool bPasswordRequestFound =
false;
247 bool bIsRequestPasswordToModify =
false;
251 task::DocumentPasswordRequest passwordRequest;
252 if (rRequest >>= passwordRequest)
254 bIsRequestPasswordToModify =
false;
255 sUrl = passwordRequest.Name.toUtf8();
256 bPasswordRequestFound =
true;
259 task::DocumentPasswordRequest2 passwordRequest2;
260 if (rRequest >>= passwordRequest2)
262 bIsRequestPasswordToModify = passwordRequest2.IsRequestPasswordToModify;
263 sUrl = passwordRequest2.Name.toUtf8();
264 bPasswordRequestFound =
true;
267 task::DocumentMSPasswordRequest2 passwordMSRequest;
268 if (rRequest >>= passwordMSRequest)
270 bIsRequestPasswordToModify = passwordMSRequest.IsRequestPasswordToModify;
271 sUrl = passwordMSRequest.Name.toUtf8();
272 bPasswordRequestFound =
true;
275 if (!bPasswordRequestFound)
280 : LOK_FEATURE_DOCUMENT_PASSWORD))
285 m_pLOKit->
mpCallback(bIsRequestPasswordToModify ? LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY
286 : LOK_CALLBACK_DOCUMENT_PASSWORD,
295 for (
auto const & cont : rContinuations)
299 if (bIsRequestPasswordToModify)
317 if (bIsRequestPasswordToModify)
320 xIPW2->setRecommendReadOnly(
true);
338 uno::Any const request(xRequest->getRequest());
340 task::DocumentMacroConfirmationRequest aConfirmRequest;
341 if (request >>= aConfirmRequest)
345 if (xInteraction.is())
346 xInteraction->handleInteractionRequest(xRequest);
355 document::FilterOptionsRequest aFilterOptionsRequest;
356 uno::Any const request(xRequest->getRequest());
357 if (request >>= aFilterOptionsRequest)
360 task::InteractionHandler::createWithParent(
361 ::comphelper::getProcessComponentContext(),
nullptr));
363 if (xInteraction.is())
364 xInteraction->handleInteractionRequest(xRequest);
375 uno::Any const request(xRequest->getRequest());
393 selectApproved(rContinuations);
402 m_Password = OUString(pPassword, strlen(pPassword), RTL_TEXTENCODING_UTF8);
bool handleIOException(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &rContinuations, const css::uno::Any &rRequest)
desktop::LibLODocument_Impl * m_pLOKDocument
desktop::LibLibreOffice_Impl * m_pLOKit
void postError(css::task::InteractionClassification classif, const char *kind, ErrCode code, const OUString &message)
Call the LOK_CALLBACK_ERROR on the LOK document (if available) or LOK lib.
virtual ~LOKInteractionHandler() override
LOKInteractionHandler(const LOKInteractionHandler &)=delete
virtual OUString SAL_CALL getImplementationName() override
virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SetPassword(char const *pPassword)
bool handleNetworkException(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
osl::Condition m_havePassword
bool handlePasswordRequest(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &rContinuations, const css::uno::Any &rRequest)
static bool handleFilterOptionsRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest > &Request)
virtual sal_Bool SAL_CALL handleInteractionRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest > &Request) override
OString m_command
Command for which we use this interaction handler (like "load", "save", "saveas", ....
virtual void SAL_CALL initialize(com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &rArguments) override
static bool handleMacroConfirmationRequest(const css::uno::Reference< css::task::XInteractionRequest > &xRequest)
virtual void SAL_CALL handle(com::sun::star::uno::Reference< com::sun::star::task::XInteractionRequest > const &rRequest) override
static int getView(const SfxViewShell *pViewShell=nullptr)
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
#define ERRCODE_IO_INVALIDLENGTH
#define ERRCODE_IO_BADCRC
#define ERRCODE_IO_ACCESSDENIED
#define ERRCODE_INET_WRITE
#define ERRCODE_IO_MISPLACEDCHAR
#define ERRCODE_IO_CANTTELL
#define ERRCODE_IO_OUTOFSPACE
#define ERRCODE_INET_GENERAL
#define ERRCODE_IO_INVALIDDEVICE
#define ERRCODE_IO_CURRENTDIR
#define ERRCODE_IO_NOTADIRECTORY
#define ERRCODE_IO_CANTREAD
#define ERRCODE_IO_CANTCREATE
#define ERRCODE_IO_LOCKVIOLATION
#define ERRCODE_IO_GENERAL
#define ERRCODE_IO_NOTSAMEDEVICE
#define ERRCODE_IO_PENDING
#define ERRCODE_INET_OFFLINE
#define ERRCODE_IO_WRONGVERSION
#define ERRCODE_IO_CANTSEEK
#define ERRCODE_IO_DEVICENOTREADY
#define ERRCODE_IO_NOTEXISTSPATH
#define ERRCODE_IO_CANTWRITE
#define ERRCODE_IO_WRONGFORMAT
#define ERRCODE_INET_READ
#define ERRCODE_IO_NOTEXISTS
#define ERRCODE_IO_RECURSIVE
#define ERRCODE_IO_ALREADYEXISTS
#define ERRCODE_IO_INVALIDCHAR
#define ERRCODE_IO_NOTSUPPORTED
#define ERRCODE_IO_UNKNOWN
#define ERRCODE_IO_WRITEPROTECTED
#define ERRCODE_INET_CONNECT
#define ERRCODE_IO_INVALIDACCESS
#define ERRCODE_INET_NAME_RESOLVE
#define ERRCODE_IO_OUTOFMEMORY
#define ERRCODE_IO_NAMETOOLONG
#define ERRCODE_IO_TOOMANYOPENFILES
#define ERRCODE_IO_NOTAFILE
#define ERRCODE_IO_ISWILDCARD
#define ERRCODE_IO_INVALIDPARAMETER
Reference< XComponentContext > getProcessComponentContext()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
std::map< size_t, std::shared_ptr< CallbackFlushHandler > > mpCallbackFlushHandlers
LibreOfficeKitCallback mpCallback
bool hasOptionalFeature(LibreOfficeKitOptionalFeatures const feature)