Update ooo320-m1
[ooovba.git] / ucbhelper / source / provider / simpleinteractionrequest.cxx
blob464d4c8d9ee8852249379535a8206fb2202783c4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: simpleinteractionrequest.cxx,v $
10 * $Revision: 1.6.20.1 $
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_ucbhelper.hxx"
33 #include <ucbhelper/simpleinteractionrequest.hxx>
35 using namespace com::sun::star;
36 using namespace ucbhelper;
38 //=========================================================================
39 SimpleInteractionRequest::SimpleInteractionRequest(
40 const uno::Any & rRequest,
41 const sal_Int32 nContinuations )
42 : InteractionRequest( rRequest )
44 // Set continuations.
45 OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN,
46 "SimpleInteractionRequest - No continuation!" );
48 sal_Int32 nLength = 0;
50 uno::Reference< task::XInteractionContinuation > xAbort;
51 uno::Reference< task::XInteractionContinuation > xRetry;
52 uno::Reference< task::XInteractionContinuation > xApprove;
53 uno::Reference< task::XInteractionContinuation > xDisapprove;
55 if ( nContinuations & CONTINUATION_ABORT )
57 ++nLength;
58 xAbort = new InteractionAbort( this );
61 if ( nContinuations & CONTINUATION_RETRY )
63 ++nLength;
64 xRetry = new InteractionRetry( this );
67 if ( nContinuations & CONTINUATION_APPROVE )
69 ++nLength;
70 xApprove = new InteractionApprove( this );
73 if ( nContinuations & CONTINUATION_DISAPPROVE )
75 ++nLength;
76 xDisapprove = new InteractionDisapprove( this );
79 OSL_ENSURE( nLength > 0,
80 "SimpleInteractionRequest - No continuation!" );
82 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
83 aContinuations( nLength );
85 nLength = 0;
87 if ( xAbort.is() )
88 aContinuations[ nLength++ ] = xAbort;
90 if ( xRetry.is() )
91 aContinuations[ nLength++ ] = xRetry;
93 if ( xApprove.is() )
94 aContinuations[ nLength++ ] = xApprove;
96 if ( xDisapprove.is() )
97 aContinuations[ nLength++ ] = xDisapprove;
99 setContinuations( aContinuations );
102 //=========================================================================
103 sal_Int32 SimpleInteractionRequest::getResponse() const
105 rtl::Reference< InteractionContinuation > xSelection = getSelection();
106 if ( xSelection.is() )
108 InteractionContinuation * pSelection = xSelection.get();
110 uno::Reference< task::XInteractionAbort > xAbort(
111 pSelection, uno::UNO_QUERY );
112 if ( xAbort.is() )
113 return CONTINUATION_ABORT;
115 uno::Reference< task::XInteractionRetry > xRetry(
116 pSelection, uno::UNO_QUERY );
117 if ( xRetry.is() )
118 return CONTINUATION_RETRY;
120 uno::Reference< task::XInteractionApprove > xApprove(
121 pSelection, uno::UNO_QUERY );
122 if ( xApprove.is() )
123 return CONTINUATION_APPROVE;
125 uno::Reference< task::XInteractionDisapprove > xDisapprove(
126 pSelection, uno::UNO_QUERY );
127 if ( xDisapprove.is() )
128 return CONTINUATION_DISAPPROVE;
130 OSL_ENSURE( sal_False,
131 "SimpleInteractionRequest::getResponse - Unknown continuation!" );
133 return CONTINUATION_UNKNOWN;