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>
21 #include <comphelper/sequence.hxx>
23 #include <osl/diagnose.h>
24 #include <rtl/ref.hxx>
26 using namespace com::sun::star
;
27 using namespace ucbhelper
;
30 SimpleInteractionRequest::SimpleInteractionRequest(
31 const uno::Any
& rRequest
,
32 const ContinuationFlags nContinuations
)
33 : InteractionRequest( rRequest
)
36 OSL_ENSURE( nContinuations
!= ContinuationFlags::NONE
,
37 "SimpleInteractionRequest - No continuation!" );
39 std::vector
< uno::Reference
< task::XInteractionContinuation
> > aContinuations
;
40 if ( nContinuations
& ContinuationFlags::Abort
)
42 aContinuations
.push_back( new InteractionAbort( this ) );
44 if ( nContinuations
& ContinuationFlags::Retry
)
46 aContinuations
.push_back( new InteractionRetry( this ) );
48 if ( nContinuations
& ContinuationFlags::Approve
)
50 aContinuations
.push_back( new InteractionApprove( this ) );
52 if ( nContinuations
& ContinuationFlags::Disapprove
)
54 aContinuations
.push_back( new InteractionDisapprove( this ) );
56 setContinuations( comphelper::containerToSequence(aContinuations
) );
60 ContinuationFlags
SimpleInteractionRequest::getResponse() const
62 rtl::Reference
< InteractionContinuation
> xSelection
= getSelection();
63 if ( xSelection
.is() )
65 uno::Reference
< task::XInteractionAbort
> xAbort(
66 xSelection
->getXWeak(), uno::UNO_QUERY
);
68 return ContinuationFlags::Abort
;
70 uno::Reference
< task::XInteractionRetry
> xRetry(
71 xSelection
->getXWeak(), uno::UNO_QUERY
);
73 return ContinuationFlags::Retry
;
75 uno::Reference
< task::XInteractionApprove
> xApprove(
76 xSelection
->getXWeak(), uno::UNO_QUERY
);
78 return ContinuationFlags::Approve
;
80 uno::Reference
< task::XInteractionDisapprove
> xDisapprove(
81 xSelection
->getXWeak(), uno::UNO_QUERY
);
82 if ( xDisapprove
.is() )
83 return ContinuationFlags::Disapprove
;
85 OSL_FAIL( "SimpleInteractionRequest::getResponse - Unknown continuation!" );
87 return ContinuationFlags::NONE
;
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */