LibreOffice Module stoc (master) 1
interact.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include "interact.hxx"
22
23#include <com/sun/star/task/XInteractionAbort.hpp>
24#include <com/sun/star/task/XInteractionRetry.hpp>
26#include <mutex>
27#include <utility>
28
29namespace com::sun::star::task { class XInteractionContinuation; }
30
32
33namespace {
34
35class AbortContinuation:
36 public cppu::WeakImplHelper<css::task::XInteractionAbort>
37{
38public:
39 AbortContinuation() {}
40 AbortContinuation(const AbortContinuation&) = delete;
41 AbortContinuation& operator=(const AbortContinuation&)= delete;
42
43 virtual void SAL_CALL select() override {}
44
45private:
46 virtual ~AbortContinuation() override {}
47};
48
49}
50
52 public cppu::WeakImplHelper<css::task::XInteractionRetry>
53{
54public:
58
59 virtual void SAL_CALL select() override;
60
61 bool isSelected() const;
62
63private:
64 virtual ~RetryContinuation() override {}
65
66 mutable std::mutex m_aMutex;
68};
69
71{
72 std::scoped_lock aGuard(m_aMutex);
73 m_bSelected = true;
74}
75
77{
78 std::scoped_lock aGuard(m_aMutex);
79 return m_bSelected;
80}
81
82InteractionRequest::InteractionRequest(css::uno::Any aRequest):
83 m_aRequest(std::move(aRequest))
84{
86 m_aContinuations = { new AbortContinuation, m_xRetryContinuation };
87}
88
89css::uno::Any SAL_CALL InteractionRequest::getRequest()
90{
91 return m_aRequest;
92}
93
94css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
96{
97 return m_aContinuations;
98}
99
101{
102 return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
103}
104
106{}
107
108/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RetryContinuation & operator=(const RetryContinuation &)=delete
virtual void SAL_CALL select() override
Definition: interact.cxx:70
RetryContinuation(const RetryContinuation &)=delete
css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > m_aContinuations
Definition: interact.hxx:59
rtl::Reference< RetryContinuation > m_xRetryContinuation
Definition: interact.hxx:60
virtual css::uno::Any SAL_CALL getRequest() override
Definition: interact.cxx:89
virtual ~InteractionRequest() override
Definition: interact.cxx:105
virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() override
Definition: interact.cxx:95
std::mutex m_aMutex
uno::Any m_aRequest