update dev300-m58
[ooovba.git] / framework / inc / jobs / shelljob.hxx
blob68d5136da340a912e5d45edfc5bc96cb6040a0b8
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/implbase2.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 : private ThreadHelpBase
75 ,public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XServiceInfo,::com::sun::star::task::XJob >
77 //-------------------------------------------
78 // member
79 private:
81 //.......................................
82 /** @short reference to an uno service manager. */
83 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
85 //-------------------------------------------
86 // native interface
87 public:
89 //---------------------------------------
90 /** @short create new instance of this class.
92 @param xSMGR
93 reference to the uno service manager, which created this instance.
94 Can be used later to create own needed uno resources on demand.
96 ShellJob(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
98 //---------------------------------------
99 /** @short does nothing real ...
101 @descr But it should exists as virtual function,
102 so this class cant make trouble
103 related to inline/symbols etcpp.!
105 virtual ~ShellJob();
107 //-------------------------------------------
108 // uno interface
109 public:
111 //---------------------------------------
112 // css.lang.XServiceInfo
113 DECLARE_XSERVICEINFO
115 // css.task.XJob
116 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
117 throw(css::lang::IllegalArgumentException,
118 css::uno::Exception ,
119 css::uno::RuntimeException );
121 //-------------------------------------------
122 // helper
123 private:
125 //---------------------------------------
126 /** generate a return value for method execute()
127 which will force deactivation of this job for further requests.
129 @return an Any following the job protocol for deactivation.
131 static css::uno::Any impl_generateAnswer4Deactivation();
133 //---------------------------------------
134 /** substitute all might existing placeholder variables
135 within the configured command.
137 The command is part of the job configuration.
138 These will make changes more easy (no code changes required).
139 Further the command can use placeholder as they are supported
140 by the global substitution service (e.g. $(prog) etcpp)
142 @param sCommand
143 the command containing placeholder variables.
145 @return the substituted command.
147 ::rtl::OUString impl_substituteCommandVariables(const ::rtl::OUString& sCommand);
149 //---------------------------------------
150 /** executes the command.
152 @param sCommand
153 the absolute command as URL or system path (without any argument !).
155 @param lArguments
156 the complete list of arguments configured for these job.
158 @param bCheckExitCode
159 bind the execution result to the exit code of the started process.
160 If it's set to false we return false only in case executable couldnt be found
161 or couldnt be started.
163 @return TRUE if command was executed successfully; FALSE otherwise.
165 ::sal_Bool impl_execute(const ::rtl::OUString& sCommand ,
166 const css::uno::Sequence< ::rtl::OUString >& lArguments ,
167 ::sal_Bool bCheckExitCode);
170 } // namespace framework
172 #endif // __FRAMEWORK_JOBS_SHELLJOB_HXX_