Bump version to 21.06.18.1
[LibreOffice.git] / stoc / source / javavm / interact.cxx
blob58be91615d2fa413caaef34ff82eff2b0c5c8b26
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 .
21 #include "interact.hxx"
23 #include <com/sun/star/task/XInteractionAbort.hpp>
24 #include <com/sun/star/task/XInteractionRetry.hpp>
25 #include <cppuhelper/implbase.hxx>
26 #include <osl/mutex.hxx>
28 namespace com::sun::star::task { class XInteractionContinuation; }
30 using stoc_javavm::InteractionRequest;
32 namespace {
34 class AbortContinuation:
35 public cppu::WeakImplHelper<css::task::XInteractionAbort>
37 public:
38 AbortContinuation() {}
39 AbortContinuation(const AbortContinuation&) = delete;
40 AbortContinuation& operator=(const AbortContinuation&)= delete;
42 virtual void SAL_CALL select() override {}
44 private:
45 virtual ~AbortContinuation() override {}
50 class InteractionRequest::RetryContinuation:
51 public cppu::WeakImplHelper<css::task::XInteractionRetry>
53 public:
54 RetryContinuation(): m_bSelected(false) {}
55 RetryContinuation(const RetryContinuation&) = delete;
56 RetryContinuation& operator=(const RetryContinuation&) = delete;
58 virtual void SAL_CALL select() override;
60 bool isSelected() const;
62 private:
63 virtual ~RetryContinuation() override {}
65 mutable osl::Mutex m_aMutex;
66 bool m_bSelected;
69 void SAL_CALL InteractionRequest::RetryContinuation::select()
71 osl::MutexGuard aGuard(m_aMutex);
72 m_bSelected = true;
75 bool InteractionRequest::RetryContinuation::isSelected() const
77 osl::MutexGuard aGuard(m_aMutex);
78 return m_bSelected;
81 InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
82 m_aRequest(rRequest)
84 m_aContinuations.realloc(2);
85 m_xRetryContinuation = new RetryContinuation;
86 m_aContinuations[0] = new AbortContinuation;
87 m_aContinuations[1] = m_xRetryContinuation.get();
90 css::uno::Any SAL_CALL InteractionRequest::getRequest()
92 return m_aRequest;
95 css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
96 SAL_CALL InteractionRequest::getContinuations()
98 return m_aContinuations;
101 bool InteractionRequest::retry() const
103 return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
106 InteractionRequest::~InteractionRequest()
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */