update dev300-m58
[ooovba.git] / configmgr / source / misc / simpleinteractionrequest.cxx
blob67deee34b1fecb158d0e86964127b6452fb50056
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.5.18.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_configmgr.hxx"
34 #include "simpleinteractionrequest.hxx"
36 namespace configmgr { namespace apihelper {
38 namespace uno = com::sun::star::uno;
39 namespace task = com::sun::star::task;
40 //=========================================================================
41 SimpleInteractionRequest::SimpleInteractionRequest(
42 const uno::Any & rRequest,
43 const sal_uInt32 nContinuations )
44 : InteractionRequest( rRequest )
46 // Set continuations.
47 OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN,
48 "SimpleInteractionRequest - No continuation!" );
50 sal_Int32 nLength = 0;
52 const sal_uInt32 k_NumContinuationTypes = 4;
53 uno::Reference< task::XInteractionContinuation > xContinuations[ k_NumContinuationTypes ];
55 if ( nContinuations & CONTINUATION_ABORT )
56 xContinuations[nLength++] = new InteractionContinuation< task::XInteractionAbort >( this );
58 if ( nContinuations & CONTINUATION_RETRY )
59 xContinuations[nLength++] = new InteractionContinuation< task::XInteractionRetry >( this );
61 if ( nContinuations & CONTINUATION_APPROVE )
62 xContinuations[nLength++] = new InteractionContinuation< task::XInteractionApprove >( this );
64 if ( nContinuations & CONTINUATION_DISAPPROVE )
65 xContinuations[nLength++] = new InteractionContinuation< task::XInteractionDisapprove >( this );
67 OSL_ENSURE( nLength > 0,
68 "SimpleInteractionRequest - No continuation!" );
70 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
71 aContinuations( xContinuations, nLength );
73 this->setContinuations( aContinuations );
76 //=========================================================================
77 sal_uInt32 SimpleInteractionRequest::getResponse() const
79 uno::Reference< task::XInteractionContinuation > xSelection = this->getSelection();
80 if ( xSelection.is() )
82 if ( uno::Reference< task::XInteractionApprove >::query(xSelection).is() )
83 return CONTINUATION_APPROVE;
85 if ( uno::Reference< task::XInteractionDisapprove >::query(xSelection).is() )
86 return CONTINUATION_DISAPPROVE;
88 if ( uno::Reference< task::XInteractionRetry >::query(xSelection).is() )
89 return CONTINUATION_RETRY;
91 if ( uno::Reference< task::XInteractionAbort >::query(xSelection).is() )
92 return CONTINUATION_ABORT;
94 OSL_ENSURE( sal_False,
95 "SimpleInteractionRequest::getResponse - Unknown continuation!" );
97 return CONTINUATION_UNKNOWN;