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 .
20 #ifndef __FRAMEWORK_JOBS_SHELLJOB_HXX_
21 #define __FRAMEWORK_JOBS_SHELLJOB_HXX_
23 #include <threadhelp/threadhelpbase.hxx>
24 #include <macros/xinterface.hxx>
25 #include <macros/xtypeprovider.hxx>
26 #include <macros/xserviceinfo.hxx>
28 #include <cppuhelper/implbase2.hxx>
30 #include <com/sun/star/frame/XFrame.hpp>
31 #include <com/sun/star/task/XJob.hpp>
32 #include <com/sun/star/lang/XEventListener.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/frame/XModuleManager.hpp>
40 //_______________________________________________
41 /** @short implements a job component which can be used
42 to execute system shell commands.
44 @descr Because the job will be implemented generic
45 it can be bound to any event where jobs can be
46 registered for. Further there is a generic
47 way to configure the shell command and it's list
52 class ShellJob
: private ThreadHelpBase
53 ,public ::cppu::WeakImplHelper2
< ::com::sun::star::lang::XServiceInfo
,::com::sun::star::task::XJob
>
55 //-------------------------------------------
59 //.......................................
60 /** @short reference to an uno service manager. */
61 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
63 //-------------------------------------------
67 //---------------------------------------
68 /** @short create new instance of this class.
71 reference to the uno service manager, which created this instance.
72 Can be used later to create own needed uno resources on demand.
74 ShellJob(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
76 //---------------------------------------
77 /** @short does nothing real ...
79 @descr But it should exists as virtual function,
80 so this class cant make trouble
81 related to inline/symbols etcpp.!
85 //-------------------------------------------
89 //---------------------------------------
90 // css.lang.XServiceInfo
94 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
95 throw(css::lang::IllegalArgumentException
,
97 css::uno::RuntimeException
);
99 //-------------------------------------------
103 //---------------------------------------
104 /** generate a return value for method execute()
105 which will force deactivation of this job for further requests.
107 @return an Any following the job protocol for deactivation.
109 static css::uno::Any
impl_generateAnswer4Deactivation();
111 //---------------------------------------
112 /** substitute all might existing placeholder variables
113 within the configured command.
115 The command is part of the job configuration.
116 These will make changes more easy (no code changes required).
117 Further the command can use placeholder as they are supported
118 by the global substitution service (e.g. $(prog) etcpp)
121 the command containing placeholder variables.
123 @return the substituted command.
125 OUString
impl_substituteCommandVariables(const OUString
& sCommand
);
127 //---------------------------------------
128 /** executes the command.
131 the absolute command as URL or system path (without any argument !).
134 the complete list of arguments configured for these job.
136 @param bCheckExitCode
137 bind the execution result to the exit code of the started process.
138 If it's set to false we return false only in case executable couldnt be found
139 or couldnt be started.
141 @return sal_True if command was executed successfully; sal_False otherwise.
143 ::sal_Bool
impl_execute(const OUString
& sCommand
,
144 const css::uno::Sequence
< OUString
>& lArguments
,
145 ::sal_Bool bCheckExitCode
);
148 } // namespace framework
150 #endif // __FRAMEWORK_JOBS_SHELLJOB_HXX_
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */