1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docpasswdrequest.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "docpasswdrequest.hxx"
35 #include <com/sun/star/task/XInteractionAbort.hpp>
36 #include <com/sun/star/task/XInteractionPassword.hpp>
38 //==========================================================================
40 class AbortContinuation
: public ::cppu::WeakImplHelper1
< ::com::sun::star::task::XInteractionAbort
>
45 AbortContinuation() : mbSelected( sal_False
) {}
47 sal_Bool
isSelected() { return mbSelected
; }
49 void reset() { mbSelected
= sal_False
; }
51 virtual void SAL_CALL
select() throw(::com::sun::star::uno::RuntimeException
) { mbSelected
= sal_True
; }
54 //==========================================================================
56 class PasswordContinuation
: public ::cppu::WeakImplHelper1
< ::com::sun::star::task::XInteractionPassword
>
59 ::rtl::OUString maPassword
;
62 PasswordContinuation() : mbSelected( sal_False
) {}
64 sal_Bool
isSelected() { return mbSelected
; }
66 void reset() { mbSelected
= sal_False
; }
68 virtual void SAL_CALL
select() throw(::com::sun::star::uno::RuntimeException
);
69 virtual void SAL_CALL
setPassword( const ::rtl::OUString
& aPass
) throw (::com::sun::star::uno::RuntimeException
);
70 virtual ::rtl::OUString SAL_CALL
getPassword( ) throw (::com::sun::star::uno::RuntimeException
);
73 void SAL_CALL
PasswordContinuation::select()
74 throw(::com::sun::star::uno::RuntimeException
)
76 mbSelected
= sal_True
;
79 void SAL_CALL
PasswordContinuation::setPassword( const ::rtl::OUString
& aPass
)
80 throw (::com::sun::star::uno::RuntimeException
)
85 ::rtl::OUString SAL_CALL
PasswordContinuation::getPassword()
86 throw (::com::sun::star::uno::RuntimeException
)
91 //==========================================================================
93 RequestDocumentPassword::RequestDocumentPassword( ::com::sun::star::task::PasswordRequestMode nMode
, ::rtl::OUString aName
)
96 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> temp2
;
97 ::com::sun::star::task::DocumentPasswordRequest
98 aDocumentPasswordRequest( temp
,
100 ::com::sun::star::task::InteractionClassification_QUERY
,
104 m_aRequest
<<= aDocumentPasswordRequest
;
106 m_pAbort
= new AbortContinuation
;
107 m_pPassword
= new PasswordContinuation
;
109 m_lContinuations
.realloc( 2 );
110 m_lContinuations
[0] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pAbort
);
111 m_lContinuations
[1] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pPassword
);
114 sal_Bool
RequestDocumentPassword::isAbort()
116 return m_pAbort
->isSelected();
119 sal_Bool
RequestDocumentPassword::isPassword()
121 return m_pPassword
->isSelected();
124 ::rtl::OUString
RequestDocumentPassword::getPassword()
126 return m_pPassword
->getPassword();
129 ::com::sun::star::uno::Any SAL_CALL
RequestDocumentPassword::getRequest()
130 throw( ::com::sun::star::uno::RuntimeException
)
135 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >
136 SAL_CALL
RequestDocumentPassword::getContinuations()
137 throw( ::com::sun::star::uno::RuntimeException
)
139 return m_lContinuations
;