1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/beans/Optional.hpp>
29 #include <com/sun/star/task/InteractionClassification.hpp>
31 #include <vcl/errcode.hxx>
32 #include <unotools/resmgr.hxx>
34 #include <unordered_map>
37 namespace com::sun::star
{
45 class XMultiServiceFactory
;
48 struct DocumentSignatureInformation
;
51 class XInteractionContinuation
;
52 class XInteractionHandler2
;
53 class XInteractionRequest
;
56 class NameClashResolveRequest
;
60 struct InteractionHandlerData
62 /** The UNO service name to use to instantiate the content provider.
67 typedef std::vector
< InteractionHandlerData
> InteractionHandlerDataList
;
69 typedef std::unordered_map
< OUString
, OUString
> StringHashMap
;
71 class UUIInteractionHelper
74 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
75 css::uno::Reference
< css::awt::XWindow
> m_xWindowParam
;
76 OUString m_aContextParam
;
77 StringHashMap m_aTypedCustomHandlers
;
78 UUIInteractionHelper(UUIInteractionHelper
const &) = delete;
79 UUIInteractionHelper
& operator =(UUIInteractionHelper
const &) = delete;
82 explicit UUIInteractionHelper(
83 css::uno::Reference
< css::uno::XComponentContext
> xContext
);
85 const css::uno::Reference
<css::awt::XWindow
> & GetParentWindow() const { return m_xWindowParam
; }
86 void SetParentWindow(const css::uno::Reference
<css::awt::XWindow
>& rWindow
) { m_xWindowParam
= rWindow
; }
88 void setContext(OUString
const & context
) { m_aContextParam
= context
; }
90 ~UUIInteractionHelper();
92 bool handleRequest( css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
94 css::beans::Optional
< OUString
>
96 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
100 replaceMessageWithArguments(
101 const OUString
& aMessage
,
102 std::vector
< OUString
> const & rArguments
);
107 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
,
108 bool bObtainErrorStringOnly
,
109 bool & bHasErrorString
,
110 OUString
& rErrorString
);
112 static void handlerequest(void* pHandleData
, void* pInteractionHandler
);
114 css::beans::Optional
< OUString
>
115 getStringFromRequest_impl(
116 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
118 static void getstringfromrequest(void* pHandleData
, void* pInteractionHandler
);
120 const css::uno::Reference
< css::awt::XWindow
>&
121 getParentXWindow() const;
123 css::uno::Reference
< css::task::XInteractionHandler2
>
124 getInteractionHandler() const;
126 bool handleTypedHandlerImplementations(
127 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
131 tryOtherInteractionHandler(
132 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
135 getInteractionHandlerList(InteractionHandlerDataList
&rdataList
);
138 isInformationalErrorMessageRequest(
140 css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
);
143 handleInteractiveIOException(
144 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
,
145 bool bObtainErrorStringOnly
,
146 bool & bHasErrorString
,
147 OUString
& rErrorString
);
150 handleAuthenticationRequest(
151 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
154 handleCertificateValidationRequest(
155 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
158 handleNameClashResolveRequest(
159 css::ucb::NameClashResolveRequest
const & rRequest
,
161 css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
);
164 handleMasterPasswordRequest(
165 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
168 handlePasswordRequest(
169 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
172 handleNoSuchFilterRequest(
173 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
176 handleFilterOptionsRequest(
178 css::task::XInteractionRequest
> const & rRequest
);
181 handleErrorHandlerRequest(
182 css::task::InteractionClassification eClassification
,
184 std::vector
< OUString
> const & rArguments
,
186 css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
,
187 bool bObtainErrorStringOnly
,
188 bool & bHasErrorString
,
189 OUString
& rErrorString
);
192 handleGenericErrorRequest(
195 css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
,
196 bool bObtainErrorStringOnly
,
197 bool & bHasErrorString
,
198 OUString
& rErrorString
);
201 handleMacroConfirmRequest(
202 const OUString
& aDocumentURL
,
203 const css::uno::Reference
< css::embed::XStorage
>& xZipStorage
,
204 const OUString
& aDocumentVersion
,
205 const css::uno::Sequence
< css::security::DocumentSignatureInformation
>& aSignInfo
,
207 css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
);
210 handleBrokenPackageRequest(
211 std::vector
< OUString
> const & rArguments
,
213 css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
,
214 bool bObtainErrorStringOnly
,
215 bool & bHasErrorString
,
216 OUString
& rErrorString
);
218 bool handleLockedDocumentRequest(
219 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
221 bool handleChangedByOthersRequest(
223 css::task::XInteractionRequest
> const & rRequest
);
225 bool handleLockFileProblemRequest(
226 css::uno::Reference
< css::task::XInteractionRequest
> const & rRequest
);
228 bool handleReloadEditableRequest(
229 css::uno::Reference
<css::task::XInteractionRequest
> const& rRequest
);
231 bool handleCustomRequest(
232 const css::uno::Reference
< css::task::XInteractionRequest
>& i_rRequest
,
233 const OUString
& i_rServiceName
237 handleAuthFallbackRequest(
238 const OUString
& instructions
,
239 const OUString
& url
,
240 css::uno::Sequence
< css::uno::Reference
< css::task::XInteractionContinuation
> > const & rContinuations
);
245 const std::pair
<TranslateId
, ErrCode
>* m_pStringArray
;
246 const std::locale
& m_rResLocale
;
248 explicit ErrorResource(const std::pair
<TranslateId
, ErrCode
>* pStringArray
, const std::locale
& rResLocale
)
249 : m_pStringArray(pStringArray
)
250 , m_rResLocale(rResLocale
)
253 bool getString(ErrCode nErrorCode
, OUString
&rString
) const;
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */