1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir package com.sun.star.wizards.agenda; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir import com.sun.star.beans.XPropertyAccess; 30*cdf0e10cSrcweir import com.sun.star.comp.loader.FactoryHelper; 31*cdf0e10cSrcweir import com.sun.star.lang.XInitialization; 32*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 33*cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo; 34*cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory; 35*cdf0e10cSrcweir import com.sun.star.lang.XTypeProvider; 36*cdf0e10cSrcweir import com.sun.star.registry.XRegistryKey; 37*cdf0e10cSrcweir import com.sun.star.task.XJob; 38*cdf0e10cSrcweir import com.sun.star.task.XJobExecutor; 39*cdf0e10cSrcweir import com.sun.star.uno.Type; 40*cdf0e10cSrcweir import com.sun.star.wizards.common.PropertyNames; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir /** 43*cdf0e10cSrcweir * This class capsulates the class, that implements the minimal component, a factory for 44*cdf0e10cSrcweir * creating the service (<CODE>__getServiceFactory</CODE>). 45*cdf0e10cSrcweir * 46*cdf0e10cSrcweir * @author $author$ 47*cdf0e10cSrcweir * @version $Revision: 1.5.52.1 $ 48*cdf0e10cSrcweir */ 49*cdf0e10cSrcweir public class CallWizard { 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /** 52*cdf0e10cSrcweir * Gives a factory for creating the service. This method is called by the 53*cdf0e10cSrcweir * <code>JavaLoader</code> 54*cdf0e10cSrcweir * 55*cdf0e10cSrcweir * <p></p> 56*cdf0e10cSrcweir * 57*cdf0e10cSrcweir * @param stringImplementationName The implementation name of the component. 58*cdf0e10cSrcweir * @param xMSF The service manager, who gives access to every known service. 59*cdf0e10cSrcweir * @param xregistrykey Makes structural information (except regarding tree 60*cdf0e10cSrcweir * structures) of a single registry key accessible. 61*cdf0e10cSrcweir * 62*cdf0e10cSrcweir * @return Returns a <code>XSingleServiceFactory</code> for creating the component. 63*cdf0e10cSrcweir * 64*cdf0e10cSrcweir * @see com.sun.star.comp.loader.JavaLoader# 65*cdf0e10cSrcweir */ 66*cdf0e10cSrcweir public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey) { 67*cdf0e10cSrcweir XSingleServiceFactory xsingleservicefactory = null; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir if (stringImplementationName.equals(WizardImplementation.class.getName())) { 70*cdf0e10cSrcweir xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__serviceName, xMSF, xregistrykey); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir return xsingleservicefactory; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir /** 77*cdf0e10cSrcweir * This class implements the component. At least the interfaces XServiceInfo, 78*cdf0e10cSrcweir * XTypeProvider, and XInitialization should be provided by the service. 79*cdf0e10cSrcweir */ 80*cdf0e10cSrcweir public static class WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor { 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /** 83*cdf0e10cSrcweir * The constructor of the inner class has a XMultiServiceFactory parameter. 84*cdf0e10cSrcweir * 85*cdf0e10cSrcweir * @param xmultiservicefactoryInitialization A special service factory could be 86*cdf0e10cSrcweir * introduced while initializing. 87*cdf0e10cSrcweir */ 88*cdf0e10cSrcweir public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization) { 89*cdf0e10cSrcweir xmultiservicefactory = xmultiservicefactoryInitialization; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir if (xmultiservicefactory != null) { 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /** 97*cdf0e10cSrcweir * Execute Wizard 98*cdf0e10cSrcweir * 99*cdf0e10cSrcweir * @param str only valid parameter is 'start' at the moment. 100*cdf0e10cSrcweir */ 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir public void trigger(String str) { 103*cdf0e10cSrcweir try { 104*cdf0e10cSrcweir if (str.equalsIgnoreCase(PropertyNames.START)) { 105*cdf0e10cSrcweir AgendaWizardDialogImpl aw = new AgendaWizardDialogImpl(xmultiservicefactory); 106*cdf0e10cSrcweir if (!AgendaWizardDialogImpl.running) { 107*cdf0e10cSrcweir aw.startWizard(); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir catch (Exception ex) { 112*cdf0e10cSrcweir ex.printStackTrace(); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir //******************************************* 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir /** 119*cdf0e10cSrcweir * The service name, that must be used to get an instance of this service. 120*cdf0e10cSrcweir */ 121*cdf0e10cSrcweir private static final String __serviceName = "com.sun.star.wizards.agenda.CallWizard"; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir /** 124*cdf0e10cSrcweir * The service manager, that gives access to all registered services. 125*cdf0e10cSrcweir */ 126*cdf0e10cSrcweir private XMultiServiceFactory xmultiservicefactory; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir /** 129*cdf0e10cSrcweir * This method is a member of the interface for initializing an object directly 130*cdf0e10cSrcweir * after its creation. 131*cdf0e10cSrcweir * 132*cdf0e10cSrcweir * @param object This array of arbitrary objects will be passed to the component 133*cdf0e10cSrcweir * after its creation. 134*cdf0e10cSrcweir * 135*cdf0e10cSrcweir * @throws com.sun.star.uno.Exception Every exception will not be handled, but 136*cdf0e10cSrcweir * will be passed to the caller. 137*cdf0e10cSrcweir */ 138*cdf0e10cSrcweir public void initialize(Object[] object) throws com.sun.star.uno.Exception { 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir /** 143*cdf0e10cSrcweir * This method returns an array of all supported service names. 144*cdf0e10cSrcweir * 145*cdf0e10cSrcweir * @return Array of supported service names. 146*cdf0e10cSrcweir */ 147*cdf0e10cSrcweir public java.lang.String[] getSupportedServiceNames() { 148*cdf0e10cSrcweir String[] stringSupportedServiceNames = new String[1]; 149*cdf0e10cSrcweir stringSupportedServiceNames[0] = __serviceName; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir return (stringSupportedServiceNames); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir /** 155*cdf0e10cSrcweir * This method returns true, if the given service will be supported by the 156*cdf0e10cSrcweir * component. 157*cdf0e10cSrcweir * 158*cdf0e10cSrcweir * @param stringService Service name. 159*cdf0e10cSrcweir * 160*cdf0e10cSrcweir * @return True, if the given service name will be supported. 161*cdf0e10cSrcweir */ 162*cdf0e10cSrcweir public boolean supportsService(String stringService) { 163*cdf0e10cSrcweir boolean booleanSupportsService = false; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if (stringService.equals(__serviceName)) { 166*cdf0e10cSrcweir booleanSupportsService = true; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir return (booleanSupportsService); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir /** 173*cdf0e10cSrcweir * This method returns an array of bytes, that can be used to unambiguously 174*cdf0e10cSrcweir * distinguish between two sets of types, e.g. to realise hashing functionality 175*cdf0e10cSrcweir * when the object is introspected. Two objects that return the same ID also 176*cdf0e10cSrcweir * have to return the same set of types in getTypes(). If an unique 177*cdf0e10cSrcweir * implementation Id cannot be provided this method has to return an empty 178*cdf0e10cSrcweir * sequence. Important: If the object aggregates other objects the ID has to be 179*cdf0e10cSrcweir * unique for the whole combination of objects. 180*cdf0e10cSrcweir * 181*cdf0e10cSrcweir * @return Array of bytes, in order to distinguish between two sets. 182*cdf0e10cSrcweir */ 183*cdf0e10cSrcweir public byte[] getImplementationId() { 184*cdf0e10cSrcweir byte[] byteReturn = { 185*cdf0e10cSrcweir }; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir try { 188*cdf0e10cSrcweir byteReturn = (PropertyNames.EMPTY_STRING + this.hashCode()).getBytes(); 189*cdf0e10cSrcweir } catch (Exception exception) { 190*cdf0e10cSrcweir System.err.println(exception); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir return (byteReturn); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir /** 197*cdf0e10cSrcweir * Return the class name of the component. 198*cdf0e10cSrcweir * 199*cdf0e10cSrcweir * @return Class name of the component. 200*cdf0e10cSrcweir */ 201*cdf0e10cSrcweir public java.lang.String getImplementationName() { 202*cdf0e10cSrcweir return (WizardImplementation.class.getName()); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir /** 206*cdf0e10cSrcweir * Provides a sequence of all types (usually interface types) provided by the 207*cdf0e10cSrcweir * object. 208*cdf0e10cSrcweir * 209*cdf0e10cSrcweir * @return Sequence of all types (usually interface types) provided by the 210*cdf0e10cSrcweir * service. 211*cdf0e10cSrcweir */ 212*cdf0e10cSrcweir public com.sun.star.uno.Type[] getTypes() { 213*cdf0e10cSrcweir Type[] typeReturn = { 214*cdf0e10cSrcweir }; 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir try { 217*cdf0e10cSrcweir 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*cdf0e10cSrcweir } catch (Exception exception) { 219*cdf0e10cSrcweir System.err.println(exception); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir return (typeReturn); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226