LibreOffice Module desktop (master)  1
lokinteractionhandler.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_DESKTOP_SOURCE_LIB_LOKINTERACTIONHANDLER_HXX
21 #define INCLUDED_DESKTOP_SOURCE_LIB_LOKINTERACTIONHANDLER_HXX
22 
23 #include <osl/conditn.hxx>
24 #include <cppuhelper/implbase.hxx>
25 #include <vcl/errcode.hxx>
26 
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/task/DocumentPasswordRequest2.hpp>
30 #include <com/sun/star/task/InteractionHandler.hpp>
31 #include <com/sun/star/ucb/InteractiveNetworkException.hpp>
32 
33 namespace desktop {
34  struct LibLibreOffice_Impl;
35  struct LibLODocument_Impl;
36 }
37 
46 class LOKInteractionHandler: public cppu::WeakImplHelper<com::sun::star::lang::XServiceInfo,
47  com::sun::star::lang::XInitialization,
48  com::sun::star::task::XInteractionHandler2>
49 {
50 private:
53 
55  OString m_command;
56 
57  OUString m_Password;
59  osl::Condition m_havePassword;
60 
63 
74  void postError(css::task::InteractionClassification classif, const char* kind, ErrCode code, const OUString &message);
75 
76  bool handleIOException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest);
77  bool handleNetworkException(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest);
78  bool handlePasswordRequest(const css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> &rContinuations, const css::uno::Any& rRequest);
79 
80 public:
81  void SetPassword(char const* pPassword);
82 
83  explicit LOKInteractionHandler(
84  const OString& rCommand,
86  desktop::LibLODocument_Impl *pLOKDocumt = nullptr);
87 
88  virtual ~LOKInteractionHandler() override;
89 
90  virtual OUString SAL_CALL getImplementationName() override;
91 
92  virtual sal_Bool SAL_CALL supportsService(OUString const & rServiceName) override;
93 
95 
96  virtual void SAL_CALL initialize(com::sun::star::uno::Sequence<com::sun::star::uno::Any > const & rArguments) override;
97 
98  virtual void SAL_CALL handle(com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> const & rRequest) override;
99 
100  virtual sal_Bool SAL_CALL handleInteractionRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest>& Request) override;
101 };
102 
103 #endif
104 
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL handleInteractionRequest(const ::com::sun::star::uno::Reference<::com::sun::star::task::XInteractionRequest > &Request) override
InteractionHandler is an interface that provides the user with various dialogs / error messages...
virtual void SAL_CALL handle(com::sun::star::uno::Reference< com::sun::star::task::XInteractionRequest > const &rRequest) override
Definition: app.cxx:166
bool handlePasswordRequest(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation >> &rContinuations, const css::uno::Any &rRequest)
desktop::LibLODocument_Impl * m_pLOKDocument
LOKInteractionHandler & operator=(const LOKInteractionHandler &)=delete
bool handleNetworkException(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation >> &rContinuations, const css::uno::Any &rRequest)
unsigned char sal_Bool
virtual OUString SAL_CALL getImplementationName() override
virtual ~LOKInteractionHandler() override
OString m_command
Command for which we use this interaction handler (like "load", "save", "saveas", ...
desktop::LibLibreOffice_Impl * m_pLOKit
void SetPassword(char const *pPassword)
virtual void SAL_CALL initialize(com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &rArguments) override
bool handleIOException(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation >> &rContinuations, const css::uno::Any &rRequest)
LOKInteractionHandler(const LOKInteractionHandler &)=delete
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 sal_Bool SAL_CALL supportsService(OUString const &rServiceName) override
virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override