1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucbhelper.hxx"
26 #include <ucbhelper/simpleinteractionrequest.hxx>
27
28 using namespace com::sun::star;
29 using namespace ucbhelper;
30
31 //=========================================================================
SimpleInteractionRequest(const uno::Any & rRequest,const sal_Int32 nContinuations)32 SimpleInteractionRequest::SimpleInteractionRequest(
33 const uno::Any & rRequest,
34 const sal_Int32 nContinuations )
35 : InteractionRequest( rRequest )
36 {
37 // Set continuations.
38 OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN,
39 "SimpleInteractionRequest - No continuation!" );
40
41 sal_Int32 nLength = 0;
42
43 uno::Reference< task::XInteractionContinuation > xAbort;
44 uno::Reference< task::XInteractionContinuation > xRetry;
45 uno::Reference< task::XInteractionContinuation > xApprove;
46 uno::Reference< task::XInteractionContinuation > xDisapprove;
47
48 if ( nContinuations & CONTINUATION_ABORT )
49 {
50 ++nLength;
51 xAbort = new InteractionAbort( this );
52 }
53
54 if ( nContinuations & CONTINUATION_RETRY )
55 {
56 ++nLength;
57 xRetry = new InteractionRetry( this );
58 }
59
60 if ( nContinuations & CONTINUATION_APPROVE )
61 {
62 ++nLength;
63 xApprove = new InteractionApprove( this );
64 }
65
66 if ( nContinuations & CONTINUATION_DISAPPROVE )
67 {
68 ++nLength;
69 xDisapprove = new InteractionDisapprove( this );
70 }
71
72 OSL_ENSURE( nLength > 0,
73 "SimpleInteractionRequest - No continuation!" );
74
75 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
76 aContinuations( nLength );
77
78 nLength = 0;
79
80 if ( xAbort.is() )
81 aContinuations[ nLength++ ] = xAbort;
82
83 if ( xRetry.is() )
84 aContinuations[ nLength++ ] = xRetry;
85
86 if ( xApprove.is() )
87 aContinuations[ nLength++ ] = xApprove;
88
89 if ( xDisapprove.is() )
90 aContinuations[ nLength++ ] = xDisapprove;
91
92 setContinuations( aContinuations );
93 }
94
95 //=========================================================================
getResponse() const96 sal_Int32 SimpleInteractionRequest::getResponse() const
97 {
98 rtl::Reference< InteractionContinuation > xSelection = getSelection();
99 if ( xSelection.is() )
100 {
101 InteractionContinuation * pSelection = xSelection.get();
102
103 uno::Reference< task::XInteractionAbort > xAbort(
104 pSelection, uno::UNO_QUERY );
105 if ( xAbort.is() )
106 return CONTINUATION_ABORT;
107
108 uno::Reference< task::XInteractionRetry > xRetry(
109 pSelection, uno::UNO_QUERY );
110 if ( xRetry.is() )
111 return CONTINUATION_RETRY;
112
113 uno::Reference< task::XInteractionApprove > xApprove(
114 pSelection, uno::UNO_QUERY );
115 if ( xApprove.is() )
116 return CONTINUATION_APPROVE;
117
118 uno::Reference< task::XInteractionDisapprove > xDisapprove(
119 pSelection, uno::UNO_QUERY );
120 if ( xDisapprove.is() )
121 return CONTINUATION_DISAPPROVE;
122
123 OSL_ENSURE( sal_False,
124 "SimpleInteractionRequest::getResponse - Unknown continuation!" );
125 }
126 return CONTINUATION_UNKNOWN;
127 }
128
129