Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/desktop/source/deployment/misc/dp_interact.cxx
Line
Count
Source
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 <dp_interact.h>
22
23
#include <comphelper/interaction.hxx>
24
25
#include <com/sun/star/task/XInteractionAbort.hpp>
26
#include <osl/diagnose.h>
27
28
29
using namespace ::com::sun::star;
30
using namespace ::com::sun::star::uno;
31
using namespace ::com::sun::star::ucb;
32
33
namespace dp_misc {
34
namespace {
35
36
37
class InteractionContinuationImpl : public ::cppu::OWeakObject,
38
                                    public task::XInteractionContinuation
39
{
40
    const Type m_type;
41
    bool * m_pselect;
42
43
public:
44
    InteractionContinuationImpl( Type const & type, bool * pselect )
45
0
        : m_type( type ),
46
0
          m_pselect( pselect )
47
0
        { OSL_ASSERT(
48
0
            cppu::UnoType<task::XInteractionContinuation>::get().isAssignableFrom(m_type) ); }
49
50
    // XInterface
51
    virtual void SAL_CALL acquire() noexcept override;
52
    virtual void SAL_CALL release() noexcept override;
53
    virtual Any SAL_CALL queryInterface( Type const & type ) override;
54
55
    // XInteractionContinuation
56
    virtual void SAL_CALL select() override;
57
};
58
59
// XInterface
60
61
void InteractionContinuationImpl::acquire() noexcept
62
0
{
63
0
    OWeakObject::acquire();
64
0
}
65
66
67
void InteractionContinuationImpl::release() noexcept
68
0
{
69
0
    OWeakObject::release();
70
0
}
71
72
73
Any InteractionContinuationImpl::queryInterface( Type const & type )
74
0
{
75
0
    if (type.isAssignableFrom( m_type )) {
76
0
        Reference<task::XInteractionContinuation> xThis(this);
77
0
        return Any( &xThis, type );
78
0
    }
79
0
    else
80
0
        return OWeakObject::queryInterface(type);
81
0
}
82
83
// XInteractionContinuation
84
85
void InteractionContinuationImpl::select()
86
0
{
87
0
    *m_pselect = true;
88
0
}
89
90
} // anon namespace
91
92
93
bool interactContinuation( Any const & request,
94
                           Type const & continuation,
95
                           Reference<XCommandEnvironment> const & xCmdEnv,
96
                           bool * pcont, bool * pabort )
97
0
{
98
0
    OSL_ASSERT(
99
0
        cppu::UnoType<task::XInteractionContinuation>::get().isAssignableFrom(
100
0
            continuation ) );
101
0
    if (!xCmdEnv)
102
0
        return false;
103
104
0
    Reference<task::XInteractionHandler> xInteractionHandler(
105
0
        xCmdEnv->getInteractionHandler() );
106
0
    if (!xInteractionHandler)
107
0
        return false;
108
109
0
    bool cont = false;
110
0
    bool abort = false;
111
0
    std::vector< Reference<task::XInteractionContinuation> > conts {
112
0
        new InteractionContinuationImpl(continuation, &cont ),
113
0
        new InteractionContinuationImpl( cppu::UnoType<task::XInteractionAbort>::get(), &abort ) };
114
0
    xInteractionHandler->handle(
115
0
        new ::comphelper::OInteractionRequest( request, std::move(conts) ) );
116
0
    if (cont || abort) {
117
0
        if (pcont != nullptr)
118
0
            *pcont = cont;
119
0
        if (pabort != nullptr)
120
0
            *pabort = abort;
121
0
        return true;
122
0
    }
123
0
    return false;
124
0
}
125
126
// XAbortChannel
127
128
void AbortChannel::sendAbort()
129
0
{
130
0
    m_aborted = true;
131
0
    if (m_xNext.is())
132
0
        m_xNext->sendAbort();
133
0
}
134
135
} // dp_misc
136
137
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */