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