Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / comphelper / docpasswordrequest.hxx
blob5440616f849d264a171493e4b104aa8d28bb191f
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 #ifndef INCLUDED_COMPHELPER_DOCPASSWORDREQUEST_HXX
21 #define INCLUDED_COMPHELPER_DOCPASSWORDREQUEST_HXX
23 #include <comphelper/comphelperdllapi.h>
24 #include <com/sun/star/task/PasswordRequestMode.hpp>
25 #include <com/sun/star/task/XInteractionAbort.hpp>
26 #include <com/sun/star/task/XInteractionRequest.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <rtl/ref.hxx>
30 namespace comphelper {
32 class PasswordContinuation;
35 /** Selects which UNO document password request type to use. */
36 enum class DocPasswordRequestType
38 Standard, /// Uses the standard com.sun.star.task.DocumentPasswordRequest request.
39 MS /// Uses the com.sun.star.task.DocumentMSPasswordRequest request.
43 class COMPHELPER_DLLPUBLIC SimplePasswordRequest :
44 public cppu::WeakImplHelper<css::task::XInteractionRequest>
46 public:
47 explicit SimplePasswordRequest();
48 virtual ~SimplePasswordRequest() override;
50 bool isPassword() const;
52 OUString getPassword() const;
54 private:
55 SimplePasswordRequest(SimplePasswordRequest const&) = delete;
56 SimplePasswordRequest& operator=(SimplePasswordRequest const&) = delete;
58 // XInteractionRequest
59 virtual css::uno::Any SAL_CALL getRequest() override;
60 virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() override;
62 private:
63 css::uno::Any maRequest;
64 css::uno::Reference<css::task::XInteractionAbort> mxAbort;
65 rtl::Reference<PasswordContinuation> mxPassword;
69 /** Implements the task.XInteractionRequest interface for requesting a password
70 string for a document.
72 class COMPHELPER_DLLPUBLIC DocPasswordRequest :
73 public cppu::WeakImplHelper<css::task::XInteractionRequest>
75 public:
76 explicit DocPasswordRequest(
77 DocPasswordRequestType eType,
78 css::task::PasswordRequestMode eMode,
79 const OUString& rDocumentUrl,
80 bool bPasswordToModify = false );
81 virtual ~DocPasswordRequest() override;
83 bool isPassword() const;
85 OUString getPassword() const;
87 OUString getPasswordToModify() const;
88 bool getRecommendReadOnly() const;
90 private:
91 DocPasswordRequest(DocPasswordRequest const&) = delete;
92 DocPasswordRequest& operator=(DocPasswordRequest const&) = delete;
94 // XInteractionRequest
95 virtual css::uno::Any SAL_CALL getRequest() override;
96 virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() override;
98 private:
99 css::uno::Any maRequest;
100 css::uno::Reference<css::task::XInteractionAbort> mxAbort;
101 rtl::Reference<PasswordContinuation> mxPassword;
105 } // namespace comphelper
107 #endif
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */