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