2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2002-12-06 09:48:59 +00:00
|
|
|
|
2006-09-16 16:30:44 +00:00
|
|
|
|
2002-07-23 13:07:24 +00:00
|
|
|
#include "interact.hxx"
|
|
|
|
|
2014-05-22 08:56:06 +02:00
|
|
|
#include <com/sun/star/task/XInteractionAbort.hpp>
|
|
|
|
#include <com/sun/star/task/XInteractionRetry.hpp>
|
2015-09-04 20:40:13 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2014-05-22 08:56:06 +02:00
|
|
|
#include <osl/mutex.hxx>
|
2002-09-16 11:30:42 +00:00
|
|
|
|
2019-05-12 02:20:12 +02:00
|
|
|
namespace com::sun::star::task { class XInteractionContinuation; }
|
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
using stoc_javavm::InteractionRequest;
|
|
|
|
|
|
|
|
namespace {
|
2002-07-23 13:07:24 +00:00
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
class AbortContinuation:
|
2016-04-13 10:11:37 +02:00
|
|
|
public cppu::WeakImplHelper<css::task::XInteractionAbort>
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2002-12-06 09:48:59 +00:00
|
|
|
public:
|
2017-03-03 20:57:02 +01:00
|
|
|
AbortContinuation() {}
|
2016-04-13 10:11:37 +02:00
|
|
|
AbortContinuation(const AbortContinuation&) = delete;
|
|
|
|
AbortContinuation& operator=(const AbortContinuation&)= delete;
|
2002-12-06 09:48:59 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL select() override {}
|
2002-12-06 09:48:59 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-03 20:57:02 +01:00
|
|
|
virtual ~AbortContinuation() override {}
|
2002-12-06 09:48:59 +00:00
|
|
|
};
|
|
|
|
|
2002-07-23 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
class InteractionRequest::RetryContinuation:
|
2016-04-13 10:11:37 +02:00
|
|
|
public cppu::WeakImplHelper<css::task::XInteractionRetry>
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2002-12-06 09:48:59 +00:00
|
|
|
public:
|
2017-03-03 20:57:02 +01:00
|
|
|
RetryContinuation(): m_bSelected(false) {}
|
2016-04-13 10:11:37 +02:00
|
|
|
RetryContinuation(const RetryContinuation&) = delete;
|
|
|
|
RetryContinuation& operator=(const RetryContinuation&) = delete;
|
2002-12-06 09:48:59 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL select() override;
|
2002-12-06 09:48:59 +00:00
|
|
|
|
|
|
|
bool isSelected() const;
|
|
|
|
|
|
|
|
private:
|
2017-03-03 20:57:02 +01:00
|
|
|
virtual ~RetryContinuation() override {}
|
2002-12-06 09:48:59 +00:00
|
|
|
|
|
|
|
mutable osl::Mutex m_aMutex;
|
|
|
|
bool m_bSelected;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SAL_CALL InteractionRequest::RetryContinuation::select()
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2002-12-06 09:48:59 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
m_bSelected = true;
|
2002-07-23 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
bool InteractionRequest::RetryContinuation::isSelected() const
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2002-12-06 09:48:59 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
return m_bSelected;
|
2002-07-23 13:07:24 +00:00
|
|
|
}
|
2002-12-06 09:48:59 +00:00
|
|
|
|
|
|
|
InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
|
|
|
|
m_aRequest(rRequest)
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2004-06-01 08:03:13 +00:00
|
|
|
m_aContinuations.realloc(2);
|
|
|
|
m_xRetryContinuation = new RetryContinuation;
|
2002-12-06 09:48:59 +00:00
|
|
|
m_aContinuations[0] = new AbortContinuation;
|
2004-06-01 08:03:13 +00:00
|
|
|
m_aContinuations[1] = m_xRetryContinuation.get();
|
2002-07-23 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
css::uno::Any SAL_CALL InteractionRequest::getRequest()
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2002-12-06 09:48:59 +00:00
|
|
|
return m_aRequest;
|
2002-07-23 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
|
|
|
|
SAL_CALL InteractionRequest::getContinuations()
|
2002-07-23 13:07:24 +00:00
|
|
|
{
|
2002-12-06 09:48:59 +00:00
|
|
|
return m_aContinuations;
|
2002-07-23 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
bool InteractionRequest::retry() const
|
|
|
|
{
|
|
|
|
return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
|
|
|
|
}
|
2002-07-23 13:07:24 +00:00
|
|
|
|
2002-12-06 09:48:59 +00:00
|
|
|
InteractionRequest::~InteractionRequest()
|
|
|
|
{}
|
2010-10-14 08:30:07 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|