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