lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / ucbhelper / source / provider / simpleinteractionrequest.cxx
blobd846be5d352b7e36df6ab0bad4a1244301bc0933
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>
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 )
35 // Set continuations.
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 InteractionContinuation * pSelection = xSelection.get();
67 uno::Reference< task::XInteractionAbort > xAbort(
68 pSelection, uno::UNO_QUERY );
69 if ( xAbort.is() )
70 return ContinuationFlags::Abort;
72 uno::Reference< task::XInteractionRetry > xRetry(
73 pSelection, uno::UNO_QUERY );
74 if ( xRetry.is() )
75 return ContinuationFlags::Retry;
77 uno::Reference< task::XInteractionApprove > xApprove(
78 pSelection, uno::UNO_QUERY );
79 if ( xApprove.is() )
80 return ContinuationFlags::Approve;
82 uno::Reference< task::XInteractionDisapprove > xDisapprove(
83 pSelection, uno::UNO_QUERY );
84 if ( xDisapprove.is() )
85 return ContinuationFlags::Disapprove;
87 OSL_FAIL( "SimpleInteractionRequest::getResponse - Unknown continuation!" );
89 return ContinuationFlags::NONE;
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */