Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <ucbhelper/simpleinteractionrequest.hxx>
21 :
22 : #include <osl/diagnose.h>
23 :
24 : using namespace com::sun::star;
25 : using namespace ucbhelper;
26 :
27 :
28 0 : SimpleInteractionRequest::SimpleInteractionRequest(
29 : const uno::Any & rRequest,
30 : const sal_Int32 nContinuations )
31 0 : : InteractionRequest( rRequest )
32 : {
33 : // Set continuations.
34 : OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN,
35 : "SimpleInteractionRequest - No continuation!" );
36 :
37 0 : sal_Int32 nLength = 0;
38 :
39 0 : uno::Reference< task::XInteractionContinuation > xAbort;
40 0 : uno::Reference< task::XInteractionContinuation > xRetry;
41 0 : uno::Reference< task::XInteractionContinuation > xApprove;
42 0 : uno::Reference< task::XInteractionContinuation > xDisapprove;
43 :
44 0 : if ( nContinuations & CONTINUATION_ABORT )
45 : {
46 0 : ++nLength;
47 0 : xAbort = new InteractionAbort( this );
48 : }
49 :
50 0 : if ( nContinuations & CONTINUATION_RETRY )
51 : {
52 0 : ++nLength;
53 0 : xRetry = new InteractionRetry( this );
54 : }
55 :
56 0 : if ( nContinuations & CONTINUATION_APPROVE )
57 : {
58 0 : ++nLength;
59 0 : xApprove = new InteractionApprove( this );
60 : }
61 :
62 0 : if ( nContinuations & CONTINUATION_DISAPPROVE )
63 : {
64 0 : ++nLength;
65 0 : xDisapprove = new InteractionDisapprove( this );
66 : }
67 :
68 : OSL_ENSURE( nLength > 0,
69 : "SimpleInteractionRequest - No continuation!" );
70 :
71 : uno::Sequence< uno::Reference< task::XInteractionContinuation > >
72 0 : aContinuations( nLength );
73 :
74 0 : nLength = 0;
75 :
76 0 : if ( xAbort.is() )
77 0 : aContinuations[ nLength++ ] = xAbort;
78 :
79 0 : if ( xRetry.is() )
80 0 : aContinuations[ nLength++ ] = xRetry;
81 :
82 0 : if ( xApprove.is() )
83 0 : aContinuations[ nLength++ ] = xApprove;
84 :
85 0 : if ( xDisapprove.is() )
86 0 : aContinuations[ nLength++ ] = xDisapprove;
87 :
88 0 : setContinuations( aContinuations );
89 0 : }
90 :
91 :
92 0 : sal_Int32 SimpleInteractionRequest::getResponse() const
93 : {
94 0 : rtl::Reference< InteractionContinuation > xSelection = getSelection();
95 0 : if ( xSelection.is() )
96 : {
97 0 : InteractionContinuation * pSelection = xSelection.get();
98 :
99 : uno::Reference< task::XInteractionAbort > xAbort(
100 0 : pSelection, uno::UNO_QUERY );
101 0 : if ( xAbort.is() )
102 0 : return CONTINUATION_ABORT;
103 :
104 : uno::Reference< task::XInteractionRetry > xRetry(
105 0 : pSelection, uno::UNO_QUERY );
106 0 : if ( xRetry.is() )
107 0 : return CONTINUATION_RETRY;
108 :
109 : uno::Reference< task::XInteractionApprove > xApprove(
110 0 : pSelection, uno::UNO_QUERY );
111 0 : if ( xApprove.is() )
112 0 : return CONTINUATION_APPROVE;
113 :
114 : uno::Reference< task::XInteractionDisapprove > xDisapprove(
115 0 : pSelection, uno::UNO_QUERY );
116 0 : if ( xDisapprove.is() )
117 0 : return CONTINUATION_DISAPPROVE;
118 :
119 0 : OSL_FAIL( "SimpleInteractionRequest::getResponse - Unknown continuation!" );
120 : }
121 0 : return CONTINUATION_UNKNOWN;
122 : }
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|