From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- .../loadAllDocuments/InteractionHandler.java | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 framework/qa/complex/loadAllDocuments/InteractionHandler.java (limited to 'framework/qa/complex/loadAllDocuments/InteractionHandler.java') diff --git a/framework/qa/complex/loadAllDocuments/InteractionHandler.java b/framework/qa/complex/loadAllDocuments/InteractionHandler.java new file mode 100644 index 000000000..24cf6a151 --- /dev/null +++ b/framework/qa/complex/loadAllDocuments/InteractionHandler.java @@ -0,0 +1,122 @@ +/* + * 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 . + */ +package complex.loadAllDocuments; + +import com.sun.star.task.XInteractionHandler; +import com.sun.star.uno.AnyConverter; + + +/** + * Implements a simple interaction handler, + * which can abort all incoming interactions only ... but make it possible to + * log it. So it can be used for debug and test purposes. + */ +public class InteractionHandler implements XInteractionHandler +{ + + + /** + * @const RETRY_COUNT it defines the max count of + * retrying of an interaction + */ + private static final int RETRY_COUNT = 3; + + + + /** + * count using of RETRY continuations + */ + private int m_nTry ; + /** true if the interaction handler was used */ + private boolean m_bWasUsed ; + + + /** + * ctor + * It's initialize an object of this class with default values + * and set the protocol stack. So the outside code can check + * if this handler was used or not. + */ + public InteractionHandler() + { + m_nTry = 0 ; + m_bWasUsed = false; + } + + /** + * Called to start the interaction, because the outside code wish to solve + * a detected problem or to inform the user about something. + * We save the information here and can handle two well known continuations + * only. + * [abort and retry]. + * + * @param xRequest + * describe the interaction + */ + public void handle(com.sun.star.task.XInteractionRequest xRequest) + { + m_bWasUsed = true; + + // analyze the possible continuations. + // We can abort all incoming interactions only. + // But additional we can try to continue it several times too. + // Of course after e.g. three loops we have to stop and abort it. + com.sun.star.task.XInteractionContinuation[] lContinuations = xRequest.getContinuations(); + + com.sun.star.task.XInteractionAbort xAbort = null; + com.sun.star.task.XInteractionRetry xRetry = null; + com.sun.star.uno.Type xAbortType = new com.sun.star.uno.Type(com.sun.star.task.XInteractionAbort.class); + com.sun.star.uno.Type xRetryType = new com.sun.star.uno.Type(com.sun.star.task.XInteractionRetry.class); + + for (int i=0; i