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 28 package testtools.servicetests; 29 30 import com.sun.star.lang.NoSupportException; 31 import com.sun.star.lang.XServiceInfo; 32 import com.sun.star.lang.XSingleComponentFactory; 33 /*import com.sun.star.uno.OptionalPropertyException;*/ 34 /*import com.sun.star.uno.VoidPropertyException;*/ 35 import com.sun.star.uno.XComponentContext; 36 37 public final class TestService implements XServiceInfo, XSingleComponentFactory 38 { 39 public String getImplementationName() { 40 return getClass().getName(); 41 } 42 43 public boolean supportsService(String serviceName) { 44 return serviceName.equals(SERVICE_NAME); 45 } 46 47 public String[] getSupportedServiceNames() { 48 return new String[] { SERVICE_NAME }; 49 } 50 51 public Object createInstanceWithContext(XComponentContext context) 52 throws com.sun.star.uno.Exception 53 { 54 return new Service(); 55 } 56 57 public Object createInstanceWithArgumentsAndContext( 58 Object[] arguments, XComponentContext context) 59 throws com.sun.star.uno.Exception 60 { 61 throw new NoSupportException( 62 "createInstanceWithArgumentsAndContext", this); 63 } 64 65 private static final class Service implements TestService2, XTestService3 { 66 public int fn1() { 67 return 1; 68 } 69 70 public int getProp1() { 71 return prop1; 72 } 73 74 public void setProp1(int value) { 75 prop1 = value; 76 } 77 78 public int getProp2() { 79 return 2; 80 } 81 82 /*public int getProp3Void() throws VoidPropertyException { 83 throw new VoidPropertyException("Prop3Void", this); 84 }*/ 85 86 public int getProp3Long() /*throws VoidPropertyException*/ { 87 return 3; 88 } 89 90 /*public int getProp4None() throws OptionalPropertyException { 91 throw new OptionalPropertyException("Prop4None", this); 92 }*/ 93 94 public int getProp4Long() /*throws OptionalPropertyException*/ { 95 return 4; 96 } 97 98 /*public int getProp5None() 99 throws OptionalPropertyException, VoidPropertyException 100 { 101 throw new OptionalPropertyException("Prop4None", this); 102 }*/ 103 104 /*public int getProp5Void() 105 throws OptionalPropertyException, VoidPropertyException 106 { 107 throw new VoidPropertyException("Prop4None", this); 108 }*/ 109 110 public int getProp5Long() 111 /*throws OptionalPropertyException, VoidPropertyException*/ 112 { 113 return 5; 114 } 115 116 public int getProp6() /*throws VoidPropertyException*/ { 117 /*if (prop6 == null) { 118 throw new VoidPropertyException("Prop6", this); 119 } else {*/ 120 return prop6.intValue(); 121 /*}*/ 122 } 123 124 public void setProp6(int value) { 125 prop6 = new Integer(value); 126 } 127 128 /*public void clearProp6() { 129 prop6 = null; 130 }*/ 131 132 /*public int getProp7None() 133 throws OptionalPropertyException, VoidPropertyException 134 { 135 throw new OptionalPropertyException("Prop7None", this); 136 }*/ 137 138 /*public void setProp7None(int value) throws OptionalPropertyException { 139 throw new OptionalPropertyException("Prop7None", this); 140 }*/ 141 142 /*public void clearProp7None() throws OptionalPropertyException { 143 throw new OptionalPropertyException("Prop7None", this); 144 }*/ 145 146 public int getProp7() 147 /*throws OptionalPropertyException, VoidPropertyException*/ 148 { 149 /*if (prop7 == null) { 150 throw new VoidPropertyException("Prop7", this); 151 } else {*/ 152 return prop7.intValue(); 153 /*}*/ 154 } 155 156 public void setProp7(int value) /*throws OptionalPropertyException*/ { 157 prop7 = new Integer(value); 158 } 159 160 /*public void clearProp7() throws OptionalPropertyException { 161 prop7 = null; 162 }*/ 163 164 /*public int getProp8None() throws OptionalPropertyException { 165 throw new OptionalPropertyException("Prop8None", this); 166 }*/ 167 168 /*public void setProp8None(int value) throws OptionalPropertyException { 169 throw new OptionalPropertyException("Prop8None", this); 170 }*/ 171 172 public int getProp8Long() /*throws OptionalPropertyException*/ { 173 return prop8; 174 } 175 176 public void setProp8Long(int value) /*throws OptionalPropertyException*/ 177 { 178 prop8 = value; 179 } 180 181 public int fn2() { 182 return 2; 183 } 184 185 public int fn3() { 186 return 3; 187 } 188 189 private int prop1 = 1; 190 private Integer prop6 = new Integer(6); 191 private Integer prop7 = new Integer(7); 192 private int prop8 = 8; 193 } 194 195 private static final String SERVICE_NAME 196 = "testtools.servicetests.TestService2"; 197 } 198