tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / desktop / source / deployment / dp_log.cxx
blob480aecb7bd48528a382ff5497365752bfad6a137
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 <cppuhelper/basemutex.hxx>
22 #include <cppuhelper/compbase.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <comphelper/anytostring.hxx>
25 #include <comphelper/logging.hxx>
26 #include <rtl/ustrbuf.hxx>
27 #include <com/sun/star/logging/LogLevel.hpp>
28 #include <com/sun/star/ucb/XProgressHandler.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::logging;
35 namespace dp_log {
37 typedef ::cppu::WeakComponentImplHelper<ucb::XProgressHandler, lang::XServiceInfo> t_log_helper;
39 namespace {
41 class ProgressLogImpl : public cppu::BaseMutex, public t_log_helper
43 comphelper::EventLogger m_logger;
45 protected:
46 virtual void SAL_CALL disposing() override;
47 virtual ~ProgressLogImpl() override;
49 public:
50 ProgressLogImpl( Sequence<Any> const & args,
51 Reference<XComponentContext> const & xContext );
53 // XServiceInfo
54 virtual OUString SAL_CALL getImplementationName() override;
55 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
56 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
58 // XProgressHandler
59 virtual void SAL_CALL push( Any const & Status ) override;
60 virtual void SAL_CALL update( Any const & Status ) override;
61 virtual void SAL_CALL pop() override;
66 ProgressLogImpl::~ProgressLogImpl()
71 void ProgressLogImpl::disposing()
76 ProgressLogImpl::ProgressLogImpl(
77 Sequence<Any> const & /* args */,
78 Reference<XComponentContext> const & xContext )
79 : t_log_helper( m_aMutex )
80 // Use the logger created by unopkg app
81 , m_logger(xContext, "unopkg")
85 // XServiceInfo
86 OUString ProgressLogImpl::getImplementationName()
88 return u"com.sun.star.comp.deployment.ProgressLog"_ustr;
91 sal_Bool ProgressLogImpl::supportsService( const OUString& ServiceName )
93 return cppu::supportsService(this, ServiceName);
96 css::uno::Sequence< OUString > ProgressLogImpl::getSupportedServiceNames()
98 // a private one
99 return { u"com.sun.star.comp.deployment.ProgressLog"_ustr };
102 // XProgressHandler
104 void ProgressLogImpl::push( Any const & Status )
106 update( Status );
109 void ProgressLogImpl::update( Any const & Status )
111 if (! Status.hasValue())
112 return;
114 OUStringBuffer buf;
116 OUString msg;
117 sal_Int32 logLevel = LogLevel::INFO;
118 if (Status >>= msg) {
119 buf.append( msg );
121 else {
122 logLevel = LogLevel::SEVERE;
123 buf.append( ::comphelper::anyToString(Status) );
125 m_logger.log(logLevel, buf.makeStringAndClear());
129 void ProgressLogImpl::pop()
133 } // namespace dp_log
135 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
136 com_sun_star_comp_deployment_ProgressLog_get_implementation(
137 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
139 return cppu::acquire(new dp_log::ProgressLogImpl(args, context));
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */