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 .
20 #ifndef COMPHELPER_DOCPASSWORDREQUEST_HXX
21 #define COMPHELPER_DOCPASSWORDREQUEST_HXX
23 #include "comphelper/comphelperdllapi.h"
24 #include <com/sun/star/task/PasswordRequestMode.hpp>
25 #include <com/sun/star/task/XInteractionRequest.hpp>
26 #include <cppuhelper/implbase1.hxx>
27 #include <cppuhelper/weak.hxx>
30 namespace comphelper
{
32 class AbortContinuation
;
33 class PasswordContinuation
;
35 // ============================================================================
37 /** Selects which UNO document password request type to use. */
38 enum DocPasswordRequestType
40 DocPasswordRequestType_STANDARD
, /// Uses the standard com.sun.star.task.DocumentPasswordRequest request.
41 DocPasswordRequestType_MS
/// Uses the com.sun.star.task.DocumentMSPasswordRequest request.
44 // ============================================================================
46 class COMPHELPER_DLLPUBLIC SimplePasswordRequest
:
47 public ::com::sun::star::task::XInteractionRequest
,
48 public ::cppu::OWeakObject
51 explicit SimplePasswordRequest( com::sun::star::task::PasswordRequestMode eMode
);
52 virtual ~SimplePasswordRequest();
54 // XInterface / OWeakObject
55 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw (::com::sun::star::uno::RuntimeException
);
56 virtual void SAL_CALL
acquire( ) throw ();
57 virtual void SAL_CALL
release( ) throw ();
59 sal_Bool
isPassword() const;
61 OUString
getPassword() const;
64 // XInteractionRequest
65 virtual ::com::sun::star::uno::Any SAL_CALL
getRequest() throw( ::com::sun::star::uno::RuntimeException
);
66 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> > SAL_CALL
getContinuations() throw( ::com::sun::star::uno::RuntimeException
);
69 ::com::sun::star::uno::Any maRequest
;
70 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> > maContinuations
;
71 AbortContinuation
* mpAbort
;
72 PasswordContinuation
* mpPassword
;
75 // ============================================================================
77 /** Implements the task.XInteractionRequest interface for requesting a password
78 string for a document.
80 class COMPHELPER_DLLPUBLIC DocPasswordRequest
:
81 public ::com::sun::star::task::XInteractionRequest
,
82 public ::cppu::OWeakObject
85 explicit DocPasswordRequest(
86 DocPasswordRequestType eType
,
87 ::com::sun::star::task::PasswordRequestMode eMode
,
88 const OUString
& rDocumentName
,
89 sal_Bool bPasswordToModify
= sal_False
);
90 virtual ~DocPasswordRequest();
92 // XInterface / OWeakObject
93 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw (::com::sun::star::uno::RuntimeException
);
94 virtual void SAL_CALL
acquire( ) throw ();
95 virtual void SAL_CALL
release( ) throw ();
97 sal_Bool
isPassword() const;
99 OUString
getPassword() const;
101 OUString
getPasswordToModify() const;
102 sal_Bool
getRecommendReadOnly() const;
105 // XInteractionRequest
106 virtual ::com::sun::star::uno::Any SAL_CALL
getRequest() throw( ::com::sun::star::uno::RuntimeException
);
107 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> > SAL_CALL
getContinuations() throw( ::com::sun::star::uno::RuntimeException
);
110 ::com::sun::star::uno::Any maRequest
;
111 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> > maContinuations
;
112 AbortContinuation
* mpAbort
;
113 PasswordContinuation
* mpPassword
;
116 // ============================================================================
118 } // namespace comphelper
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */