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 <cppuhelper/implbase.hxx>
24 #include <com/sun/star/task/XJob.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
30 /** @short implements a job component which can be used
31 to execute system shell commands.
33 @descr Because the job will be implemented generic
34 it can be bound to any event where jobs can be
35 registered for. Further there is a generic
36 way to configure the shell command and it's list
39 class ShellJob final
: public ::cppu::WeakImplHelper
< css::lang::XServiceInfo
,css::task::XJob
>
45 /** @short reference to a uno service manager. */
46 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
51 /** @short create new instance of this class.
54 reference to the uno service manager, which created this instance.
55 Can be used later to create own needed uno resources on demand.
57 ShellJob(css::uno::Reference
< css::uno::XComponentContext
> xContext
);
59 /** @short does nothing real ...
61 @descr But it should exists as virtual function,
62 so this class can't make trouble
63 related to inline/symbols etcpp.!
65 virtual ~ShellJob() override
;
70 /* interface XServiceInfo */
71 virtual OUString SAL_CALL
getImplementationName() override
;
72 virtual sal_Bool SAL_CALL
supportsService( const OUString
& sServiceName
) override
;
73 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
76 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
) override
;
81 /** generate a return value for method execute()
82 which will force deactivation of this job for further requests.
84 @return an Any following the job protocol for deactivation.
86 static css::uno::Any
impl_generateAnswer4Deactivation();
88 /** substitute all might existing placeholder variables
89 within the configured command.
91 The command is part of the job configuration.
92 These will make changes more easy (no code changes required).
93 Further the command can use placeholder as they are supported
94 by the global substitution service (e.g. $(prog) etcpp)
97 the command containing placeholder variables.
99 @return the substituted command.
101 OUString
impl_substituteCommandVariables(const OUString
& sCommand
);
103 /** executes the command.
106 the absolute command as URL or system path (without any argument !).
109 the complete list of arguments configured for these job.
111 @param bCheckExitCode
112 bind the execution result to the exit code of the started process.
113 If it's set to false we return false only in case executable couldn't be found
114 or couldn't be started.
116 @return sal_True if command was executed successfully; sal_False otherwise.
118 bool impl_execute(const OUString
& sCommand
,
119 const css::uno::Sequence
< OUString
>& lArguments
,
120 bool bCheckExitCode
);
123 } // namespace framework
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */