27#include <com/sun/star/task/ErrorCodeRequest.hpp>
28#include <com/sun/star/task/XInteractionHandler.hpp>
29#include <com/sun/star/task/XInteractionRequest.hpp>
30#include <com/sun/star/task/XInteractionPassword.hpp>
31#include <com/sun/star/task/DocumentPasswordRequest.hpp>
42class PDFPasswordRequest:
43 public cppu::WeakImplHelper<
44 task::XInteractionRequest, task::XInteractionPassword >
53 explicit PDFPasswordRequest(
bool bFirstTry,
const OUString& rName);
54 PDFPasswordRequest(
const PDFPasswordRequest&) =
delete;
55 PDFPasswordRequest& operator=(
const PDFPasswordRequest&) =
delete;
58 virtual uno::Any SAL_CALL getRequest( )
override;
59 virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL
getContinuations( )
override;
62 virtual void SAL_CALL setPassword(
const OUString& rPwd )
override;
66 virtual void SAL_CALL select()
override;
68 bool isSelected()
const { std::scoped_lock
const guard( m_aMutex );
return m_bSelected; }
71 virtual ~PDFPasswordRequest()
override {}
74PDFPasswordRequest::PDFPasswordRequest(
bool bFirstTry,
const OUString& rName ) :
77 task::DocumentPasswordRequest(
79 task::InteractionClassification_QUERY,
81 ? task::PasswordRequestMode_PASSWORD_ENTER
82 : task::PasswordRequestMode_PASSWORD_REENTER),
87uno::Any PDFPasswordRequest::getRequest()
92uno::Sequence< uno::Reference< task::XInteractionContinuation > > PDFPasswordRequest::getContinuations()
97void PDFPasswordRequest::setPassword(
const OUString& rPwd )
99 std::scoped_lock
const guard( m_aMutex );
106 std::scoped_lock
const guard( m_aMutex );
111void PDFPasswordRequest::select()
113 std::scoped_lock
const guard( m_aMutex );
118class UnsupportedEncryptionFormatRequest:
119 public cppu::WeakImplHelper< task::XInteractionRequest >
122 UnsupportedEncryptionFormatRequest() {}
123 UnsupportedEncryptionFormatRequest(
const UnsupportedEncryptionFormatRequest&) =
delete;
124 UnsupportedEncryptionFormatRequest& operator=(
const UnsupportedEncryptionFormatRequest&) =
delete;
127 virtual ~UnsupportedEncryptionFormatRequest()
override {}
129 virtual uno::Any SAL_CALL getRequest()
override {
131 task::ErrorCodeRequest(
132 OUString(), uno::Reference< uno::XInterface >(),
133 sal_uInt32(ERRCODE_IO_WRONGVERSION)));
138 virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > >
141 uno::Sequence< uno::Reference< task::XInteractionContinuation > >();
150bool getPassword(
const uno::Reference< task::XInteractionHandler >& xHandler,
153 const OUString& rDocName
156 bool bSuccess =
false;
159 new PDFPasswordRequest( bFirstTry, rDocName ) );
162 xHandler->handle( xReq );
164 catch( uno::Exception& )
168 if( xReq->isSelected() )
171 rOutPwd = xReq->getPassword();
178 uno::Reference< task::XInteractionHandler >
const & handler)
180 assert(handler.is());
181 handler->handle(
new UnsupportedEncryptionFormatRequest);
void getContinuations(css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > const &rContinuations, css::uno::Reference< t1 > *pContinuation1, css::uno::Reference< t2 > *pContinuation2)
bool getPassword(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, OUString &rOutPwd, bool bFirstTry, const OUString &rDocName)
retrieve password from user
void reportUnsupportedEncryptionFormat(css::uno::Reference< css::task::XInteractionHandler > const &handler)
bool getPassword(const uno::Reference< task::XInteractionHandler > &xHandler, OUString &rOutPwd, bool bFirstTry, const OUString &rDocName)