1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 package test;
28 
29 import com.sun.star.lang.XInitialization;
30 import com.sun.star.task.XJob;
31 import com.sun.star.lang.XSingleServiceFactory;
32 import com.sun.star.beans.*;
33 import com.sun.star.container.*;
34 import com.sun.star.lang.XServiceInfo;
35 import com.sun.star.lang.XTypeProvider;
36 import com.sun.star.uno.Type;
37 import com.sun.star.uno.Any;
38 import com.sun.star.frame.XDispatch;
39 import com.sun.star.frame.XDispatchProvider;
40 import com.sun.star.frame.XModel;
41 import com.sun.star.util.XURLTransformer;
42 import com.sun.star.frame.XController;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.util.URL;
45 import com.sun.star.lang.XMultiServiceFactory;
46 import util.utils;
47 import com.sun.star.lang.XComponent;
48 import lib.StatusException;
49 import util.SOfficeFactory;
50 import com.sun.star.registry.XRegistryKey;
51 import com.sun.star.comp.loader.FactoryHelper;
52 
53 
54 public class Job {
55 
56     static public class _Implementation implements XServiceInfo, XTypeProvider,
57             XJob, XNamed {
58 	static private final String __serviceName = "test.Job";
59         Object oDoc = null;
60         String actionType = null;
61         String actionParm = null;
62         XMultiServiceFactory oMSF = null;
63 
64 
65 	public _Implementation(XMultiServiceFactory xMSF) {
66             oMSF = xMSF;
67 	}
68 
69 	// XServiceInfo
70 	public String getImplementationName() throws com.sun.star.uno.RuntimeException {
71 	    return getClass().getName();
72 	}
73 
74 	public boolean supportsService(String serviceName) throws com.sun.star.uno.RuntimeException {
75 	    return __serviceName.equals(serviceName);
76 	}
77 
78 	public String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
79 	    return new String[] {__serviceName};
80 	}
81 
82         public static int executed = 0;
83         public Object execute(NamedValue[] args) {
84             executed++;
85 
86             return null;
87         }
88 
89         public String getName() {
90             return  "" + executed;
91         }
92 
93         public void setName(String n) {
94         }
95 
96 	public byte[] getImplementationId() {
97 	    return toString().getBytes();
98 	}
99 
100 	public Type[] getTypes() {
101 	    Class interfaces[] = getClass().getInterfaces();
102 	    Type types[] = new Type[interfaces.length];
103 	    for(int i = 0; i < interfaces.length; ++ i)
104 		types[i] = new Type(interfaces[i]);
105 	    return types;
106 	}
107 
108     }
109 
110     public static XSingleServiceFactory __getServiceFactory(String implName,
111 							    XMultiServiceFactory multiFactory,
112 							    XRegistryKey regKey) {
113 	XSingleServiceFactory xSingleServiceFactory = null;
114 	xSingleServiceFactory = FactoryHelper.getServiceFactory(_Implementation.class,
115 								    _Implementation.__serviceName,
116 								    multiFactory,
117 								    regKey);
118 	return xSingleServiceFactory;
119     }
120 
121 
122     public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
123 	boolean result = true;
124 	result = FactoryHelper.writeRegistryServiceInfo(_Implementation.class.getName(),
125 							  _Implementation.__serviceName, regKey);
126 	return result;
127     }
128 }
129