1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_ucbhelper.hxx" 30 #include <ucbhelper/simpleinteractionrequest.hxx> 31 32 using namespace com::sun::star; 33 using namespace ucbhelper; 34 35 //========================================================================= 36 SimpleInteractionRequest::SimpleInteractionRequest( 37 const uno::Any & rRequest, 38 const sal_Int32 nContinuations ) 39 : InteractionRequest( rRequest ) 40 { 41 // Set continuations. 42 OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN, 43 "SimpleInteractionRequest - No continuation!" ); 44 45 sal_Int32 nLength = 0; 46 47 uno::Reference< task::XInteractionContinuation > xAbort; 48 uno::Reference< task::XInteractionContinuation > xRetry; 49 uno::Reference< task::XInteractionContinuation > xApprove; 50 uno::Reference< task::XInteractionContinuation > xDisapprove; 51 52 if ( nContinuations & CONTINUATION_ABORT ) 53 { 54 ++nLength; 55 xAbort = new InteractionAbort( this ); 56 } 57 58 if ( nContinuations & CONTINUATION_RETRY ) 59 { 60 ++nLength; 61 xRetry = new InteractionRetry( this ); 62 } 63 64 if ( nContinuations & CONTINUATION_APPROVE ) 65 { 66 ++nLength; 67 xApprove = new InteractionApprove( this ); 68 } 69 70 if ( nContinuations & CONTINUATION_DISAPPROVE ) 71 { 72 ++nLength; 73 xDisapprove = new InteractionDisapprove( this ); 74 } 75 76 OSL_ENSURE( nLength > 0, 77 "SimpleInteractionRequest - No continuation!" ); 78 79 uno::Sequence< uno::Reference< task::XInteractionContinuation > > 80 aContinuations( nLength ); 81 82 nLength = 0; 83 84 if ( xAbort.is() ) 85 aContinuations[ nLength++ ] = xAbort; 86 87 if ( xRetry.is() ) 88 aContinuations[ nLength++ ] = xRetry; 89 90 if ( xApprove.is() ) 91 aContinuations[ nLength++ ] = xApprove; 92 93 if ( xDisapprove.is() ) 94 aContinuations[ nLength++ ] = xDisapprove; 95 96 setContinuations( aContinuations ); 97 } 98 99 //========================================================================= 100 sal_Int32 SimpleInteractionRequest::getResponse() const 101 { 102 rtl::Reference< InteractionContinuation > xSelection = getSelection(); 103 if ( xSelection.is() ) 104 { 105 InteractionContinuation * pSelection = xSelection.get(); 106 107 uno::Reference< task::XInteractionAbort > xAbort( 108 pSelection, uno::UNO_QUERY ); 109 if ( xAbort.is() ) 110 return CONTINUATION_ABORT; 111 112 uno::Reference< task::XInteractionRetry > xRetry( 113 pSelection, uno::UNO_QUERY ); 114 if ( xRetry.is() ) 115 return CONTINUATION_RETRY; 116 117 uno::Reference< task::XInteractionApprove > xApprove( 118 pSelection, uno::UNO_QUERY ); 119 if ( xApprove.is() ) 120 return CONTINUATION_APPROVE; 121 122 uno::Reference< task::XInteractionDisapprove > xDisapprove( 123 pSelection, uno::UNO_QUERY ); 124 if ( xDisapprove.is() ) 125 return CONTINUATION_DISAPPROVE; 126 127 OSL_ENSURE( sal_False, 128 "SimpleInteractionRequest::getResponse - Unknown continuation!" ); 129 } 130 return CONTINUATION_UNKNOWN; 131 } 132 133