1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_COMPHELPER_INTERACTION_HXX
21 #define INCLUDED_COMPHELPER_INTERACTION_HXX
23 #include <comphelper/uno3.hxx>
24 #include <cppuhelper/implbase1.hxx>
25 #include <com/sun/star/task/XInteractionApprove.hpp>
26 #include <com/sun/star/task/XInteractionDisapprove.hpp>
27 #include <com/sun/star/task/XInteractionAbort.hpp>
28 #include <com/sun/star/task/XInteractionRetry.hpp>
29 #include <com/sun/star/task/XInteractionPassword.hpp>
30 #include <com/sun/star/task/XInteractionRequest.hpp>
31 #include <comphelper/comphelperdllapi.h>
33 //.........................................................................
36 //.........................................................................
38 //=========================================================================
39 //= OInteractionSelect
40 //=========================================================================
41 /** base class for concrete XInteractionContinuation implementations.<p/>
42 Instances of the classes maintain a flag indicating if the handler was called.
44 class OInteractionSelect
46 sal_Bool m_bSelected
: 1; /// indicates if the select event occurred
49 OInteractionSelect() : m_bSelected(sal_False
) { }
52 /// determines whether or not this handler was selected
53 sal_Bool
wasSelected() const { return m_bSelected
; }
54 /// resets the state to "not selected", so you may reuse the handler
55 void reset() { m_bSelected
= sal_False
; }
58 void implSelected() { m_bSelected
= sal_True
; }
61 //=========================================================================
63 //=========================================================================
64 /** template for instantiating concret interaction handlers<p/>
65 the template argument must eb an interface derived from XInteractionContinuation
67 template <class INTERACTION
>
69 :public ::cppu::WeakImplHelper1
< INTERACTION
>
70 ,public OInteractionSelect
75 // XInteractionContinuation
76 virtual void SAL_CALL
select( ) throw(::com::sun::star::uno::RuntimeException
);
79 //.........................................................................
80 template <class INTERACTION
>
81 void SAL_CALL OInteraction
< INTERACTION
>::select( ) throw(::com::sun::star::uno::RuntimeException
)
86 //=========================================================================
87 //= OInteractionApprove
88 //=========================================================================
89 typedef OInteraction
< ::com::sun::star::task::XInteractionApprove
> OInteractionApprove
;
91 //=========================================================================
92 //= OInteractionDispprove
93 //=========================================================================
94 typedef OInteraction
< ::com::sun::star::task::XInteractionDisapprove
> OInteractionDisapprove
;
96 //=========================================================================
98 //=========================================================================
99 typedef OInteraction
< ::com::sun::star::task::XInteractionAbort
> OInteractionAbort
;
101 //=========================================================================
102 //= OInteractionRetry
103 //=========================================================================
104 typedef OInteraction
< ::com::sun::star::task::XInteractionRetry
> OInteractionRetry
;
106 //=========================================================================
107 //= OInteractionPassword
108 //=========================================================================
109 class COMPHELPER_DLLPUBLIC OInteractionPassword
: public OInteraction
< ::com::sun::star::task::XInteractionPassword
>
112 OInteractionPassword()
116 OInteractionPassword( const OUString
& _rInitialPassword
)
117 :m_sPassword( _rInitialPassword
)
121 // XInteractionPassword
122 virtual void SAL_CALL
setPassword( const OUString
& _Password
) throw (::com::sun::star::uno::RuntimeException
);
123 virtual OUString SAL_CALL
getPassword( ) throw (::com::sun::star::uno::RuntimeException
);
126 OUString m_sPassword
;
129 //=========================================================================
130 //= OInteractionRequest
131 //=========================================================================
132 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::task::XInteractionRequest
133 > OInteractionRequest_Base
;
134 /** implements an interaction request (com.sun.star.task::XInteractionRequest)<p/>
135 at run time, you can freely add any interaction continuation objects
137 class COMPHELPER_DLLPUBLIC OInteractionRequest
: public OInteractionRequest_Base
139 ::com::sun::star::uno::Any
140 m_aRequest
; /// the request we represent
141 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >
142 m_aContinuations
; /// all registered continuations
145 OInteractionRequest(const ::com::sun::star::uno::Any
& _rRequestDescription
);
147 /// add a new continuation
148 void addContinuation(const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>& _rxContinuation
);
150 // XInteractionRequest
151 virtual ::com::sun::star::uno::Any SAL_CALL
getRequest( ) throw(::com::sun::star::uno::RuntimeException
);
152 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
);
154 //.........................................................................
155 } // namespace comphelper
156 //.........................................................................
158 #endif // INCLUDED_COMPHELPER_INTERACTION_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */