Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/uui/source/iahndl.hxx
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
#pragma once
21
22
#include <rtl/ustring.hxx>
23
24
#include <com/sun/star/uno/Reference.hxx>
25
#include <com/sun/star/uno/Sequence.hxx>
26
#include <com/sun/star/uno/XComponentContext.hpp>
27
28
#include <com/sun/star/beans/Optional.hpp>
29
#include <com/sun/star/task/InteractionClassification.hpp>
30
31
#include <comphelper/errcode.hxx>
32
#include <unotools/resmgr.hxx>
33
34
#include <unordered_map>
35
#include <vector>
36
37
namespace com::sun::star {
38
    namespace awt {
39
        class XWindow;
40
    }
41
    namespace embed {
42
        class XStorage;
43
    }
44
    namespace security {
45
        struct DocumentSignatureInformation;
46
    }
47
    namespace task {
48
        class XInteractionContinuation;
49
        class XInteractionHandler2;
50
        class XInteractionRequest;
51
    }
52
    namespace ucb {
53
        class NameClashResolveRequest;
54
    }
55
}
56
57
typedef std::unordered_map< OUString, OUString >    StringHashMap;
58
59
class UUIInteractionHelper
60
{
61
private:
62
    css::uno::Reference< css::uno::XComponentContext >      m_xContext;
63
    css::uno::Reference< css::awt::XWindow >                m_xWindowParam;
64
    OUString                                                m_aContextParam;
65
    StringHashMap                                           m_aTypedCustomHandlers;
66
    UUIInteractionHelper(UUIInteractionHelper const &) = delete;
67
    UUIInteractionHelper& operator =(UUIInteractionHelper const &) = delete;
68
69
public:
70
    explicit UUIInteractionHelper(
71
        css::uno::Reference< css::uno::XComponentContext > xContext);
72
73
0
    const css::uno::Reference<css::awt::XWindow> & GetParentWindow() const { return m_xWindowParam; }
74
185k
    void SetParentWindow(const css::uno::Reference<css::awt::XWindow>& rWindow) { m_xWindowParam = rWindow; }
75
76
185k
    void setContext(OUString const & context) { m_aContextParam = context; }
77
78
    ~UUIInteractionHelper();
79
80
    bool handleRequest( css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
81
82
    css::beans::Optional< OUString >
83
    getStringFromRequest(
84
            css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
85
86
    // Helper.
87
    static OUString
88
    replaceMessageWithArguments(
89
            const OUString& aMessage,
90
            std::vector< OUString > const & rArguments );
91
92
private:
93
    bool
94
    handleRequest_impl(
95
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest,
96
        bool bObtainErrorStringOnly,
97
        bool & bHasErrorString,
98
        OUString & rErrorString);
99
100
    static void handlerequest(void* pHandleData, void* pInteractionHandler);
101
102
    css::beans::Optional< OUString >
103
    getStringFromRequest_impl(
104
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
105
106
    static void getstringfromrequest(void* pHandleData, void* pInteractionHandler);
107
108
    const css::uno::Reference< css::awt::XWindow>&
109
    getParentXWindow() const;
110
111
    css::uno::Reference< css::task::XInteractionHandler2 >
112
    getInteractionHandler() const;
113
114
    bool    handleTypedHandlerImplementations(
115
                css::uno::Reference< css::task::XInteractionRequest > const &  rRequest
116
            );
117
118
    static bool
119
    isInformationalErrorMessageRequest(
120
        css::uno::Sequence<
121
            css::uno::Reference< css::task::XInteractionContinuation > > const &  rContinuations);
122
123
    bool
124
    handleInteractiveIOException(
125
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest,
126
        bool bObtainErrorStringOnly,
127
        bool & bHasErrorString,
128
        OUString & rErrorString);
129
130
    bool
131
    handleAuthenticationRequest(
132
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
133
134
    bool
135
    handleCertificateValidationRequest(
136
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
137
138
    void
139
    handleNameClashResolveRequest(
140
        css::ucb::NameClashResolveRequest const & rRequest,
141
        css::uno::Sequence<
142
            css::uno::Reference< css::task::XInteractionContinuation > > const & rContinuations);
143
144
    bool
145
    handleMasterPasswordRequest(
146
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
147
148
    bool
149
    handlePasswordRequest(
150
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
151
152
    bool
153
    handleNoSuchFilterRequest(
154
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
155
156
    bool
157
    handleFilterOptionsRequest(
158
        css::uno::Reference<
159
            css::task::XInteractionRequest > const & rRequest);
160
161
    void
162
    handleErrorHandlerRequest(
163
        css::task::InteractionClassification eClassification,
164
        ErrCode nErrorCode,
165
        std::vector< OUString > const & rArguments,
166
        css::uno::Sequence<
167
            css::uno::Reference< css::task::XInteractionContinuation > > const &  rContinuations,
168
        bool bObtainErrorStringOnly,
169
        bool & bHasErrorString,
170
        OUString & rErrorString);
171
172
    void
173
    handleGenericErrorRequest(
174
        ErrCodeMsg nErrorCode,
175
        css::uno::Sequence<
176
            css::uno::Reference< css::task::XInteractionContinuation > > const &  rContinuations,
177
        bool bObtainErrorStringOnly,
178
        bool & bHasErrorString,
179
        OUString & rErrorString);
180
181
    void
182
    handleMacroConfirmRequest(
183
        const OUString& aDocumentURL,
184
        const css::uno::Reference< css::embed::XStorage >& xZipStorage,
185
        const OUString& aDocumentVersion,
186
        const css::uno::Sequence< css::security::DocumentSignatureInformation >& aSignInfo,
187
        css::uno::Sequence<
188
            css::uno::Reference< css::task::XInteractionContinuation > > const &  rContinuations);
189
190
    void
191
    handleBrokenPackageRequest(
192
        std::vector< OUString > const & rArguments,
193
        css::uno::Sequence<
194
            css::uno::Reference< css::task::XInteractionContinuation > > const & rContinuations,
195
        bool bObtainErrorStringOnly,
196
        bool & bHasErrorString,
197
        OUString & rErrorString);
198
199
    bool handleFontsDisallowEditingRequest(
200
        const css::uno::Reference<css::task::XInteractionRequest>& rRequest);
201
202
    bool handleLockedDocumentRequest(
203
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
204
205
    bool handleChangedByOthersRequest(
206
        css::uno::Reference<
207
            css::task::XInteractionRequest > const & rRequest);
208
209
    bool handleLockFileProblemRequest(
210
        css::uno::Reference< css::task::XInteractionRequest > const & rRequest);
211
212
    bool handleReloadEditableRequest(
213
        css::uno::Reference<css::task::XInteractionRequest> const& rRequest);
214
215
    bool handleCustomRequest(
216
                const css::uno::Reference< css::task::XInteractionRequest >& i_rRequest,
217
                const OUString& i_rServiceName
218
            ) const;
219
220
    void
221
    handleAuthFallbackRequest(
222
            const OUString & instructions,
223
            const OUString & url,
224
            css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > const & rContinuations );
225
226
    void
227
    handleLoadReadOnlyRequest(
228
        const OUString& sDocumentURL,
229
        css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > const & rContinuations);
230
};
231
232
class ErrorResource
233
{
234
    const std::pair<TranslateId, ErrCode>* m_pStringArray;
235
    const std::locale& m_rResLocale;
236
public:
237
    explicit ErrorResource(const std::pair<TranslateId, ErrCode>* pStringArray, const std::locale& rResLocale)
238
0
        : m_pStringArray(pStringArray)
239
0
        , m_rResLocale(rResLocale)
240
0
    {
241
0
    }
242
    bool getString(ErrCode nErrorCode, OUString &rString) const;
243
};
244
245
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */