fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_passwordrequest.cxx
blob96838feaced157acef371db70eeaff382993e98a
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 "osl/mutex.hxx"
23 #include "com/sun/star/lang/XTypeProvider.hpp"
24 #include "com/sun/star/task/DocumentPasswordRequest.hpp"
26 #include <cppuhelper/queryinterface.hxx>
27 #include "cppuhelper/typeprovider.hxx"
28 #include "ucbhelper/interactionrequest.hxx"
30 #include "tdoc_passwordrequest.hxx"
32 using namespace com::sun::star;
33 using namespace tdoc_ucp;
35 namespace tdoc_ucp
37 class InteractionSupplyPassword :
38 public ucbhelper::InteractionContinuation,
39 public lang::XTypeProvider,
40 public task::XInteractionPassword
42 public:
43 InteractionSupplyPassword( ucbhelper::InteractionRequest * pRequest )
44 : InteractionContinuation( pRequest ) {}
46 // XInterface
47 virtual uno::Any SAL_CALL queryInterface( const uno::Type & rType )
48 throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
49 virtual void SAL_CALL acquire()
50 throw () SAL_OVERRIDE;
51 virtual void SAL_CALL release()
52 throw () SAL_OVERRIDE;
54 // XTypeProvider
55 virtual uno::Sequence< uno::Type > SAL_CALL getTypes()
56 throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
57 virtual uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
58 throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
60 // XInteractionContinuation
61 virtual void SAL_CALL select()
62 throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
64 // XInteractionPassword
65 virtual void SAL_CALL setPassword( const OUString & aPasswd )
66 throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
67 virtual OUString SAL_CALL getPassword()
68 throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
70 private:
71 osl::Mutex m_aMutex;
72 OUString m_aPassword;
74 } // namespace tdoc_ucp
79 // InteractionSupplyPassword Implementation.
86 // XInterface methods.
90 // virtual
91 void SAL_CALL InteractionSupplyPassword::acquire()
92 throw()
94 OWeakObject::acquire();
98 // virtual
99 void SAL_CALL InteractionSupplyPassword::release()
100 throw()
102 OWeakObject::release();
106 // virtual
107 uno::Any SAL_CALL
108 InteractionSupplyPassword::queryInterface( const uno::Type & rType )
109 throw ( uno::RuntimeException, std::exception )
111 uno::Any aRet = cppu::queryInterface( rType,
112 static_cast< lang::XTypeProvider * >( this ),
113 static_cast< task::XInteractionContinuation * >( this ),
114 static_cast< task::XInteractionPassword * >( this ) );
116 return aRet.hasValue()
117 ? aRet : InteractionContinuation::queryInterface( rType );
122 // XTypeProvider methods.
126 // virtual
127 uno::Sequence< sal_Int8 > SAL_CALL
128 InteractionSupplyPassword::getImplementationId()
129 throw( uno::RuntimeException, std::exception )
131 return css::uno::Sequence<sal_Int8>();
135 // virtual
136 uno::Sequence< uno::Type > SAL_CALL InteractionSupplyPassword::getTypes()
137 throw( uno::RuntimeException, std::exception )
139 static cppu::OTypeCollection * pCollection = 0;
140 if ( !pCollection )
142 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
143 if ( !pCollection )
145 static cppu::OTypeCollection collection(
146 cppu::UnoType<lang::XTypeProvider>::get(),
147 cppu::UnoType<task::XInteractionPassword>::get() );
148 pCollection = &collection;
151 return (*pCollection).getTypes();
156 // XInteractionContinuation methods.
160 // virtual
161 void SAL_CALL InteractionSupplyPassword::select()
162 throw( uno::RuntimeException, std::exception )
164 recordSelection();
169 // XInteractionPassword methods.
173 // virtual
174 void SAL_CALL
175 InteractionSupplyPassword::setPassword( const OUString& aPasswd )
176 throw ( uno::RuntimeException, std::exception )
178 osl::MutexGuard aGuard( m_aMutex );
179 m_aPassword = aPasswd;
182 // virtual
183 OUString SAL_CALL InteractionSupplyPassword::getPassword()
184 throw ( uno::RuntimeException, std::exception )
186 osl::MutexGuard aGuard( m_aMutex );
187 return m_aPassword;
193 // DocumentPasswordRequest Implementation.
198 DocumentPasswordRequest::DocumentPasswordRequest(
199 task::PasswordRequestMode eMode,
200 const OUString & rDocumentName )
202 // Fill request...
203 task::DocumentPasswordRequest aRequest;
204 // aRequest.Message = // OUString
205 // aRequest.Context = // XInterface
206 aRequest.Classification = task::InteractionClassification_ERROR;
207 aRequest.Mode = eMode;
208 aRequest.Name = rDocumentName;
210 setRequest( uno::makeAny( aRequest ) );
212 // Fill continuations...
213 uno::Sequence<
214 uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
215 aContinuations[ 0 ] = new ucbhelper::InteractionAbort( this );
216 aContinuations[ 1 ] = new ucbhelper::InteractionRetry( this );
217 aContinuations[ 2 ] = new InteractionSupplyPassword( this );
219 setContinuations( aContinuations );
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */