Branch data Line data Source code
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/java/JavaDisabledException.hpp"
24 : : #include "com/sun/star/java/JavaVMCreationFailureException.hpp"
25 : : #include "com/sun/star/task/XInteractionAbort.hpp"
26 : : #include "com/sun/star/task/XInteractionRetry.hpp"
27 : : #include "com/sun/star/task/XInteractionContinuation.hpp"
28 : : #include "cppuhelper/implbase1.hxx"
29 : : #include "osl/mutex.hxx"
30 : :
31 : : namespace css = com::sun::star;
32 : :
33 : : using stoc_javavm::InteractionRequest;
34 : :
35 : : namespace {
36 : :
37 : : class AbortContinuation:
38 : : public cppu::WeakImplHelper1< css::task::XInteractionAbort >
39 : : {
40 : : public:
41 : 0 : inline AbortContinuation() {}
42 : :
43 : 0 : virtual inline void SAL_CALL select() throw (css::uno::RuntimeException) {}
44 : :
45 : : private:
46 : : AbortContinuation(AbortContinuation &); // not implemented
47 : : void operator =(AbortContinuation); // not implemented
48 : :
49 [ # # ]: 0 : virtual inline ~AbortContinuation() {}
50 : : };
51 : :
52 : : }
53 : :
54 : : class InteractionRequest::RetryContinuation:
55 : : public cppu::WeakImplHelper1< css::task::XInteractionRetry >
56 : : {
57 : : public:
58 [ # # ]: 0 : inline RetryContinuation(): m_bSelected(false) {}
59 : :
60 : : virtual void SAL_CALL select() throw (css::uno::RuntimeException);
61 : :
62 : : bool isSelected() const;
63 : :
64 : : private:
65 : : RetryContinuation(RetryContinuation &); // not implemented
66 : : void operator =(RetryContinuation); // not implemented
67 : :
68 [ # # ][ # # ]: 0 : virtual inline ~RetryContinuation() {}
69 : :
70 : : mutable osl::Mutex m_aMutex;
71 : : bool m_bSelected;
72 : : };
73 : :
74 : 0 : void SAL_CALL InteractionRequest::RetryContinuation::select()
75 : : throw (css::uno::RuntimeException)
76 : : {
77 [ # # ]: 0 : osl::MutexGuard aGuard(m_aMutex);
78 [ # # ]: 0 : m_bSelected = true;
79 : 0 : }
80 : :
81 : 0 : bool InteractionRequest::RetryContinuation::isSelected() const
82 : : {
83 [ # # ]: 0 : osl::MutexGuard aGuard(m_aMutex);
84 [ # # ]: 0 : return m_bSelected;
85 : : }
86 : :
87 : 0 : InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
88 [ # # ]: 0 : m_aRequest(rRequest)
89 : : {
90 [ # # ]: 0 : m_aContinuations.realloc(2);
91 [ # # ][ # # ]: 0 : m_xRetryContinuation = new RetryContinuation;
92 [ # # ][ # # ]: 0 : m_aContinuations[0] = new AbortContinuation;
[ # # ][ # # ]
93 [ # # ][ # # ]: 0 : m_aContinuations[1] = m_xRetryContinuation.get();
[ # # ]
94 : 0 : }
95 : :
96 : 0 : css::uno::Any SAL_CALL InteractionRequest::getRequest()
97 : : throw (css::uno::RuntimeException)
98 : : {
99 : 0 : return m_aRequest;
100 : : }
101 : :
102 : : css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
103 : 0 : SAL_CALL InteractionRequest::getContinuations()
104 : : throw (css::uno::RuntimeException)
105 : : {
106 : 0 : return m_aContinuations;
107 : : }
108 : :
109 : 0 : bool InteractionRequest::retry() const
110 : : {
111 [ # # ][ # # ]: 0 : return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
112 : : }
113 : :
114 [ # # ]: 0 : InteractionRequest::~InteractionRequest()
115 [ # # ]: 0 : {}
116 : :
117 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|