Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/uui/source/iahndl.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
#include <memory>
21
22
#include <com/sun/star/awt/XWindow.hpp>
23
#include <com/sun/star/configuration/theDefaultProvider.hpp>
24
#include <com/sun/star/configuration/backend/MergeRecoveryRequest.hpp>
25
#include <com/sun/star/configuration/backend/StratumCreationException.hpp>
26
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
27
#include <com/sun/star/document/BrokenPackageRequest.hpp>
28
#include <com/sun/star/document/ExoticFileLoadException.hpp>
29
#include <com/sun/star/document/FontsDisallowEditingRequest.hpp>
30
#include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
31
#include <com/sun/star/java/WrongJavaVersionException.hpp>
32
#include <com/sun/star/lang/XInitialization.hpp>
33
#include <com/sun/star/script/ModuleSizeExceededRequest.hpp>
34
#include <com/sun/star/task/ErrorCodeIOException.hpp>
35
#include <com/sun/star/task/ErrorCodeRequest2.hpp>
36
#include <com/sun/star/task/InteractionHandler.hpp>
37
#include <com/sun/star/task/XInteractionAbort.hpp>
38
#include <com/sun/star/task/XInteractionApprove.hpp>
39
#include <com/sun/star/task/XInteractionDisapprove.hpp>
40
#include <com/sun/star/task/XInteractionHandler2.hpp>
41
#include <com/sun/star/task/XInteractionRequest.hpp>
42
#include <com/sun/star/ucb/AuthenticationFallbackRequest.hpp>
43
#include <com/sun/star/ucb/InteractiveAppException.hpp>
44
#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
45
#include <com/sun/star/ucb/InteractiveLockingNotLockedException.hpp>
46
#include <com/sun/star/ucb/InteractiveLockingLockExpiredException.hpp>
47
#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
48
#include <com/sun/star/ucb/InteractiveNetworkOffLineException.hpp>
49
#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
50
#include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp>
51
#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
52
#include <com/sun/star/ucb/InteractiveWrongMediumException.hpp>
53
#include <com/sun/star/ucb/NameClashException.hpp>
54
#include <com/sun/star/ucb/NameClashResolveRequest.hpp>
55
#include <com/sun/star/ucb/UnsupportedNameClashException.hpp>
56
#include <com/sun/star/ucb/XInteractionReplaceExistingData.hpp>
57
#include <com/sun/star/ucb/XInteractionSupplyName.hpp>
58
#include <com/sun/star/xforms/InvalidDataOnSubmitException.hpp>
59
#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
60
61
#include <sal/log.hxx>
62
#include <rtl/ustrbuf.hxx>
63
#include <osl/conditn.hxx>
64
#include <unotools/resmgr.hxx>
65
#include <utility>
66
#include <vcl/errinf.hxx>
67
#include <vcl/svapp.hxx>
68
#include <vcl/weld/weld.hxx>
69
#include <comphelper/diagnose_ex.hxx>
70
#include <comphelper/documentconstants.hxx>
71
#include <comphelper/propertysequence.hxx>
72
#include <svtools/sfxecode.hxx>
73
#include <unotools/configmgr.hxx>
74
#include <comphelper/namedvaluecollection.hxx>
75
#include <typelib/typedescription.hxx>
76
#include <unotools/confignode.hxx>
77
78
#include <ids.hxx>
79
#include <ids.hrc>
80
#include <strings.hrc>
81
82
#include "getcontinuations.hxx"
83
#include "secmacrowarnings.hxx"
84
85
#include "iahndl.hxx"
86
#include "nameclashdlg.hxx"
87
#include <comphelper/string.hxx>
88
89
using ::com::sun::star::uno::Sequence;
90
using ::com::sun::star::uno::UNO_QUERY;
91
using ::com::sun::star::uno::Reference;
92
using ::com::sun::star::task::XInteractionContinuation;
93
using ::com::sun::star::task::XInteractionAbort;
94
using ::com::sun::star::task::XInteractionApprove;
95
using ::com::sun::star::lang::XInitialization;
96
using ::com::sun::star::uno::UNO_QUERY_THROW;
97
using ::com::sun::star::task::InteractionHandler;
98
using ::com::sun::star::task::XInteractionHandler2;
99
using ::com::sun::star::uno::Exception;
100
using ::com::sun::star::uno::Any;
101
using ::com::sun::star::task::XInteractionRequest;
102
103
using namespace ::com::sun::star;
104
105
namespace {
106
107
class HandleData : public osl::Condition
108
{
109
public:
110
    explicit HandleData(
111
        uno::Reference< task::XInteractionRequest > xRequest)
112
0
        : m_rRequest(std::move(xRequest)),
113
0
          bHandled( false )
114
0
    {
115
0
    }
116
    uno::Reference< task::XInteractionRequest > m_rRequest;
117
    bool                                        bHandled;
118
    beans::Optional< OUString >            m_aResult;
119
};
120
121
} /* namespace */
122
123
UUIInteractionHelper::UUIInteractionHelper(
124
    uno::Reference< uno::XComponentContext > xContext)
125
215k
    :  m_xContext(std::move(xContext))
126
215k
{
127
215k
}
128
129
UUIInteractionHelper::~UUIInteractionHelper()
130
215k
{
131
215k
}
132
133
void UUIInteractionHelper::handlerequest(
134
    void* pHandleData, void* pInteractionHelper)
135
0
{
136
0
    HandleData* pHND
137
0
        = static_cast< HandleData * >(pHandleData);
138
0
    UUIInteractionHelper* pUUI
139
0
        = static_cast< UUIInteractionHelper * >(pInteractionHelper);
140
0
    bool bDummy = false;
141
0
    OUString aDummy;
142
0
    try
143
0
    {
144
0
        pHND->bHandled
145
0
            = pUUI->handleRequest_impl(pHND->m_rRequest, false, bDummy, aDummy);
146
0
        pHND->set();
147
0
    }
148
0
    catch (css::uno::Exception&)
149
0
    {
150
0
        TOOLS_WARN_EXCEPTION("uui", "");
151
0
    }
152
0
}
153
154
bool
155
UUIInteractionHelper::handleRequest(
156
    uno::Reference< task::XInteractionRequest > const & rRequest)
157
0
{
158
0
    if(!Application::IsMainThread() && GetpApp())
159
0
    {
160
        // we are not in the main thread, let it handle that stuff
161
0
        HandleData aHD(rRequest);
162
0
        Link<void*,void> aLink = LINK_NONMEMBER(&aHD,handlerequest);
163
0
        Application::PostUserEvent(aLink,this);
164
0
        comphelper::SolarMutex& rSolarMutex = Application::GetSolarMutex();
165
0
        sal_uInt32 nLockCount = (rSolarMutex.IsCurrentThread()) ? rSolarMutex.release(true) : 0;
166
0
        aHD.wait();
167
0
        if (nLockCount)
168
0
            rSolarMutex.acquire(nLockCount);
169
0
        return aHD.bHandled;
170
0
    }
171
0
    else
172
0
    {
173
0
        bool bDummy = false;
174
0
        OUString aDummy;
175
0
        return handleRequest_impl(rRequest, false, bDummy, aDummy);
176
0
    }
177
0
}
178
179
void UUIInteractionHelper::getstringfromrequest(
180
    void* pHandleData,void* pInteractionHelper)
181
0
{
182
0
    HandleData* pHND = static_cast<HandleData*>(pHandleData);
183
0
    UUIInteractionHelper* pUUI = static_cast<UUIInteractionHelper*>(pInteractionHelper);
184
0
    pHND->m_aResult = pUUI->getStringFromRequest_impl(pHND->m_rRequest);
185
0
    pHND->set();
186
0
}
187
188
beans::Optional< OUString >
189
UUIInteractionHelper::getStringFromRequest_impl(
190
    uno::Reference< task::XInteractionRequest > const & rRequest)
191
0
{
192
0
    bool bSuccess = false;
193
0
    OUString aMessage;
194
0
    handleRequest_impl(rRequest, true, bSuccess, aMessage);
195
196
0
    OSL_ENSURE(bSuccess ||
197
0
               !isInformationalErrorMessageRequest(
198
0
                   rRequest->getContinuations()),
199
0
               "Interaction request is a candidate for a string representation."
200
0
               "Please implement!");
201
202
0
    return beans::Optional< OUString >(bSuccess, aMessage);
203
0
}
204
205
beans::Optional< OUString >
206
UUIInteractionHelper::getStringFromRequest(
207
    uno::Reference< task::XInteractionRequest > const & rRequest)
208
0
{
209
0
    if(!Application::IsMainThread() && GetpApp())
210
0
    {
211
        // we are not in the main thread, let it handle that stuff
212
0
        HandleData aHD(rRequest);
213
0
        Link<void*,void> aLink = LINK_NONMEMBER(&aHD,getstringfromrequest);
214
0
        Application::PostUserEvent(aLink,this);
215
0
        comphelper::SolarMutex& rSolarMutex = Application::GetSolarMutex();
216
0
        sal_uInt32 nLockCount = (rSolarMutex.IsCurrentThread()) ? rSolarMutex.release(true) : 0;
217
0
        aHD.wait();
218
0
        if (nLockCount)
219
0
            rSolarMutex.acquire(nLockCount);
220
0
        return aHD.m_aResult;
221
0
    }
222
0
    else
223
0
        return getStringFromRequest_impl(rRequest);
224
0
}
225
226
OUString
227
UUIInteractionHelper::replaceMessageWithArguments(
228
    const OUString& _aMessage,
229
    std::vector< OUString > const & rArguments )
230
0
{
231
0
    OUString aMessage = _aMessage;
232
233
0
    SAL_WARN_IF(rArguments.empty(), "uui", "replaceMessageWithArguments: No arguments passed!");
234
0
    for (size_t i = 0; i < rArguments.size(); ++i)
235
0
    {
236
0
        const OUString sReplaceTemplate = "$(ARG" + OUString::number(i+1) + ")";
237
0
        aMessage = aMessage.replaceAll(sReplaceTemplate, rArguments[i]);
238
0
    }
239
240
0
    return aMessage;
241
0
}
242
243
bool
244
UUIInteractionHelper::isInformationalErrorMessageRequest(
245
    uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
246
        rContinuations)
247
0
{
248
    // Only requests with a single continuation (user has no choice, request
249
    // is just informational)
250
0
    if (rContinuations.getLength() != 1 )
251
0
        return false;
252
253
    // user can only abort or approve, all other continuations are not
254
    // considered to be informational.
255
0
    uno::Reference< task::XInteractionApprove > xApprove(
256
0
        rContinuations[0], uno::UNO_QUERY);
257
0
    if (xApprove.is())
258
0
        return true;
259
260
0
    uno::Reference< task::XInteractionAbort > xAbort(
261
0
        rContinuations[0], uno::UNO_QUERY);
262
0
    return xAbort.is();
263
0
}
264
265
namespace
266
{
267
268
    bool lcl_matchesRequest( const Any& i_rRequest, const OUString& i_rTypeName, std::u16string_view i_rPropagation )
269
0
    {
270
0
        const css::uno::TypeDescription aTypeDesc( i_rTypeName );
271
0
        const typelib_TypeDescription* pTypeDesc = aTypeDesc.get();
272
0
        if ( !pTypeDesc || !pTypeDesc->pWeakRef )
273
0
        {
274
0
            SAL_WARN( "uui","no type found for '" << i_rTypeName << "'" );
275
0
            return false;
276
0
        }
277
0
        const css::uno::Type aType( pTypeDesc->pWeakRef );
278
279
0
        const bool bExactMatch = i_rPropagation == u"named-only";
280
0
        if ( bExactMatch )
281
0
            return i_rRequest.getValueType().equals( aType );
282
283
0
        return i_rRequest.isExtractableTo( aType );
284
0
    }
285
}
286
287
288
bool UUIInteractionHelper::handleCustomRequest( const Reference< XInteractionRequest >& i_rRequest, const OUString& i_rServiceName ) const
289
0
{
290
0
    try
291
0
    {
292
0
        Reference< XInteractionHandler2 > xHandler( m_xContext->getServiceManager()->createInstanceWithContext( i_rServiceName, m_xContext ), UNO_QUERY_THROW );
293
294
0
        Reference< XInitialization > xHandlerInit( xHandler, UNO_QUERY );
295
0
        if ( xHandlerInit.is() )
296
0
        {
297
0
            ::comphelper::NamedValueCollection aInitArgs;
298
0
            aInitArgs.put( u"Parent"_ustr, getParentXWindow() );
299
0
            xHandlerInit->initialize( aInitArgs.getWrappedPropertyValues() );
300
0
        }
301
302
0
        if ( xHandler->handleInteractionRequest( i_rRequest ) )
303
0
            return true;
304
0
    }
305
0
    catch( const Exception& )
306
0
    {
307
0
        DBG_UNHANDLED_EXCEPTION("uui");
308
0
    }
309
0
    return false;
310
0
}
311
312
313
bool UUIInteractionHelper::handleTypedHandlerImplementations( Reference< XInteractionRequest > const & rRequest )
314
0
{
315
    // the request
316
0
    const Any aRequest( rRequest->getRequest() );
317
318
0
    const StringHashMap::const_iterator aCacheHitTest = m_aTypedCustomHandlers.find( aRequest.getValueTypeName() );
319
0
    if ( aCacheHitTest != m_aTypedCustomHandlers.end() )
320
0
        return handleCustomRequest( rRequest, aCacheHitTest->second );
321
322
    // the base registration node for "typed" interaction handlers
323
0
    const ::utl::OConfigurationTreeRoot aConfigRoot( ::utl::OConfigurationTreeRoot::createWithComponentContext(
324
0
        m_xContext,
325
0
        u"/org.openoffice.Interaction/InteractionHandlers"_ustr,
326
0
        -1,
327
0
        ::utl::OConfigurationTreeRoot::CM_READONLY
328
0
    ) );
329
330
    // loop through all registered implementations
331
0
    const Sequence< OUString > aRegisteredHandlers( aConfigRoot.getNodeNames() );
332
0
    for ( auto const & handlerName : aRegisteredHandlers )
333
0
    {
334
0
        const ::utl::OConfigurationNode aHandlerNode( aConfigRoot.openNode( handlerName ) );
335
0
        const ::utl::OConfigurationNode aTypesNode( aHandlerNode.openNode( u"HandledRequestTypes"_ustr ) );
336
337
        // loop through all the types which the current handler is registered for
338
0
        const Sequence< OUString > aHandledTypes( aTypesNode.getNodeNames() );
339
0
        for ( auto const & type : aHandledTypes )
340
0
        {
341
            // the UNO type is the node name
342
0
            ::utl::OConfigurationNode aType( aTypesNode.openNode( type ) );
343
            // and there's a child denoting how the responsibility propagates
344
0
            OUString sPropagation;
345
0
            OSL_VERIFY( aType.getNodeValue( u"Propagation"_ustr ) >>= sPropagation );
346
0
            if ( lcl_matchesRequest( aRequest, type, sPropagation ) )
347
0
            {
348
                // retrieve the service/implementation name of the handler
349
0
                OUString sServiceName;
350
0
                OSL_VERIFY( aHandlerNode.getNodeValue( u"ServiceName"_ustr ) >>= sServiceName );
351
                // cache the information who feels responsible for requests of this type
352
0
                m_aTypedCustomHandlers[ aRequest.getValueTypeName() ] = sServiceName;
353
                // actually handle the request
354
0
                return handleCustomRequest( rRequest, sServiceName );
355
0
            }
356
0
        }
357
0
    }
358
359
0
    return false;
360
0
}
361
362
bool
363
UUIInteractionHelper::handleRequest_impl(
364
    uno::Reference< task::XInteractionRequest > const & rRequest,
365
    bool bObtainErrorStringOnly,
366
    bool & bHasErrorString,
367
    OUString & rErrorString)
368
0
{
369
0
    try
370
0
    {
371
0
        if (!rRequest.is())
372
0
            return false;
373
374
0
        uno::Any aAnyRequest(rRequest->getRequest());
375
376
0
        script::ModuleSizeExceededRequest aModSizeException;
377
0
        if (aAnyRequest >>= aModSizeException )
378
0
        {
379
0
            std::vector< OUString > aArguments;
380
0
            aArguments.push_back(
381
0
                comphelper::string::convertCommaSeparated(aModSizeException.Names));
382
0
            handleErrorHandlerRequest( task::InteractionClassification_WARNING,
383
0
                                       ERRCODE_UUI_IO_MODULESIZEEXCEEDED,
384
0
                                       aArguments,
385
0
                                       rRequest->getContinuations(),
386
0
                                       bObtainErrorStringOnly,
387
0
                                       bHasErrorString,
388
0
                                       rErrorString);
389
0
            return true;
390
0
        }
391
392
0
        document::ExoticFileLoadException aExoticFileLoadException;
393
0
        if (aAnyRequest >>= aExoticFileLoadException)
394
0
        {
395
0
            std::vector< OUString > aArguments;
396
397
0
            if( !aExoticFileLoadException.URL.isEmpty() )
398
0
            {
399
0
                aArguments.push_back( aExoticFileLoadException.URL );
400
0
            }
401
0
            if( !aExoticFileLoadException.FilterUIName.isEmpty() )
402
0
            {
403
0
                aArguments.push_back( aExoticFileLoadException.FilterUIName );
404
0
            }
405
406
0
            handleErrorHandlerRequest( task::InteractionClassification_WARNING,
407
0
                                       ERRCODE_UUI_IO_EXOTICFILEFORMAT,
408
0
                                       aArguments,
409
0
                                       rRequest->getContinuations(),
410
0
                                       bObtainErrorStringOnly,
411
0
                                       bHasErrorString,
412
0
                                       rErrorString);
413
0
            return true;
414
0
        }
415
416
0
        ucb::NameClashException aNCException;
417
0
        if (aAnyRequest >>= aNCException)
418
0
        {
419
0
            ErrCode nErrorCode = ERRCODE_UUI_IO_TARGETALREADYEXISTS;
420
0
            std::vector< OUString > aArguments;
421
422
0
            if( !aNCException.Name.isEmpty() )
423
0
            {
424
0
                nErrorCode = ERRCODE_UUI_IO_ALREADYEXISTS;
425
0
                aArguments.push_back( aNCException.Name );
426
0
            }
427
428
0
            handleErrorHandlerRequest( aNCException.Classification,
429
0
                                       nErrorCode,
430
0
                                       aArguments,
431
0
                                       rRequest->getContinuations(),
432
0
                                       bObtainErrorStringOnly,
433
0
                                       bHasErrorString,
434
0
                                       rErrorString);
435
0
            return true;
436
0
        }
437
438
0
        ucb::UnsupportedNameClashException aUORequest;
439
0
        if (aAnyRequest >>= aUORequest)
440
0
        {
441
442
0
            uno::Reference< task::XInteractionApprove > xApprove;
443
0
            uno::Reference< task::XInteractionDisapprove > xDisapprove;
444
0
            getContinuations(
445
0
                rRequest->getContinuations(), &xApprove, &xDisapprove);
446
447
0
            if ( xApprove.is() && xDisapprove.is() )
448
0
            {
449
0
                std::vector< OUString > aArguments;
450
0
                handleErrorHandlerRequest( task::InteractionClassification_QUERY,
451
0
                                           ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE,
452
0
                                           aArguments,
453
0
                                           rRequest->getContinuations(),
454
0
                                           bObtainErrorStringOnly,
455
0
                                           bHasErrorString,
456
0
                                           rErrorString);
457
0
            }
458
0
            return true;
459
0
        }
460
461
0
        if ( handleInteractiveIOException( rRequest,
462
0
                                           bObtainErrorStringOnly,
463
0
                                           bHasErrorString,
464
0
                                           rErrorString ) )
465
0
            return true;
466
467
0
        ucb::InteractiveAppException aAppException;
468
0
        if (aAnyRequest >>= aAppException)
469
0
        {
470
0
            std::vector< OUString > aArguments;
471
0
            handleErrorHandlerRequest( aAppException.Classification,
472
0
                                       ErrCode(aAppException.Code),
473
0
                                       aArguments,
474
0
                                       rRequest->getContinuations(),
475
0
                                       bObtainErrorStringOnly,
476
0
                                       bHasErrorString,
477
0
                                       rErrorString);
478
0
            return true;
479
0
        }
480
481
0
        ucb::InteractiveNetworkException aNetworkException;
482
0
        if (aAnyRequest >>= aNetworkException)
483
0
        {
484
0
            ErrCode nErrorCode;
485
0
            std::vector< OUString > aArguments;
486
0
            ucb::InteractiveNetworkOffLineException aOffLineException;
487
0
            ucb::InteractiveNetworkResolveNameException aResolveNameException;
488
0
            ucb::InteractiveNetworkConnectException aConnectException;
489
0
            ucb::InteractiveNetworkReadException aReadException;
490
0
            ucb::InteractiveNetworkWriteException aWriteException;
491
0
            if (aAnyRequest >>= aOffLineException)
492
0
                nErrorCode = ERRCODE_INET_OFFLINE;
493
0
            else if (aAnyRequest >>= aResolveNameException)
494
0
            {
495
0
                nErrorCode = ERRCODE_INET_NAME_RESOLVE;
496
0
                aArguments.push_back(aResolveNameException.Server);
497
0
            }
498
0
            else if (aAnyRequest >>= aConnectException)
499
0
            {
500
0
                nErrorCode = ERRCODE_INET_CONNECT;
501
0
                aArguments.push_back(aConnectException.Server);
502
0
                aArguments.push_back(aConnectException.Message);
503
0
            }
504
0
            else if (aAnyRequest >>= aReadException)
505
0
            {
506
0
                nErrorCode = ERRCODE_INET_READ;
507
0
                aArguments.push_back(aReadException.Diagnostic);
508
0
            }
509
0
            else if (aAnyRequest >>= aWriteException)
510
0
            {
511
0
                nErrorCode = ERRCODE_INET_WRITE;
512
0
                aArguments.push_back(aWriteException.Diagnostic);
513
0
            }
514
0
            else
515
0
                nErrorCode = ERRCODE_INET_GENERAL;
516
517
0
            handleErrorHandlerRequest(aNetworkException.Classification,
518
0
                                      nErrorCode,
519
0
                                      aArguments,
520
0
                                      rRequest->getContinuations(),
521
0
                                      bObtainErrorStringOnly,
522
0
                                      bHasErrorString,
523
0
                                      rErrorString);
524
0
            return true;
525
0
        }
526
527
0
        ucb::InteractiveWrongMediumException aWrongMediumException;
528
0
        if (aAnyRequest >>= aWrongMediumException)
529
0
        {
530
0
            sal_Int32 nMedium = 0;
531
0
            aWrongMediumException.Medium >>= nMedium;
532
0
            std::vector< OUString > aArguments { OUString::number(nMedium + 1) };
533
0
            handleErrorHandlerRequest(aWrongMediumException.Classification,
534
0
                                      ERRCODE_UUI_WRONGMEDIUM,
535
0
                                      aArguments,
536
0
                                      rRequest->getContinuations(),
537
0
                                      bObtainErrorStringOnly,
538
0
                                      bHasErrorString,
539
0
                                      rErrorString);
540
0
            return true;
541
0
        }
542
543
0
        java::WrongJavaVersionException aWrongJavaVersionException;
544
0
        if (aAnyRequest >>= aWrongJavaVersionException)
545
0
        {
546
0
            ErrCode nErrorCode;
547
0
            std::vector< OUString > aArguments;
548
0
            if (aWrongJavaVersionException.DetectedVersion.isEmpty())
549
0
                if (aWrongJavaVersionException.LowestSupportedVersion.isEmpty())
550
0
                    nErrorCode = ERRCODE_UUI_WRONGJAVA;
551
0
                else
552
0
                {
553
0
                    nErrorCode = ERRCODE_UUI_WRONGJAVA_MIN;
554
0
                    aArguments.push_back(aWrongJavaVersionException.LowestSupportedVersion);
555
0
                }
556
0
            else if (aWrongJavaVersionException.LowestSupportedVersion.isEmpty())
557
0
            {
558
0
                nErrorCode = ERRCODE_UUI_WRONGJAVA_VERSION;
559
0
                aArguments.push_back(aWrongJavaVersionException.DetectedVersion);
560
0
            }
561
0
            else
562
0
            {
563
0
                nErrorCode = ERRCODE_UUI_WRONGJAVA_VERSION_MIN;
564
0
                aArguments.reserve(2);
565
0
                aArguments.push_back(aWrongJavaVersionException.DetectedVersion);
566
0
                aArguments.push_back(aWrongJavaVersionException.LowestSupportedVersion);
567
0
            }
568
0
            handleErrorHandlerRequest(task::InteractionClassification_ERROR,
569
0
                                      nErrorCode,
570
0
                                      aArguments,
571
0
                                      rRequest->getContinuations(),
572
0
                                      bObtainErrorStringOnly,
573
0
                                      bHasErrorString,
574
0
                                      rErrorString);
575
0
            return true;
576
0
        }
577
578
0
        configuration::backend::MergeRecoveryRequest aMergeRecoveryRequest;
579
0
        if (aAnyRequest >>= aMergeRecoveryRequest)
580
0
        {
581
0
            ErrCode nErrorCode = aMergeRecoveryRequest.IsRemovalRequest
582
0
                ? ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE
583
0
                : ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE;
584
585
0
            std::vector< OUString > aArguments { aMergeRecoveryRequest.ErrorLayerId };
586
587
0
            handleErrorHandlerRequest(task::InteractionClassification_ERROR,
588
0
                                      nErrorCode,
589
0
                                      aArguments,
590
0
                                      rRequest->getContinuations(),
591
0
                                      bObtainErrorStringOnly,
592
0
                                      bHasErrorString,
593
0
                                      rErrorString);
594
0
            return true;
595
0
        }
596
597
0
        configuration::backend::StratumCreationException
598
0
            aStratumCreationException;
599
600
0
        if (aAnyRequest >>= aStratumCreationException)
601
0
        {
602
0
            const ErrCode nErrorCode = ERRCODE_UUI_CONFIGURATION_BACKENDMISSING;
603
604
0
            OUString aStratum = aStratumCreationException.StratumData;
605
0
            if (aStratum.isEmpty())
606
0
                aStratum = aStratumCreationException.StratumService;
607
608
0
            std::vector< OUString > aArguments { aStratum };
609
610
0
            handleErrorHandlerRequest(task::InteractionClassification_ERROR,
611
0
                                      nErrorCode,
612
0
                                      aArguments,
613
0
                                      rRequest->getContinuations(),
614
0
                                      bObtainErrorStringOnly,
615
0
                                      bHasErrorString,
616
0
                                      rErrorString);
617
0
            return true;
618
0
        }
619
620
0
        xforms::InvalidDataOnSubmitException aInvalidDataOnSubmitException;
621
0
        if (aAnyRequest >>= aInvalidDataOnSubmitException)
622
0
        {
623
0
            const ErrCode nErrorCode =
624
0
                ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA;
625
626
0
            std::vector< OUString > aArguments;
627
628
0
            handleErrorHandlerRequest(task::InteractionClassification_QUERY,
629
0
                                      nErrorCode,
630
0
                                      aArguments,
631
0
                                      rRequest->getContinuations(),
632
0
                                      bObtainErrorStringOnly,
633
0
                                      bHasErrorString,
634
0
                                      rErrorString);
635
0
            return true;
636
0
        }
637
638
0
        ucb::InteractiveLockingLockedException aLLException;
639
0
        if (aAnyRequest >>= aLLException)
640
0
        {
641
0
            ErrCode nErrorCode = aLLException.SelfOwned
642
0
                ? ERRCODE_UUI_LOCKING_LOCKED_SELF : ERRCODE_UUI_LOCKING_LOCKED;
643
0
            std::vector< OUString > aArguments { aLLException.Url };
644
645
0
            handleErrorHandlerRequest( aLLException.Classification,
646
0
                                       nErrorCode,
647
0
                                       aArguments,
648
0
                                       rRequest->getContinuations(),
649
0
                                       bObtainErrorStringOnly,
650
0
                                       bHasErrorString,
651
0
                                       rErrorString );
652
0
            return true;
653
0
        }
654
655
0
        ucb::InteractiveLockingNotLockedException aLNLException;
656
0
        if (aAnyRequest >>= aLNLException)
657
0
        {
658
0
            std::vector< OUString > aArguments { aLNLException.Url };
659
660
0
            handleErrorHandlerRequest( aLNLException.Classification,
661
0
                                       ERRCODE_UUI_LOCKING_NOT_LOCKED,
662
0
                                       aArguments,
663
0
                                       rRequest->getContinuations(),
664
0
                                       bObtainErrorStringOnly,
665
0
                                       bHasErrorString,
666
0
                                       rErrorString );
667
0
            return true;
668
0
        }
669
670
0
        ucb::InteractiveLockingLockExpiredException aLLEException;
671
0
        if (aAnyRequest >>= aLLEException)
672
0
        {
673
0
            std::vector< OUString > aArguments { aLLEException.Url };
674
675
0
            handleErrorHandlerRequest( aLLEException.Classification,
676
0
                                       ERRCODE_UUI_LOCKING_LOCK_EXPIRED,
677
0
                                       aArguments,
678
0
                                       rRequest->getContinuations(),
679
0
                                       bObtainErrorStringOnly,
680
0
                                       bHasErrorString,
681
0
                                       rErrorString );
682
0
            return true;
683
0
        }
684
685
0
        document::BrokenPackageRequest aBrokenPackageRequest;
686
0
        if (aAnyRequest >>= aBrokenPackageRequest)
687
0
        {
688
0
            std::vector< OUString > aArguments;
689
690
0
            if( !aBrokenPackageRequest.aName.isEmpty() )
691
0
                aArguments.push_back( aBrokenPackageRequest.aName );
692
693
0
            handleBrokenPackageRequest( aArguments,
694
0
                                        rRequest->getContinuations(),
695
0
                                        bObtainErrorStringOnly,
696
0
                                        bHasErrorString,
697
0
                                        rErrorString );
698
0
            return true;
699
0
        }
700
701
0
        if (handleFontsDisallowEditingRequest(rRequest))
702
0
            return true;
703
704
0
        task::ErrorCodeRequest2 aErrorCodeRequest2;
705
0
        if (aAnyRequest >>= aErrorCodeRequest2)
706
0
        {
707
0
            handleGenericErrorRequest(
708
0
                    ErrCodeMsg(ErrCode(aErrorCodeRequest2.ErrCode), aErrorCodeRequest2.Arg1, aErrorCodeRequest2.Arg2, static_cast<DialogMask>(aErrorCodeRequest2.DialogMask)),
709
0
                    rRequest->getContinuations(),
710
0
                    bObtainErrorStringOnly,
711
0
                    bHasErrorString,
712
0
                    rErrorString);
713
0
            return true;
714
0
        }
715
0
        task::ErrorCodeRequest aErrorCodeRequest;
716
0
        if (aAnyRequest >>= aErrorCodeRequest)
717
0
        {
718
0
            handleGenericErrorRequest( ErrCode(aErrorCodeRequest.ErrCode),
719
0
                    rRequest->getContinuations(),
720
0
                    bObtainErrorStringOnly,
721
0
                    bHasErrorString,
722
0
                    rErrorString);
723
0
            return true;
724
0
        }
725
726
0
        task::ErrorCodeIOException aErrorCodeIOException;
727
0
        if (aAnyRequest >>= aErrorCodeIOException)
728
0
        {
729
0
            handleGenericErrorRequest( ErrCode(aErrorCodeIOException.ErrCode),
730
0
                                       rRequest->getContinuations(),
731
0
                                       bObtainErrorStringOnly,
732
0
                                       bHasErrorString,
733
0
                                       rErrorString);
734
0
            return true;
735
0
        }
736
737
0
        loader::CannotActivateFactoryException aCannotActivateFactoryException;
738
0
        if (aAnyRequest >>= aCannotActivateFactoryException)
739
0
        {
740
0
            std::vector< OUString > aArguments { aCannotActivateFactoryException.Message };
741
742
0
            handleErrorHandlerRequest( task::InteractionClassification_ERROR,
743
0
                                       ERRCODE_UUI_CANNOT_ACTIVATE_FACTORY,
744
0
                                       aArguments,
745
0
                                       rRequest->getContinuations(),
746
0
                                       bObtainErrorStringOnly,
747
0
                                       bHasErrorString,
748
0
                                       rErrorString );
749
0
            return true;
750
0
        }
751
752
753
        // Handle requests which do not have a plain string representation.
754
755
0
        if (!bObtainErrorStringOnly)
756
0
        {
757
0
            ucb::AuthenticationFallbackRequest anAuthFallbackRequest;
758
0
            if ( aAnyRequest >>= anAuthFallbackRequest )
759
0
            {
760
0
                handleAuthFallbackRequest( anAuthFallbackRequest.instructions,
761
0
                        anAuthFallbackRequest.url, rRequest->getContinuations() );
762
0
                return true;
763
0
            }
764
765
0
            if ( handleAuthenticationRequest( rRequest ) )
766
0
                return true;
767
768
0
            if ( handleCertificateValidationRequest( rRequest ) )
769
0
                return true;
770
771
0
            ucb::NameClashResolveRequest aNameClashResolveRequest;
772
0
            if (aAnyRequest >>= aNameClashResolveRequest)
773
0
            {
774
0
                handleNameClashResolveRequest(aNameClashResolveRequest,
775
0
                                              rRequest->getContinuations());
776
0
                return true;
777
0
            }
778
779
0
            if ( handleMasterPasswordRequest( rRequest ) )
780
0
                return true;
781
782
0
            if ( handlePasswordRequest( rRequest ) )
783
0
                return true;
784
785
0
            if ( handleNoSuchFilterRequest( rRequest ) )
786
0
                return true;
787
788
0
            if ( handleFilterOptionsRequest( rRequest ) )
789
0
                return true;
790
791
0
            if ( handleLockedDocumentRequest( rRequest ) )
792
0
                return true;
793
794
0
            if ( handleChangedByOthersRequest( rRequest ) )
795
0
                return true;
796
797
0
            if ( handleLockFileProblemRequest( rRequest ) )
798
0
                return true;
799
800
0
            if ( handleReloadEditableRequest( rRequest ) )
801
0
                return true;
802
803
0
            task::DocumentMacroConfirmationRequest aMacroConfirmRequest;
804
0
            if (aAnyRequest >>= aMacroConfirmRequest)
805
0
            {
806
0
                handleMacroConfirmRequest(
807
0
                    aMacroConfirmRequest.DocumentURL,
808
0
                    aMacroConfirmRequest.DocumentStorage,
809
0
                    !aMacroConfirmRequest.DocumentVersion.isEmpty() ? aMacroConfirmRequest.DocumentVersion : ODFVER_013_TEXT,
810
0
                    aMacroConfirmRequest.DocumentSignatureInformation,
811
0
                    rRequest->getContinuations());
812
0
                return true;
813
0
            }
814
815
0
            OUString aFileName;
816
0
            beans::NamedValue aLoadReadOnlyRequest;
817
0
            if ((aAnyRequest >>= aLoadReadOnlyRequest) &&
818
0
                aLoadReadOnlyRequest.Name == "LoadReadOnlyRequest" &&
819
0
                (aLoadReadOnlyRequest.Value >>= aFileName))
820
0
            {
821
0
                handleLoadReadOnlyRequest(aFileName,
822
0
                                          rRequest->getContinuations());
823
0
                return true;
824
0
            }
825
826
            // Last chance: interaction handlers registered in the configuration
827
828
829
            // typed InteractionHandlers (ooo.Interactions)
830
0
            if ( handleTypedHandlerImplementations( rRequest ) )
831
0
                return true;
832
0
        }
833
834
        // Not handled.
835
0
        return false;
836
0
    }
837
0
    catch( const uno::RuntimeException& )
838
0
    {
839
0
        throw;  // allowed to leave here
840
0
    }
841
0
    catch( const uno::Exception& )
842
0
    {
843
0
        DBG_UNHANDLED_EXCEPTION("uui");
844
0
    }
845
0
    return false;
846
0
}
847
848
const uno::Reference< awt::XWindow>&
849
UUIInteractionHelper::getParentXWindow() const
850
0
{
851
0
    return m_xWindowParam;
852
0
}
853
854
uno::Reference< task::XInteractionHandler2 >
855
UUIInteractionHelper::getInteractionHandler() const
856
0
{
857
0
    return InteractionHandler::createWithParentAndContext(
858
0
        m_xContext, m_xWindowParam,
859
0
        m_aContextParam);
860
0
}
861
862
namespace {
863
864
DialogMask
865
executeMessageBox(
866
    weld::Window * pParent,
867
    OUString const & rTitle,
868
    OUString const & rMessage,
869
    VclMessageType eMessageType)
870
0
{
871
0
    SolarMutexGuard aGuard;
872
873
0
    std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, eMessageType,
874
0
        eMessageType == VclMessageType::Question ? VclButtonsType::YesNo : VclButtonsType::Ok, rMessage, GetpApp()));
875
0
    xBox->set_title(rTitle);
876
877
0
    short nMessResult = xBox->run();
878
0
    DialogMask aResult = DialogMask::NONE;
879
0
    switch (nMessResult)
880
0
    {
881
0
        case RET_OK:
882
0
            aResult = DialogMask::ButtonsOk;
883
0
            break;
884
0
        case RET_CANCEL:
885
0
            aResult = DialogMask::ButtonsCancel;
886
0
            break;
887
0
        case RET_YES:
888
0
            aResult = DialogMask::ButtonsYes;
889
0
            break;
890
0
        case RET_NO:
891
0
            aResult = DialogMask::ButtonsNo;
892
0
            break;
893
0
        default:
894
0
            SAL_WARN("uui", "executeMessageBox: nMessResult is " << nMessResult);
895
0
            assert(false);
896
0
    }
897
898
0
    return aResult;
899
0
}
900
901
NameClashResolveDialogResult executeSimpleNameClashResolveDialog(weld::Window *pParent,
902
                                                                 OUString const & rTargetFolderURL,
903
                                                                 OUString const & rClashingName,
904
                                                                 OUString & rProposedNewName,
905
                                                                 bool bAllowOverwrite)
906
0
{
907
0
    std::locale aResLocale = Translate::Create("uui");
908
0
    NameClashDialog aDialog(pParent, aResLocale, rTargetFolderURL,
909
0
                            rClashingName, rProposedNewName, bAllowOverwrite);
910
911
0
    NameClashResolveDialogResult eResult = static_cast<NameClashResolveDialogResult>(aDialog.run());
912
0
    rProposedNewName = aDialog.getNewName();
913
0
    return eResult;
914
0
}
915
916
} // namespace
917
918
void
919
UUIInteractionHelper::handleNameClashResolveRequest(
920
    ucb::NameClashResolveRequest const & rRequest,
921
    uno::Sequence< uno::Reference<
922
        task::XInteractionContinuation > > const & rContinuations)
923
0
{
924
0
    OSL_ENSURE(!rRequest.TargetFolderURL.isEmpty(),
925
0
        "NameClashResolveRequest must not contain empty TargetFolderURL" );
926
927
0
    OSL_ENSURE(!rRequest.ClashingName.isEmpty(),
928
0
        "NameClashResolveRequest must not contain empty ClashingName" );
929
930
0
    uno::Reference< task::XInteractionAbort > xAbort;
931
0
    uno::Reference< ucb::XInteractionSupplyName > xSupplyName;
932
0
    uno::Reference< ucb::XInteractionReplaceExistingData > xReplaceExistingData;
933
0
    getContinuations(
934
0
        rContinuations, &xAbort, &xSupplyName, &xReplaceExistingData);
935
936
0
    OSL_ENSURE( xAbort.is(),
937
0
        "NameClashResolveRequest must contain Abort continuation" );
938
939
0
    OSL_ENSURE( xSupplyName.is(),
940
0
        "NameClashResolveRequest must contain SupplyName continuation" );
941
942
0
    NameClashResolveDialogResult eResult = ABORT;
943
0
    OUString aProposedNewName( rRequest.ProposedNewName );
944
945
0
    uno::Reference<awt::XWindow> xParent = getParentXWindow();
946
0
    eResult = executeSimpleNameClashResolveDialog(Application::GetFrameWeld(xParent),
947
0
                    rRequest.TargetFolderURL,
948
0
                    rRequest.ClashingName,
949
0
                    aProposedNewName,
950
0
                    xReplaceExistingData.is());
951
952
0
    switch ( eResult )
953
0
    {
954
0
    case ABORT:
955
0
        xAbort->select();
956
0
        break;
957
958
0
    case RENAME:
959
0
        xSupplyName->setName( aProposedNewName );
960
0
        xSupplyName->select();
961
0
        break;
962
963
0
    case OVERWRITE:
964
0
        OSL_ENSURE(
965
0
            xReplaceExistingData.is(),
966
0
            "Invalid NameClashResolveDialogResult: OVERWRITE - "
967
0
            "No ReplaceExistingData continuation available!" );
968
0
        xReplaceExistingData->select();
969
0
        break;
970
0
    }
971
0
}
972
973
void
974
UUIInteractionHelper::handleGenericErrorRequest(
975
    ErrCodeMsg nErrorCode,
976
    uno::Sequence< uno::Reference<
977
        task::XInteractionContinuation > > const & rContinuations,
978
    bool bObtainErrorStringOnly,
979
    bool & bHasErrorString,
980
    OUString & rErrorString)
981
0
{
982
0
    if (bObtainErrorStringOnly)
983
0
    {
984
0
        bHasErrorString = isInformationalErrorMessageRequest(rContinuations);
985
0
        if (bHasErrorString)
986
0
        {
987
0
            OUString aErrorString;
988
0
            ErrorHandler::GetErrorString(nErrorCode, aErrorString);
989
0
            rErrorString = aErrorString;
990
0
        }
991
0
    }
992
0
    else
993
0
    {
994
0
        uno::Reference< task::XInteractionAbort > xAbort;
995
0
        uno::Reference< task::XInteractionApprove > xApprove;
996
0
        getContinuations(rContinuations, &xApprove, &xAbort);
997
998
        // Note: It's important to convert the transported long to the
999
        // required  unsigned long value. Otherwise using as flag field
1000
        // can fail ...
1001
0
        bool bWarning = !nErrorCode.IgnoreWarning();
1002
1003
0
        if ( nErrorCode == ERRCODE_SFX_INCOMPLETE_ENCRYPTION )
1004
0
        {
1005
            // the security warning box needs a special title
1006
0
            OUString aErrorString;
1007
0
            ErrorHandler::GetErrorString( nErrorCode, aErrorString );
1008
1009
0
            std::locale aResLocale = Translate::Create("uui");
1010
0
            OUString aTitle( utl::ConfigManager::getProductName() );
1011
1012
0
            OUString aErrTitle = Translate::get(STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE, aResLocale);
1013
1014
0
            if ( !aTitle.isEmpty() && !aErrTitle.isEmpty() )
1015
0
                aTitle += " - " ;
1016
0
            aTitle += aErrTitle;
1017
1018
0
            uno::Reference<awt::XWindow> xParent = getParentXWindow();
1019
0
            executeMessageBox(Application::GetFrameWeld(xParent), aTitle, aErrorString, VclMessageType::Error);
1020
0
        }
1021
0
        else
1022
0
        {
1023
0
            uno::Reference<awt::XWindow> xParent = getParentXWindow();
1024
0
            ErrorHandler::HandleError(nErrorCode, Application::GetFrameWeld(xParent));
1025
0
        }
1026
1027
0
        if (xApprove.is() && bWarning)
1028
0
            xApprove->select();
1029
0
        else if (xAbort.is())
1030
0
            xAbort->select();
1031
0
    }
1032
0
}
1033
1034
void
1035
UUIInteractionHelper::handleMacroConfirmRequest(
1036
    const OUString& aDocumentURL,
1037
    const uno::Reference< embed::XStorage >& xZipStorage,
1038
    const OUString& aDocumentVersion,
1039
    const uno::Sequence< security::DocumentSignatureInformation >& aSignInfo,
1040
    uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
1041
        rContinuations )
1042
0
{
1043
0
    uno::Reference< task::XInteractionAbort > xAbort;
1044
0
    uno::Reference< task::XInteractionApprove > xApprove;
1045
0
    getContinuations( rContinuations, &xApprove, &xAbort );
1046
1047
0
    bool bApprove = false;
1048
1049
0
    bool bShowSignatures = aSignInfo.hasElements();
1050
0
    uno::Reference<awt::XWindow> xParent = getParentXWindow();
1051
0
    MacroWarning aWarning(Application::GetFrameWeld(xParent), bShowSignatures);
1052
1053
0
    aWarning.SetDocumentURL(aDocumentURL);
1054
0
    if ( aSignInfo.getLength() > 1 )
1055
0
    {
1056
0
        aWarning.SetStorage(xZipStorage, aDocumentVersion, aSignInfo);
1057
0
    }
1058
0
    else if ( aSignInfo.getLength() == 1 )
1059
0
    {
1060
0
        aWarning.SetCertificate(aSignInfo[0].Signer);
1061
0
    }
1062
1063
0
    bApprove = aWarning.run() == RET_OK;
1064
1065
0
    if ( bApprove && xApprove.is() )
1066
0
        xApprove->select();
1067
0
    else if ( xAbort.is() )
1068
0
        xAbort->select();
1069
0
}
1070
1071
void
1072
UUIInteractionHelper::handleBrokenPackageRequest(
1073
    std::vector< OUString > const & rArguments,
1074
    uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
1075
        rContinuations,
1076
    bool bObtainErrorStringOnly,
1077
    bool & bHasErrorString,
1078
    OUString & rErrorString)
1079
0
{
1080
0
    if (bObtainErrorStringOnly)
1081
0
    {
1082
0
        bHasErrorString = isInformationalErrorMessageRequest(rContinuations);
1083
0
        if (!bHasErrorString)
1084
0
            return;
1085
0
    }
1086
1087
0
    uno::Reference< task::XInteractionApprove > xApprove;
1088
0
    uno::Reference< task::XInteractionDisapprove > xDisapprove;
1089
0
    uno::Reference< task::XInteractionAbort > xAbort;
1090
0
    getContinuations(rContinuations, &xApprove, &xDisapprove, &xAbort);
1091
1092
0
    ErrCode nErrorCode;
1093
0
    if( xApprove.is() && xDisapprove.is() )
1094
0
    {
1095
0
        nErrorCode = ERRCODE_UUI_IO_BROKENPACKAGE;
1096
0
    }
1097
0
    else if ( xAbort.is() )
1098
0
    {
1099
0
        nErrorCode = ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR;
1100
0
    }
1101
0
    else
1102
0
        return;
1103
1104
0
    OUString aMessage;
1105
0
    {
1106
0
        std::locale aResLocale = Translate::Create("uui");
1107
0
        ErrorResource aErrorResource(RID_UUI_ERRHDL, aResLocale);
1108
0
        if (!aErrorResource.getString(nErrorCode, aMessage))
1109
0
            return;
1110
0
    }
1111
1112
0
    aMessage = replaceMessageWithArguments( aMessage, rArguments );
1113
1114
0
    if (bObtainErrorStringOnly)
1115
0
    {
1116
0
        rErrorString = aMessage;
1117
0
        return;
1118
0
    }
1119
1120
0
    VclMessageType eMessageType;
1121
0
    if( xApprove.is() && xDisapprove.is() )
1122
0
        eMessageType = VclMessageType::Question;
1123
0
    else if ( xAbort.is() )
1124
0
        eMessageType = VclMessageType::Warning;
1125
0
    else
1126
0
        return;
1127
1128
0
    OUString title(
1129
0
        utl::ConfigManager::getProductName() +
1130
0
        " " +
1131
0
        utl::ConfigManager::getProductVersion() );
1132
1133
0
    uno::Reference<awt::XWindow> xParent = getParentXWindow();
1134
0
    switch (executeMessageBox(Application::GetFrameWeld(xParent), title, aMessage, eMessageType))
1135
0
    {
1136
0
    case DialogMask::ButtonsOk:
1137
0
        OSL_ENSURE( xAbort.is(), "unexpected situation" );
1138
0
        if (xAbort.is())
1139
0
            xAbort->select();
1140
0
        break;
1141
1142
0
    case DialogMask::ButtonsNo:
1143
0
        OSL_ENSURE(xDisapprove.is(), "unexpected situation");
1144
0
        if (xDisapprove.is())
1145
0
            xDisapprove->select();
1146
0
        break;
1147
1148
0
    case DialogMask::ButtonsYes:
1149
0
        OSL_ENSURE(xApprove.is(), "unexpected situation");
1150
0
        if (xApprove.is())
1151
0
            xApprove->select();
1152
0
        break;
1153
1154
0
    default: break;
1155
0
    }
1156
0
}
1157
1158
bool UUIInteractionHelper::handleFontsDisallowEditingRequest(
1159
    const uno::Reference<task::XInteractionRequest>& rRequest)
1160
0
{
1161
0
    document::FontsDisallowEditingRequest aRequest;
1162
0
    if (!(rRequest->getRequest() >>= aRequest))
1163
0
        return false;
1164
1165
0
    uno::Reference<task::XInteractionApprove> xApprove;
1166
0
    uno::Reference<task::XInteractionDisapprove> xDisapprove;
1167
0
    getContinuations(rRequest->getContinuations(), &xApprove, &xDisapprove);
1168
1169
0
    if (xApprove.is() && xDisapprove.is())
1170
0
    {
1171
0
        std::locale aResLocale = Translate::Create("uui");
1172
0
        OUString title(utl::ConfigManager::getProductName());
1173
1174
0
        OUString title2 = Translate::get(STR_READONLY_FONT_TITLE, aResLocale);
1175
0
        if (!title.isEmpty() && !title2.isEmpty())
1176
0
            title += " - ";
1177
0
        title += title2;
1178
1179
0
        OUString aMessage = replaceMessageWithArguments(
1180
0
            Translate::get(STR_READONLY_FONT_MSG, aResLocale), { aRequest.aFontNames });
1181
1182
0
        switch (executeMessageBox(Application::GetFrameWeld(getParentXWindow()), title, aMessage,
1183
0
                                  VclMessageType::Question))
1184
0
        {
1185
0
            case DialogMask::ButtonsNo:
1186
0
                if (xDisapprove.is())
1187
0
                    xDisapprove->select();
1188
0
                break;
1189
1190
0
            case DialogMask::ButtonsYes:
1191
0
                if (xApprove.is())
1192
0
                    xApprove->select();
1193
0
                break;
1194
1195
0
            default:
1196
0
                break;
1197
0
        }
1198
0
    }
1199
1200
0
    return true;
1201
0
}
1202
1203
// ErrorResource Implementation
1204
bool ErrorResource::getString(ErrCode nErrorCode, OUString &rString) const
1205
0
{
1206
0
    for (const std::pair<TranslateId, ErrCode>* pStringArray = m_pStringArray; pStringArray->first; ++pStringArray)
1207
0
    {
1208
0
        if (nErrorCode.StripWarning() == pStringArray->second.StripWarning())
1209
0
        {
1210
0
            rString = Translate::get(pStringArray->first, m_rResLocale);
1211
0
            return true;
1212
0
        }
1213
0
    }
1214
0
    return false;
1215
0
}
1216
1217
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */