tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / desktop / source / deployment / manager / dp_commandenvironments.cxx
blob0d87a0ac5f1d00694dc350689284ce067c9ec17c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <com/sun/star/deployment/VersionException.hpp>
22 #include <com/sun/star/deployment/LicenseException.hpp>
23 #include <com/sun/star/deployment/InstallException.hpp>
24 #include <com/sun/star/deployment/DependencyException.hpp>
25 #include <com/sun/star/deployment/PlatformException.hpp>
26 #include <com/sun/star/task/XInteractionApprove.hpp>
27 #include <utility>
28 #include "dp_commandenvironments.hxx"
29 #include <osl/diagnose.h>
31 namespace deployment = css::deployment;
32 namespace task = css::task;
33 namespace ucb = css::ucb;
34 namespace uno = css::uno;
36 using css::uno::Reference;
38 namespace dp_manager {
40 BaseCommandEnv::BaseCommandEnv()
44 BaseCommandEnv::BaseCommandEnv(
45 Reference< task::XInteractionHandler> const & handler)
46 : m_forwardHandler(handler)
50 BaseCommandEnv::~BaseCommandEnv()
53 // XCommandEnvironment
55 Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler()
57 return this;
61 Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler()
63 return this;
66 void BaseCommandEnv::handle(
67 Reference< task::XInteractionRequest> const & /*xRequest*/ )
71 void BaseCommandEnv::handle_(bool approve,
72 Reference< task::XInteractionRequest> const & xRequest )
74 if (!approve)
76 //not handled so far -> forwarding
77 if (m_forwardHandler.is())
78 m_forwardHandler->handle(xRequest);
79 else
80 return; //cannot handle
82 else
84 // select:
85 for (auto& xContinuation : xRequest->getContinuations())
87 Reference<task::XInteractionApprove> xInteractionApprove(xContinuation, uno::UNO_QUERY);
88 if (xInteractionApprove.is())
90 xInteractionApprove->select();
91 // don't query again for ongoing continuations:
92 break;
99 // XProgressHandler
100 void BaseCommandEnv::push( uno::Any const & /*Status*/ )
104 void BaseCommandEnv::update( uno::Any const & /*Status */)
108 void BaseCommandEnv::pop()
113 TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
117 TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
118 css::uno::Reference< css::task::XInteractionHandler> const & handler):
119 BaseCommandEnv(handler)
122 // XInteractionHandler
123 void TmpRepositoryCommandEnv::handle(
124 Reference< task::XInteractionRequest> const & xRequest )
126 uno::Any request( xRequest->getRequest() );
127 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
129 deployment::VersionException verExc;
130 deployment::LicenseException licExc;
131 deployment::InstallException instExc;
133 bool approve = false;
135 if ((request >>= verExc)
136 || (request >>= licExc)
137 || (request >>= instExc))
139 approve = true;
142 handle_(approve, xRequest);
146 LicenseCommandEnv::LicenseCommandEnv(
147 css::uno::Reference< css::task::XInteractionHandler> const & handler,
148 bool bSuppressLicense,
149 OUString repository):
150 BaseCommandEnv(handler), m_repository(std::move(repository)),
151 m_bSuppressLicense(bSuppressLicense)
154 // XInteractionHandler
155 void LicenseCommandEnv::handle(
156 Reference< task::XInteractionRequest> const & xRequest )
158 uno::Any request( xRequest->getRequest() );
159 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
161 deployment::LicenseException licExc;
163 bool approve = false;
165 if (request >>= licExc)
167 if (m_bSuppressLicense
168 || m_repository == "bundled"
169 || licExc.AcceptBy == "admin")
171 //always approve in bundled case, because we do not support
172 //showing licenses anyway.
173 //The "admin" already accepted the license when installing the
174 // shared extension
175 approve = true;
179 handle_(approve, xRequest);
183 NoLicenseCommandEnv::NoLicenseCommandEnv(
184 css::uno::Reference< css::task::XInteractionHandler> const & handler):
185 BaseCommandEnv(handler)
188 // XInteractionHandler
189 void NoLicenseCommandEnv::handle(
190 Reference< task::XInteractionRequest> const & xRequest )
192 uno::Any request( xRequest->getRequest() );
193 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
195 deployment::LicenseException licExc;
197 bool approve = false;
199 if (request >>= licExc)
201 approve = true;
203 handle_(approve, xRequest);
206 SilentCheckPrerequisitesCommandEnv::SilentCheckPrerequisitesCommandEnv()
210 void SilentCheckPrerequisitesCommandEnv::handle(
211 Reference< task::XInteractionRequest> const & xRequest )
213 uno::Any request( xRequest->getRequest() );
214 OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
216 deployment::LicenseException licExc;
217 deployment::PlatformException platformExc;
218 deployment::DependencyException depExc;
220 if (request >>= licExc)
222 handle_(true, xRequest); // approve = true
224 else if ((request >>= platformExc)
225 || (request >>= depExc))
227 m_Exception = std::move(request);
229 else
231 m_UnknownException = std::move(request);
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */