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 com.sun.star.wizards.letter; 24 25 import com.sun.star.beans.XPropertyAccess; 26 import com.sun.star.comp.loader.FactoryHelper; 27 import com.sun.star.lang.XInitialization; 28 import com.sun.star.lang.XMultiServiceFactory; 29 import com.sun.star.lang.XServiceInfo; 30 import com.sun.star.lang.XSingleServiceFactory; 31 import com.sun.star.lang.XTypeProvider; 32 import com.sun.star.registry.XRegistryKey; 33 import com.sun.star.task.XJob; 34 import com.sun.star.task.XJobExecutor; 35 import com.sun.star.uno.Type; 36 import com.sun.star.wizards.common.PropertyNames; 37 38 /** 39 * This class capsulates the class, that implements the minimal component, a factory for 40 * creating the service (<CODE>__getServiceFactory</CODE>). 41 * 42 * @author $author$ 43 * @version $Revision: 1.3.192.1 $ 44 */ 45 public class CallWizard 46 { 47 48 /** 49 * Gives a factory for creating the service. This method is called by the 50 * <code>JavaLoader</code> 51 * 52 * <p></p> 53 * 54 * @param stringImplementationName The implementation name of the component. 55 * @param xMSF The service manager, who gives access to every known service. 56 * @param xregistrykey Makes structural information (except regarding tree 57 * structures) of a single registry key accessible. 58 * 59 * @return Returns a <code>XSingleServiceFactory</code> for creating the component. 60 * 61 * @see com.sun.star.comp.loader.JavaLoader# 62 */ __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey)63 public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey) 64 { 65 XSingleServiceFactory xsingleservicefactory = null; 66 67 if (stringImplementationName.equals(WizardImplementation.class.getName())) 68 { 69 xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__serviceName, xMSF, xregistrykey); 70 } 71 72 return xsingleservicefactory; 73 } 74 75 /** 76 * This class implements the component. At least the interfaces XServiceInfo, 77 * XTypeProvider, and XInitialization should be provided by the service. 78 */ 79 public static class WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor 80 { 81 82 /** 83 * The constructor of the inner class has a XMultiServiceFactory parameter. 84 * 85 * @param xmultiservicefactoryInitialization A special service factory could be 86 * introduced while initializing. 87 */ WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization)88 public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization) 89 { 90 xmultiservicefactory = xmultiservicefactoryInitialization; 91 92 if (xmultiservicefactory != null) 93 { 94 } 95 } 96 97 /** 98 * Execute Wizard 99 * 100 * @param str only valid parameter is 'start' at the moment. 101 */ trigger(String str)102 public void trigger(String str) 103 { 104 if (str.equalsIgnoreCase(PropertyNames.START)) 105 { 106 LetterWizardDialogImpl lw = new LetterWizardDialogImpl(xmultiservicefactory); 107 if (!LetterWizardDialogImpl.running) 108 { 109 lw.startWizard(xmultiservicefactory, null); 110 } 111 } 112 } //******************************************* 113 /** 114 * The service name, that must be used to get an instance of this service. 115 */ 116 private static final String __serviceName = "com.sun.star.wizards.letter.CallWizard"; 117 /** 118 * The service manager, that gives access to all registered services. 119 */ 120 private XMultiServiceFactory xmultiservicefactory; 121 122 /** 123 * This method is a member of the interface for initializing an object directly 124 * after its creation. 125 * 126 * @param object This array of arbitrary objects will be passed to the component 127 * after its creation. 128 * 129 * @throws com.sun.star.uno.Exception Every exception will not be handled, but 130 * will be passed to the caller. 131 */ initialize(Object[] object)132 public void initialize(Object[] object) throws com.sun.star.uno.Exception 133 { 134 } 135 136 /** 137 * This method returns an array of all supported service names. 138 * 139 * @return Array of supported service names. 140 */ getSupportedServiceNames()141 public java.lang.String[] getSupportedServiceNames() 142 { 143 String[] stringSupportedServiceNames = new String[1]; 144 stringSupportedServiceNames[0] = __serviceName; 145 146 return (stringSupportedServiceNames); 147 } 148 149 /** 150 * This method returns true, if the given service will be supported by the 151 * component. 152 * 153 * @param stringService Service name. 154 * 155 * @return True, if the given service name will be supported. 156 */ supportsService(String stringService)157 public boolean supportsService(String stringService) 158 { 159 boolean booleanSupportsService = false; 160 161 if (stringService.equals(__serviceName)) 162 { 163 booleanSupportsService = true; 164 } 165 166 return (booleanSupportsService); 167 } 168 169 /** 170 * This method returns an array of bytes, that can be used to unambiguously 171 * distinguish between two sets of types, e.g. to realise hashing functionality 172 * when the object is introspected. Two objects that return the same ID also 173 * have to return the same set of types in getTypes(). If an unique 174 * implementation Id cannot be provided this method has to return an empty 175 * sequence. Important: If the object aggregates other objects the ID has to be 176 * unique for the whole combination of objects. 177 * 178 * @return Array of bytes, in order to distinguish between two sets. 179 */ getImplementationId()180 public byte[] getImplementationId() 181 { 182 byte[] byteReturn = 183 { 184 }; 185 186 try 187 { 188 byteReturn = (PropertyNames.EMPTY_STRING + this.hashCode()).getBytes(); 189 } 190 catch (Exception exception) 191 { 192 System.err.println(exception); 193 } 194 195 return (byteReturn); 196 } 197 198 /** 199 * Return the class name of the component. 200 * 201 * @return Class name of the component. 202 */ getImplementationName()203 public java.lang.String getImplementationName() 204 { 205 return (WizardImplementation.class.getName()); 206 } 207 208 /** 209 * Provides a sequence of all types (usually interface types) provided by the 210 * object. 211 * 212 * @return Sequence of all types (usually interface types) provided by the 213 * service. 214 */ getTypes()215 public com.sun.star.uno.Type[] getTypes() 216 { 217 Type[] typeReturn = 218 { 219 }; 220 221 try 222 { 223 typeReturn = new Type[] 224 { 225 new Type(XPropertyAccess.class), new Type(XJob.class), new Type(XJobExecutor.class), new Type(XTypeProvider.class), new Type(XServiceInfo.class), new Type(XInitialization.class) 226 }; 227 } 228 catch (Exception exception) 229 { 230 System.err.println(exception); 231 } 232 233 return (typeReturn); 234 } 235 } 236 } 237