tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_passwordrequest.cxx
blob76ceff75f1d0149f7f43e59d948eaeeca35d4a7f
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 .
21 #include <com/sun/star/lang/XTypeProvider.hpp>
22 #include <com/sun/star/task/DocumentPasswordRequest.hpp>
23 #include <com/sun/star/task/XInteractionPassword.hpp>
25 #include <cppuhelper/queryinterface.hxx>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <ucbhelper/interactionrequest.hxx>
29 #include "tdoc_passwordrequest.hxx"
31 #include <mutex>
33 using namespace com::sun::star;
34 using namespace tdoc_ucp;
36 namespace tdoc_ucp
38 namespace {
40 using InteractionSupplyPassword_BASE = cppu::ImplInheritanceHelper<ucbhelper::InteractionContinuation,
41 task::XInteractionPassword>;
42 class InteractionSupplyPassword : public InteractionSupplyPassword_BASE
44 public:
45 explicit InteractionSupplyPassword( ucbhelper::InteractionRequest * pRequest )
46 : InteractionSupplyPassword_BASE( pRequest ) {}
48 // XInteractionContinuation
49 virtual void SAL_CALL select() override;
51 // XInteractionPassword
52 virtual void SAL_CALL setPassword( const OUString & aPasswd ) override;
53 virtual OUString SAL_CALL getPassword() override;
55 private:
56 std::mutex m_aMutex;
57 OUString m_aPassword;
61 } // namespace tdoc_ucp
64 // InteractionSupplyPassword Implementation.
67 // XInteractionContinuation methods.
70 // virtual
71 void SAL_CALL InteractionSupplyPassword::select()
73 recordSelection();
77 // XInteractionPassword methods.
80 // virtual
81 void SAL_CALL
82 InteractionSupplyPassword::setPassword( const OUString& aPasswd )
84 std::scoped_lock aGuard( m_aMutex );
85 m_aPassword = aPasswd;
88 // virtual
89 OUString SAL_CALL InteractionSupplyPassword::getPassword()
91 std::scoped_lock aGuard( m_aMutex );
92 return m_aPassword;
96 // DocumentPasswordRequest Implementation.
99 DocumentPasswordRequest::DocumentPasswordRequest(
100 task::PasswordRequestMode eMode,
101 const OUString & rDocumentName )
103 // Fill request...
104 task::DocumentPasswordRequest aRequest;
105 // aRequest.Message = // OUString
106 // aRequest.Context = // XInterface
107 aRequest.Classification = task::InteractionClassification_ERROR;
108 aRequest.Mode = eMode;
109 aRequest.Name = rDocumentName;
111 setRequest( uno::Any( aRequest ) );
113 // Fill continuations...
114 uno::Sequence<
115 uno::Reference< task::XInteractionContinuation > > aContinuations{
116 new ucbhelper::InteractionAbort( this ),
117 new ucbhelper::InteractionRetry( this ),
118 new InteractionSupplyPassword( this )
121 setContinuations( aContinuations );
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */