1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef COMPHELPER_DOCPASSWORDREQUEST_HXX 25 #define COMPHELPER_DOCPASSWORDREQUEST_HXX 26 27 #include "comphelper/comphelperdllapi.h" 28 #include <com/sun/star/task/PasswordRequestMode.hpp> 29 #include <com/sun/star/task/XInteractionRequest.hpp> 30 #include <cppuhelper/implbase1.hxx> 31 #include <cppuhelper/weak.hxx> 32 33 34 namespace comphelper { 35 36 class AbortContinuation; 37 class PasswordContinuation; 38 39 // ============================================================================ 40 41 /** Selects which UNO document password request type to use. */ 42 enum DocPasswordRequestType 43 { 44 DocPasswordRequestType_STANDARD, /// Uses the standard com.sun.star.task.DocumentPasswordRequest request. 45 DocPasswordRequestType_MS /// Uses the com.sun.star.task.DocumentMSPasswordRequest request. 46 }; 47 48 // ============================================================================ 49 50 class COMPHELPER_DLLPUBLIC SimplePasswordRequest : 51 public ::com::sun::star::task::XInteractionRequest, 52 public ::cppu::OWeakObject 53 { 54 public: 55 explicit SimplePasswordRequest( com::sun::star::task::PasswordRequestMode eMode ); 56 virtual ~SimplePasswordRequest(); 57 58 // XInterface / OWeakObject 59 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 60 virtual void SAL_CALL acquire( ) throw (); 61 virtual void SAL_CALL release( ) throw (); 62 63 sal_Bool isAbort() const; 64 sal_Bool isPassword() const; 65 66 ::rtl::OUString getPassword() const; 67 68 private: 69 // XInteractionRequest 70 virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException ); 71 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 ); 72 73 private: 74 ::com::sun::star::uno::Any maRequest; 75 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > maContinuations; 76 AbortContinuation * mpAbort; 77 PasswordContinuation * mpPassword; 78 }; 79 80 // ============================================================================ 81 82 /** Implements the task.XInteractionRequest interface for requesting a password 83 string for a document. 84 */ 85 class COMPHELPER_DLLPUBLIC DocPasswordRequest : 86 public ::com::sun::star::task::XInteractionRequest, 87 public ::cppu::OWeakObject 88 { 89 public: 90 explicit DocPasswordRequest( 91 DocPasswordRequestType eType, 92 ::com::sun::star::task::PasswordRequestMode eMode, 93 const ::rtl::OUString& rDocumentName, 94 sal_Bool bPasswordToModify = sal_False ); 95 virtual ~DocPasswordRequest(); 96 97 // XInterface / OWeakObject 98 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 99 virtual void SAL_CALL acquire( ) throw (); 100 virtual void SAL_CALL release( ) throw (); 101 102 sal_Bool isAbort() const; 103 sal_Bool isPassword() const; 104 105 ::rtl::OUString getPassword() const; 106 107 ::rtl::OUString getPasswordToModify() const; 108 sal_Bool getRecommendReadOnly() const; 109 110 private: 111 // XInteractionRequest 112 virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException ); 113 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 ); 114 115 private: 116 ::com::sun::star::uno::Any maRequest; 117 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > maContinuations; 118 AbortContinuation * mpAbort; 119 PasswordContinuation * mpPassword; 120 }; 121 122 // ============================================================================ 123 124 } // namespace comphelper 125 126 #endif 127 128