1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <osl/conditn.hxx>
23 #include <cppuhelper/implbase.hxx>
24 #include <comphelper/errcode.hxx>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/task/InteractionClassification.hpp>
29 #include <com/sun/star/task/XInteractionHandler2.hpp>
32 struct LibLibreOffice_Impl
;
33 struct LibLODocument_Impl
;
36 /** InteractionHandler is an interface that provides the user with various dialogs / error messages.
38 We need an own implementation for the LibreOfficeKit so that we can route the
39 information easily via callbacks.
41 TODO: the callbacks are not implemented yet, we just approve any interaction
44 class LOKInteractionHandler
: public cppu::WeakImplHelper
<css::lang::XServiceInfo
,
45 css::lang::XInitialization
,
46 css::task::XInteractionHandler2
>
49 desktop::LibLibreOffice_Impl
* m_pLOKit
;
50 desktop::LibLODocument_Impl
* m_pLOKDocument
;
52 /// Command for which we use this interaction handler (like "load", "save", "saveas", ...)
57 osl::Condition m_havePassword
;
59 LOKInteractionHandler(const LOKInteractionHandler
&) = delete;
60 LOKInteractionHandler
& operator=(const LOKInteractionHandler
&) = delete;
62 /** Call the LOK_CALLBACK_ERROR on the LOK document (if available) or LOK lib.
64 The error itself is a JSON message, like:
66 "classification": "error" | "warning" | "info"
67 "kind": "network" etc.
68 "code": 403 | 404 | ...
69 "message": freeform description
72 void postError(css::task::InteractionClassification classif
, const char* kind
, ErrCode code
, const OUString
&message
);
74 bool handleIOException(const css::uno::Sequence
<css::uno::Reference
<css::task::XInteractionContinuation
>> &rContinuations
, const css::uno::Any
& rRequest
);
75 bool handleNetworkException(const css::uno::Sequence
<css::uno::Reference
<css::task::XInteractionContinuation
>> &rContinuations
, const css::uno::Any
& rRequest
);
76 bool handlePasswordRequest(const css::uno::Sequence
<css::uno::Reference
<css::task::XInteractionContinuation
>> &rContinuations
, const css::uno::Any
& rRequest
);
77 static bool handleMacroConfirmationRequest(const css::uno::Reference
<css::task::XInteractionRequest
>& xRequest
);
79 static bool handleFilterOptionsRequest(const css::uno::Reference
<css::task::XInteractionRequest
>& Request
);
80 static bool handlePackageReparationRequest(const css::uno::Reference
<css::task::XInteractionRequest
>& xRequest
);
82 static bool handleLoadReadOnlyRequest(const css::uno::Reference
<css::task::XInteractionRequest
>& xRequest
);
85 void SetPassword(char const* pPassword
);
87 explicit LOKInteractionHandler(
89 desktop::LibLibreOffice_Impl
*,
90 desktop::LibLODocument_Impl
*pLOKDocumt
= nullptr);
92 virtual ~LOKInteractionHandler() override
;
94 virtual OUString SAL_CALL
getImplementationName() override
;
96 virtual sal_Bool SAL_CALL
supportsService(OUString
const & rServiceName
) override
;
98 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
100 virtual void SAL_CALL
initialize(css::uno::Sequence
<css::uno::Any
> const & rArguments
) override
;
102 virtual void SAL_CALL
handle(css::uno::Reference
<css::task::XInteractionRequest
> const & rRequest
) override
;
104 virtual sal_Bool SAL_CALL
handleInteractionRequest(const css::uno::Reference
<css::task::XInteractionRequest
>& Request
) override
;
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */