Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / ucbhelper / source / provider / simpleinteractionrequest.cxx
blobc592c59936073dc08aeafb305416b442e9c8151a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ucbhelper/simpleinteractionrequest.hxx>
22 using namespace com::sun::star;
23 using namespace ucbhelper;
25 //=========================================================================
26 SimpleInteractionRequest::SimpleInteractionRequest(
27 const uno::Any & rRequest,
28 const sal_Int32 nContinuations )
29 : InteractionRequest( rRequest )
31 // Set continuations.
32 OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN,
33 "SimpleInteractionRequest - No continuation!" );
35 sal_Int32 nLength = 0;
37 uno::Reference< task::XInteractionContinuation > xAbort;
38 uno::Reference< task::XInteractionContinuation > xRetry;
39 uno::Reference< task::XInteractionContinuation > xApprove;
40 uno::Reference< task::XInteractionContinuation > xDisapprove;
42 if ( nContinuations & CONTINUATION_ABORT )
44 ++nLength;
45 xAbort = new InteractionAbort( this );
48 if ( nContinuations & CONTINUATION_RETRY )
50 ++nLength;
51 xRetry = new InteractionRetry( this );
54 if ( nContinuations & CONTINUATION_APPROVE )
56 ++nLength;
57 xApprove = new InteractionApprove( this );
60 if ( nContinuations & CONTINUATION_DISAPPROVE )
62 ++nLength;
63 xDisapprove = new InteractionDisapprove( this );
66 OSL_ENSURE( nLength > 0,
67 "SimpleInteractionRequest - No continuation!" );
69 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
70 aContinuations( nLength );
72 nLength = 0;
74 if ( xAbort.is() )
75 aContinuations[ nLength++ ] = xAbort;
77 if ( xRetry.is() )
78 aContinuations[ nLength++ ] = xRetry;
80 if ( xApprove.is() )
81 aContinuations[ nLength++ ] = xApprove;
83 if ( xDisapprove.is() )
84 aContinuations[ nLength++ ] = xDisapprove;
86 setContinuations( aContinuations );
89 //=========================================================================
90 sal_Int32 SimpleInteractionRequest::getResponse() const
92 rtl::Reference< InteractionContinuation > xSelection = getSelection();
93 if ( xSelection.is() )
95 InteractionContinuation * pSelection = xSelection.get();
97 uno::Reference< task::XInteractionAbort > xAbort(
98 pSelection, uno::UNO_QUERY );
99 if ( xAbort.is() )
100 return CONTINUATION_ABORT;
102 uno::Reference< task::XInteractionRetry > xRetry(
103 pSelection, uno::UNO_QUERY );
104 if ( xRetry.is() )
105 return CONTINUATION_RETRY;
107 uno::Reference< task::XInteractionApprove > xApprove(
108 pSelection, uno::UNO_QUERY );
109 if ( xApprove.is() )
110 return CONTINUATION_APPROVE;
112 uno::Reference< task::XInteractionDisapprove > xDisapprove(
113 pSelection, uno::UNO_QUERY );
114 if ( xDisapprove.is() )
115 return CONTINUATION_DISAPPROVE;
117 OSL_FAIL( "SimpleInteractionRequest::getResponse - Unknown continuation!" );
119 return CONTINUATION_UNKNOWN;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */