Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / desktop / source / lib / lokinteractionhandler.hxx
blob5c6c6f87de6ddb0c70221a734369938b638c68fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
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>
31 namespace desktop {
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
42 that we get.
44 class LOKInteractionHandler: public cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo,
45 com::sun::star::lang::XInitialization,
46 com::sun::star::task::XInteractionHandler2>
48 private:
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", ...)
53 OString m_command;
55 OUString m_Password;
56 bool m_usePassword;
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 ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest>& Request);
81 public:
82 void SetPassword(char const* pPassword);
84 explicit LOKInteractionHandler(
85 OString command,
86 desktop::LibLibreOffice_Impl *,
87 desktop::LibLODocument_Impl *pLOKDocumt = nullptr);
89 virtual ~LOKInteractionHandler() override;
91 virtual OUString SAL_CALL getImplementationName() override;
93 virtual sal_Bool SAL_CALL supportsService(OUString const & rServiceName) override;
95 virtual com::sun::star::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
97 virtual void SAL_CALL initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any > const & rArguments) override;
99 virtual void SAL_CALL handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const & rRequest) override;
101 virtual sal_Bool SAL_CALL handleInteractionRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest>& Request) override;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */