1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <osl/diagnose.h>
24 using namespace com::sun::star
;
25 using namespace ucbhelper
;
28 SimpleInteractionRequest::SimpleInteractionRequest(
29 const uno::Any
& rRequest
,
30 const sal_Int32 nContinuations
)
31 : InteractionRequest( rRequest
)
34 OSL_ENSURE( nContinuations
!= CONTINUATION_UNKNOWN
,
35 "SimpleInteractionRequest - No continuation!" );
37 sal_Int32 nLength
= 0;
39 uno::Reference
< task::XInteractionContinuation
> xAbort
;
40 uno::Reference
< task::XInteractionContinuation
> xRetry
;
41 uno::Reference
< task::XInteractionContinuation
> xApprove
;
42 uno::Reference
< task::XInteractionContinuation
> xDisapprove
;
44 if ( nContinuations
& CONTINUATION_ABORT
)
47 xAbort
= new InteractionAbort( this );
50 if ( nContinuations
& CONTINUATION_RETRY
)
53 xRetry
= new InteractionRetry( this );
56 if ( nContinuations
& CONTINUATION_APPROVE
)
59 xApprove
= new InteractionApprove( this );
62 if ( nContinuations
& CONTINUATION_DISAPPROVE
)
65 xDisapprove
= new InteractionDisapprove( this );
68 OSL_ENSURE( nLength
> 0,
69 "SimpleInteractionRequest - No continuation!" );
71 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> >
72 aContinuations( nLength
);
77 aContinuations
[ nLength
++ ] = xAbort
;
80 aContinuations
[ nLength
++ ] = xRetry
;
83 aContinuations
[ nLength
++ ] = xApprove
;
85 if ( xDisapprove
.is() )
86 aContinuations
[ nLength
++ ] = xDisapprove
;
88 setContinuations( aContinuations
);
92 sal_Int32
SimpleInteractionRequest::getResponse() const
94 rtl::Reference
< InteractionContinuation
> xSelection
= getSelection();
95 if ( xSelection
.is() )
97 InteractionContinuation
* pSelection
= xSelection
.get();
99 uno::Reference
< task::XInteractionAbort
> xAbort(
100 pSelection
, uno::UNO_QUERY
);
102 return CONTINUATION_ABORT
;
104 uno::Reference
< task::XInteractionRetry
> xRetry(
105 pSelection
, uno::UNO_QUERY
);
107 return CONTINUATION_RETRY
;
109 uno::Reference
< task::XInteractionApprove
> xApprove(
110 pSelection
, uno::UNO_QUERY
);
112 return CONTINUATION_APPROVE
;
114 uno::Reference
< task::XInteractionDisapprove
> xDisapprove(
115 pSelection
, uno::UNO_QUERY
);
116 if ( xDisapprove
.is() )
117 return CONTINUATION_DISAPPROVE
;
119 OSL_FAIL( "SimpleInteractionRequest::getResponse - Unknown continuation!" );
121 return CONTINUATION_UNKNOWN
;
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */