1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir package test;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.lang.XInitialization;
26cdf0e10cSrcweir import com.sun.star.task.XJob;
27cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory;
28cdf0e10cSrcweir import com.sun.star.beans.*;
29cdf0e10cSrcweir import com.sun.star.container.*;
30cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo;
31cdf0e10cSrcweir import com.sun.star.lang.XTypeProvider;
32cdf0e10cSrcweir import com.sun.star.uno.Type;
33cdf0e10cSrcweir import com.sun.star.uno.Any;
34cdf0e10cSrcweir import com.sun.star.frame.XDispatch;
35cdf0e10cSrcweir import com.sun.star.frame.XDispatchProvider;
36cdf0e10cSrcweir import com.sun.star.frame.XModel;
37cdf0e10cSrcweir import com.sun.star.util.XURLTransformer;
38cdf0e10cSrcweir import com.sun.star.frame.XController;
39cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
40cdf0e10cSrcweir import com.sun.star.util.URL;
41cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
42cdf0e10cSrcweir import util.utils;
43cdf0e10cSrcweir import com.sun.star.lang.XComponent;
44cdf0e10cSrcweir import lib.StatusException;
45cdf0e10cSrcweir import util.SOfficeFactory;
46cdf0e10cSrcweir import com.sun.star.registry.XRegistryKey;
47cdf0e10cSrcweir import com.sun.star.comp.loader.FactoryHelper;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir public class Job {
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     static public class _Implementation implements XServiceInfo, XTypeProvider,
53cdf0e10cSrcweir             XJob, XNamed {
54cdf0e10cSrcweir 	static private final String __serviceName = "test.Job";
55cdf0e10cSrcweir         Object oDoc = null;
56cdf0e10cSrcweir         String actionType = null;
57cdf0e10cSrcweir         String actionParm = null;
58cdf0e10cSrcweir         XMultiServiceFactory oMSF = null;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 
_Implementation(XMultiServiceFactory xMSF)61cdf0e10cSrcweir 	public _Implementation(XMultiServiceFactory xMSF) {
62cdf0e10cSrcweir             oMSF = xMSF;
63cdf0e10cSrcweir 	}
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	// XServiceInfo
getImplementationName()66cdf0e10cSrcweir 	public String getImplementationName() throws com.sun.star.uno.RuntimeException {
67cdf0e10cSrcweir 	    return getClass().getName();
68cdf0e10cSrcweir 	}
69cdf0e10cSrcweir 
supportsService(String serviceName)70cdf0e10cSrcweir 	public boolean supportsService(String serviceName) throws com.sun.star.uno.RuntimeException {
71cdf0e10cSrcweir 	    return __serviceName.equals(serviceName);
72cdf0e10cSrcweir 	}
73cdf0e10cSrcweir 
getSupportedServiceNames()74cdf0e10cSrcweir 	public String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
75cdf0e10cSrcweir 	    return new String[] {__serviceName};
76cdf0e10cSrcweir 	}
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         public static int executed = 0;
execute(NamedValue[] args)79cdf0e10cSrcweir         public Object execute(NamedValue[] args) {
80cdf0e10cSrcweir             executed++;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir             return null;
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir 
getName()85cdf0e10cSrcweir         public String getName() {
86cdf0e10cSrcweir             return  "" + executed;
87cdf0e10cSrcweir         }
88cdf0e10cSrcweir 
setName(String n)89cdf0e10cSrcweir         public void setName(String n) {
90cdf0e10cSrcweir         }
91cdf0e10cSrcweir 
getImplementationId()92cdf0e10cSrcweir 	public byte[] getImplementationId() {
93cdf0e10cSrcweir 	    return toString().getBytes();
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 
getTypes()96cdf0e10cSrcweir 	public Type[] getTypes() {
97cdf0e10cSrcweir 	    Class interfaces[] = getClass().getInterfaces();
98cdf0e10cSrcweir 	    Type types[] = new Type[interfaces.length];
99cdf0e10cSrcweir 	    for(int i = 0; i < interfaces.length; ++ i)
100cdf0e10cSrcweir 		types[i] = new Type(interfaces[i]);
101cdf0e10cSrcweir 	    return types;
102cdf0e10cSrcweir 	}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir 
__getServiceFactory(String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)106cdf0e10cSrcweir     public static XSingleServiceFactory __getServiceFactory(String implName,
107cdf0e10cSrcweir 							    XMultiServiceFactory multiFactory,
108cdf0e10cSrcweir 							    XRegistryKey regKey) {
109cdf0e10cSrcweir 	XSingleServiceFactory xSingleServiceFactory = null;
110cdf0e10cSrcweir 	xSingleServiceFactory = FactoryHelper.getServiceFactory(_Implementation.class,
111cdf0e10cSrcweir 								    _Implementation.__serviceName,
112cdf0e10cSrcweir 								    multiFactory,
113cdf0e10cSrcweir 								    regKey);
114cdf0e10cSrcweir 	return xSingleServiceFactory;
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
__writeRegistryServiceInfo(XRegistryKey regKey)118cdf0e10cSrcweir     public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
119cdf0e10cSrcweir 	boolean result = true;
120cdf0e10cSrcweir 	result = FactoryHelper.writeRegistryServiceInfo(_Implementation.class.getName(),
121cdf0e10cSrcweir 							  _Implementation.__serviceName, regKey);
122cdf0e10cSrcweir 	return result;
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir }
125