update dev300-m57
[ooovba.git] / framework / inc / jobs / shelljob.hxx
blob956290cd7d36a1038a4eedc5062b41f7d5967187
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shelljob.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_JOBS_SHELLJOB_HXX_
32 #define __FRAMEWORK_JOBS_SHELLJOB_HXX_
34 //_______________________________________________
35 // my own includes
37 #include <threadhelp/threadhelpbase.hxx>
38 #include <macros/xinterface.hxx>
39 #include <macros/xtypeprovider.hxx>
40 #include <macros/xserviceinfo.hxx>
42 //_______________________________________________
43 // other includes
44 #include <cppuhelper/weak.hxx>
46 //_______________________________________________
47 // uno includes
48 #include <com/sun/star/frame/XFrame.hpp>
49 #include <com/sun/star/task/XJob.hpp>
50 #include <com/sun/star/lang/XEventListener.hpp>
51 #include <com/sun/star/container/XNameAccess.hpp>
52 #include <com/sun/star/frame/XModuleManager.hpp>
54 //_______________________________________________
55 // namespace
57 namespace framework{
59 //_______________________________________________
60 // declarations
62 //_______________________________________________
63 /** @short implements a job component which can be used
64 to execute system shell commands.
66 @descr Because the job will be implemented generic
67 it can be bound to any event where jobs can be
68 registered for. Further there is a generic
69 way to configure the shell command and it's list
70 of arguments.
72 @author as96863
74 class ShellJob : public css::lang::XTypeProvider
75 , public css::lang::XServiceInfo
76 , public css::task::XJob
77 , private ThreadHelpBase
78 , public ::cppu::OWeakObject
80 //-------------------------------------------
81 // member
82 private:
84 //.......................................
85 /** @short reference to an uno service manager. */
86 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
88 //-------------------------------------------
89 // native interface
90 public:
92 //---------------------------------------
93 /** @short create new instance of this class.
95 @param xSMGR
96 reference to the uno service manager, which created this instance.
97 Can be used later to create own needed uno resources on demand.
99 ShellJob(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
101 //---------------------------------------
102 /** @short does nothing real ...
104 @descr But it should exists as virtual function,
105 so this class cant make trouble
106 related to inline/symbols etcpp.!
108 virtual ~ShellJob();
110 //-------------------------------------------
111 // uno interface
112 public:
114 //---------------------------------------
115 // css.uno.XInterface
116 // css.lang.XTypeProvider
117 // css.lang.XServiceInfo
118 FWK_DECLARE_XINTERFACE
119 FWK_DECLARE_XTYPEPROVIDER
120 DECLARE_XSERVICEINFO
122 // css.task.XJob
123 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
124 throw(css::lang::IllegalArgumentException,
125 css::uno::Exception ,
126 css::uno::RuntimeException );
128 //-------------------------------------------
129 // helper
130 private:
132 //---------------------------------------
133 /** generate a return value for method execute()
134 which will force deactivation of this job for further requests.
136 @return an Any following the job protocol for deactivation.
138 static css::uno::Any impl_generateAnswer4Deactivation();
140 //---------------------------------------
141 /** substitute all might existing placeholder variables
142 within the configured command.
144 The command is part of the job configuration.
145 These will make changes more easy (no code changes required).
146 Further the command can use placeholder as they are supported
147 by the global substitution service (e.g. $(prog) etcpp)
149 @param sCommand
150 the command containing placeholder variables.
152 @return the substituted command.
154 ::rtl::OUString impl_substituteCommandVariables(const ::rtl::OUString& sCommand);
156 //---------------------------------------
157 /** executes the command.
159 @param sCommand
160 the absolute command as URL or system path (without any argument !).
162 @param lArguments
163 the complete list of arguments configured for these job.
165 @param bCheckExitCode
166 bind the execution result to the exit code of the started process.
167 If it's set to false we return false only in case executable couldnt be found
168 or couldnt be started.
170 @return TRUE if command was executed successfully; FALSE otherwise.
172 ::sal_Bool impl_execute(const ::rtl::OUString& sCommand ,
173 const css::uno::Sequence< ::rtl::OUString >& lArguments ,
174 ::sal_Bool bCheckExitCode);
177 } // namespace framework
179 #endif // __FRAMEWORK_JOBS_SHELLJOB_HXX_