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 .
21 #include "interact.hxx"
23 #include <boost/noncopyable.hpp>
24 #include <com/sun/star/java/JavaDisabledException.hpp>
25 #include <com/sun/star/java/JavaVMCreationFailureException.hpp>
26 #include <com/sun/star/task/XInteractionAbort.hpp>
27 #include <com/sun/star/task/XInteractionRetry.hpp>
28 #include <com/sun/star/task/XInteractionContinuation.hpp>
29 #include <cppuhelper/implbase1.hxx>
30 #include <osl/mutex.hxx>
32 using stoc_javavm::InteractionRequest
;
36 class AbortContinuation
:
37 public cppu::WeakImplHelper1
<css::task::XInteractionAbort
>,
38 private boost::noncopyable
41 inline AbortContinuation() {}
43 virtual void SAL_CALL
select() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{}
46 virtual inline ~AbortContinuation() {}
51 class InteractionRequest::RetryContinuation
:
52 public cppu::WeakImplHelper1
<css::task::XInteractionRetry
>,
53 private boost::noncopyable
56 inline RetryContinuation(): m_bSelected(false) {}
58 virtual void SAL_CALL
select() throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
60 bool isSelected() const;
63 virtual inline ~RetryContinuation() {}
65 mutable osl::Mutex m_aMutex
;
69 void SAL_CALL
InteractionRequest::RetryContinuation::select()
70 throw (css::uno::RuntimeException
, std::exception
)
72 osl::MutexGuard
aGuard(m_aMutex
);
76 bool InteractionRequest::RetryContinuation::isSelected() const
78 osl::MutexGuard
aGuard(m_aMutex
);
82 InteractionRequest::InteractionRequest(css::uno::Any
const & rRequest
):
85 m_aContinuations
.realloc(2);
86 m_xRetryContinuation
= new RetryContinuation
;
87 m_aContinuations
[0] = new AbortContinuation
;
88 m_aContinuations
[1] = m_xRetryContinuation
.get();
91 css::uno::Any SAL_CALL
InteractionRequest::getRequest()
92 throw (css::uno::RuntimeException
, std::exception
)
97 css::uno::Sequence
< css::uno::Reference
< css::task::XInteractionContinuation
> >
98 SAL_CALL
InteractionRequest::getContinuations()
99 throw (css::uno::RuntimeException
, std::exception
)
101 return m_aContinuations
;
104 bool InteractionRequest::retry() const
106 return m_xRetryContinuation
.is() && m_xRetryContinuation
->isSelected();
109 InteractionRequest::~InteractionRequest()
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */