134dd1e25SAndrew Rist /************************************************************** 2*be8bac39Smseidel * 334dd1e25SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 434dd1e25SAndrew Rist * or more contributor license agreements. See the NOTICE file 534dd1e25SAndrew Rist * distributed with this work for additional information 634dd1e25SAndrew Rist * regarding copyright ownership. The ASF licenses this file 734dd1e25SAndrew Rist * to you under the Apache License, Version 2.0 (the 834dd1e25SAndrew Rist * "License"); you may not use this file except in compliance 934dd1e25SAndrew Rist * with the License. You may obtain a copy of the License at 10*be8bac39Smseidel * 1134dd1e25SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*be8bac39Smseidel * 1334dd1e25SAndrew Rist * Unless required by applicable law or agreed to in writing, 1434dd1e25SAndrew Rist * software distributed under the License is distributed on an 1534dd1e25SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1634dd1e25SAndrew Rist * KIND, either express or implied. See the License for the 1734dd1e25SAndrew Rist * specific language governing permissions and limitations 1834dd1e25SAndrew Rist * under the License. 19*be8bac39Smseidel * 2034dd1e25SAndrew Rist *************************************************************/ 2134dd1e25SAndrew Rist 2234dd1e25SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir /* 25*be8bac39Smseidel This example shows a UNO component that inherits com.sun.star.lib.uno.helper.PropertySet in 26*be8bac39Smseidel order to provide implementations of these interfaces: 27cdf0e10cSrcweir 28cdf0e10cSrcweir com.sun.star.beans.XPropertySet 29cdf0e10cSrcweir com.sun.star.beans.XMultiPropertySet 30cdf0e10cSrcweir com.sun.star.beans.XFastPropertySet 31cdf0e10cSrcweir com.sun.star.lang.XComponent 32cdf0e10cSrcweir com.sun.star.uno.XWeak 33cdf0e10cSrcweir com.sun.star.lang.XTypeProvider 34cdf0e10cSrcweir */ 35cdf0e10cSrcweir import com.sun.star.lib.uno.helper.PropertySet; 36cdf0e10cSrcweir import com.sun.star.comp.loader.FactoryHelper; 37cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo; 38cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 39cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory; 40cdf0e10cSrcweir import com.sun.star.registry.XRegistryKey; 41cdf0e10cSrcweir import com.sun.star.uno.Any; 42cdf0e10cSrcweir import com.sun.star.uno.Type; 43cdf0e10cSrcweir import com.sun.star.uno.XInterface; 44cdf0e10cSrcweir import com.sun.star.lang.XTypeProvider; 45cdf0e10cSrcweir import com.sun.star.beans.PropertyAttribute; 46cdf0e10cSrcweir 47cdf0e10cSrcweir /** 48*be8bac39Smseidel This component contains the following properties: 49cdf0e10cSrcweir * <table border> 50cdf0e10cSrcweir * <tr> 51cdf0e10cSrcweir * <th> Property Name </th> 52cdf0e10cSrcweir * <th> Type Name </th> 53cdf0e10cSrcweir * <th> PropertyAttribute </th> 54cdf0e10cSrcweir * <tr><td>boolA</td><td>BOOLEAN</td><td> - </td</tr> 55cdf0e10cSrcweir * <tr><td>charA</td><td>CHAR</td><td> - </td></tr> 56cdf0e10cSrcweir * <tr><td>byteA</td><td>BYTE</td><td> - </td></tr> 57cdf0e10cSrcweir * <tr><td>shortA</td><td>SHORT</td><td> - </td></tr> 58cdf0e10cSrcweir * <tr><td>intA</td><td>LONG</td><td> - </td></tr> 59cdf0e10cSrcweir * <tr><td>longA</td><td>HYPER</td><td> - </td></tr> 60cdf0e10cSrcweir * <tr><td>floatA</td><td>FLOAT</td><td> - </td></tr> 61cdf0e10cSrcweir * <tr><td>doubleA</td><td>DOUBLE</td><td> - </td></tr> 62cdf0e10cSrcweir * <tr><td>stringA</td><td>STRING</td><td> - </td></tr> 63cdf0e10cSrcweir * <tr><td>objectA</td><td>ANY</td><td> - </td></tr> 64cdf0e10cSrcweir * <tr><td>anyA</td><td>ANY</td><td> - </td></tr> 65cdf0e10cSrcweir * <tr><td>typeA</td><td>TYPE</td><td> - </td></tr> 66cdf0e10cSrcweir * <tr><td>xinterfaceA</td><td>INTERFACE</td><td> - </td></tr> 67cdf0e10cSrcweir * <tr><td>xtypeproviderA</td><td>INTERFACE</td><td> - </td></tr> 68cdf0e10cSrcweir * <tr><td>arBoolA</td><td>[]boolean</td><td> - </td></tr> 69cdf0e10cSrcweir * <tr><td>arCharA</td><td>[]char</td><td> - </td></tr> 70cdf0e10cSrcweir * <tr><td>arByteA</td><td>[]byte</td><td> - </td></tr> 71cdf0e10cSrcweir * <tr><td>arShortA</td><td>[]short</td><td> - </td></tr> 72cdf0e10cSrcweir * <tr><td>arIntA</td><td>[]long</td><td> - </td></tr> 73cdf0e10cSrcweir * <tr><td>arLongA</td><td>[]hyper</td><td> - </td></tr> 74cdf0e10cSrcweir * <tr><td>arFloatA</td><td>[]float</td><td> - </td></tr> 75cdf0e10cSrcweir * <tr><td>arDoubleA</td><td>[]double</td><td> - </td></tr> 76cdf0e10cSrcweir * <tr><td>arStringA</td><td>[]string</td><td> - </td></tr> 77cdf0e10cSrcweir * <tr><td>arObjectA</td><td>[]any</td><td> - </td></tr> 78cdf0e10cSrcweir * <tr><td>arXinterfaceA</td><td>[]com.sun.star.uno.XInterface</td><td> - </td></tr> 79cdf0e10cSrcweir * <tr><td>ar2BoolA</td><td>[][]boolean</td><td> - </td></tr> 80cdf0e10cSrcweir * <tr><td>boolClassA</td><td>boolean</td><td> - </td></tr> 81cdf0e10cSrcweir * <tr><td>charClassA</td><td>char</td><td> - </td></tr> 82cdf0e10cSrcweir * <tr><td>byteClassA</td><td>byte</td><td> - </td></tr> 83cdf0e10cSrcweir * <tr><td>shortClassA</td><td>short</td><td> - </td></tr> 84cdf0e10cSrcweir * <tr><td>intClassA</td><td>long</td><td> - </td></tr> 85cdf0e10cSrcweir * <tr><td>longClassA</td><td>hyper</td><td> - </td></tr> 86cdf0e10cSrcweir * <tr><td>floatClassA</td><td>float</td><td> - </td></tr> 87cdf0e10cSrcweir * <tr><td>doubleClassA</td><td>double</td><td> - </td></tr> 88cdf0e10cSrcweir * <tr><td>roIntA</td><td>long</td><td>READONLY</td></tr> 89cdf0e10cSrcweir * <tr><td>roIntClassA</td><td>long</td><td>READONLY</td></tr> 90cdf0e10cSrcweir * <tr><td>roObjectA</td><td>any</td><td>READONLY</td></tr> 91cdf0e10cSrcweir * <tr><td>roAnyA</td><td>any</td><td>READONLY</td></tr> 92cdf0e10cSrcweir * <tr><td>bcBoolA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr> 93cdf0e10cSrcweir * <tr><td>bcBoolClassA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr> 94cdf0e10cSrcweir * <tr><td>bcObjectA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr> 95cdf0e10cSrcweir * <tr><td>bcAnyA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr> 96cdf0e10cSrcweir * <tr><td>mvIntA</td><td>long</td><td>MAYBEVOID</td></tr> 97cdf0e10cSrcweir * <tr><td>mvObjectA</td><td>any</td><td>MAYBEVOID</td></tr> 98cdf0e10cSrcweir * <tr><td>mvAnyA</td><td>any</td><td>MAYBEVOID</td></tr> 99cdf0e10cSrcweir * <tr><td>mvXinterfaceA</td><td>any</td><td>MAYBEVOID</td></tr> 100cdf0e10cSrcweir </table> 101cdf0e10cSrcweir */ 102cdf0e10cSrcweir 103cdf0e10cSrcweir public class PropTest extends PropertySet implements XServiceInfo 104cdf0e10cSrcweir { 105cdf0e10cSrcweir 106cdf0e10cSrcweir public boolean boolA; 107cdf0e10cSrcweir public char charA; 108cdf0e10cSrcweir public byte byteA; 109cdf0e10cSrcweir public short shortA; 110cdf0e10cSrcweir public int intA; 111cdf0e10cSrcweir public long longA; 112cdf0e10cSrcweir public float floatA; 113cdf0e10cSrcweir public double doubleA; 114cdf0e10cSrcweir public String stringA; // MAYBEVOID 115cdf0e10cSrcweir public Object objectA; // MAYBEVOID 116cdf0e10cSrcweir public Any anyA; // MAYBEVOID 117cdf0e10cSrcweir public Type typeA;// MAYBEVOID 118cdf0e10cSrcweir public XInterface xinterfaceA;// MAYBEVOID 119cdf0e10cSrcweir public XTypeProvider xtypeproviderA;// MAYBEVOID 120cdf0e10cSrcweir public boolean[] arBoolA; // MAYBEVOID 121cdf0e10cSrcweir public char[] arCharA; // MAYBEVOID 122cdf0e10cSrcweir public byte[] arByteA; // MAYBEVOID 123cdf0e10cSrcweir public short[] arShortA; // MAYBEVOID 124cdf0e10cSrcweir public int[] arIntA; // MAYBEVOID 125cdf0e10cSrcweir public long[] arLongA; // MAYBEVOID 126cdf0e10cSrcweir public float[] arFloatA; // MAYBEVOID 127cdf0e10cSrcweir public double[] arDoubleA; // MAYBEVOID 128cdf0e10cSrcweir public String[] arStringA; // MAYBEVOID 129cdf0e10cSrcweir public Object[] arObjectA; // MAYBEVOID 130cdf0e10cSrcweir public Any[] arAnyA; // MAYBEVOID 131cdf0e10cSrcweir public XInterface[] arXinterfaceA; // MAYBEVOID 132*be8bac39Smseidel public boolean[][] ar2BoolA; // MAYBEVOID 133cdf0e10cSrcweir public Boolean boolClassA; // MAYBEVOID 134cdf0e10cSrcweir public Character charClassA; // MAYBEVOID 135*be8bac39Smseidel public Byte byteClassA; // MAYBEVOID 136*be8bac39Smseidel public Short shortClassA; // MAYBEVOID 137cdf0e10cSrcweir public Integer intClassA; // MAYBEVOID 138cdf0e10cSrcweir public Long longClassA; // MAYBEVOID 139cdf0e10cSrcweir public Float floatClassA; // MAYBEVOID 140cdf0e10cSrcweir public Double doubleClassA; // MAYBEVOID 141cdf0e10cSrcweir 142cdf0e10cSrcweir // readonly 143cdf0e10cSrcweir public int roIntA= 100; 144*be8bac39Smseidel public Integer roIntClassA= new Integer(100); 145cdf0e10cSrcweir public Object roObjectA= new Integer(101); 146cdf0e10cSrcweir public Any roAnyA= new Any( new Type(int.class), new Integer(102)); 147cdf0e10cSrcweir 148cdf0e10cSrcweir // BOUND & CONSTRAINED 149cdf0e10cSrcweir public boolean bcBoolA; 150cdf0e10cSrcweir public Boolean bcBoolClassA; // MAYBEVOID 151cdf0e10cSrcweir public Object bcObjectA; // MAYBEVOID 152*be8bac39Smseidel public Any bcAnyA; // MAYBEVOID 153cdf0e10cSrcweir 154cdf0e10cSrcweir // MAYBEVOID 155cdf0e10cSrcweir public Integer mvIntA; 156cdf0e10cSrcweir public Object mvObjectA; 157cdf0e10cSrcweir public Any mvAnyA; 158cdf0e10cSrcweir public XInterface mvXinterfaceA; 159*be8bac39Smseidel 160cdf0e10cSrcweir public static final String __serviceName="PropTest"; 161cdf0e10cSrcweir PropTest()162cdf0e10cSrcweir public PropTest() { 163cdf0e10cSrcweir registerProperty("boolA", (short) 0); 164cdf0e10cSrcweir registerProperty("charA", (short) 0); 165cdf0e10cSrcweir registerProperty("byteA", (short) 0); 166cdf0e10cSrcweir registerProperty("shortA", (short) 0); 167cdf0e10cSrcweir registerProperty("intA", (short) 0); 168cdf0e10cSrcweir registerProperty("longA", (short) 0); 169cdf0e10cSrcweir registerProperty("floatA", (short) 0); 170cdf0e10cSrcweir registerProperty("doubleA", (short) 0); 171cdf0e10cSrcweir registerProperty("stringA", PropertyAttribute.MAYBEVOID); 172cdf0e10cSrcweir registerProperty("objectA", PropertyAttribute.MAYBEVOID); 173cdf0e10cSrcweir registerProperty("anyA", PropertyAttribute.MAYBEVOID); 174cdf0e10cSrcweir registerProperty("typeA", PropertyAttribute.MAYBEVOID); 175cdf0e10cSrcweir registerProperty("xinterfaceA", PropertyAttribute.MAYBEVOID); 176cdf0e10cSrcweir registerProperty("xtypeproviderA", PropertyAttribute.MAYBEVOID); 177cdf0e10cSrcweir registerProperty("arBoolA", PropertyAttribute.MAYBEVOID); 178cdf0e10cSrcweir registerProperty("arCharA", PropertyAttribute.MAYBEVOID); 179cdf0e10cSrcweir registerProperty("arByteA", PropertyAttribute.MAYBEVOID); 180cdf0e10cSrcweir registerProperty("arShortA", PropertyAttribute.MAYBEVOID); 181cdf0e10cSrcweir registerProperty("arIntA", PropertyAttribute.MAYBEVOID); 182cdf0e10cSrcweir registerProperty("arLongA", PropertyAttribute.MAYBEVOID); 183cdf0e10cSrcweir registerProperty("arFloatA", PropertyAttribute.MAYBEVOID); 184cdf0e10cSrcweir registerProperty("arDoubleA", PropertyAttribute.MAYBEVOID); 185cdf0e10cSrcweir registerProperty("arStringA", PropertyAttribute.MAYBEVOID); 186cdf0e10cSrcweir registerProperty("arObjectA", PropertyAttribute.MAYBEVOID); 187cdf0e10cSrcweir registerProperty("arAnyA", PropertyAttribute.MAYBEVOID); 188cdf0e10cSrcweir registerProperty("arXinterfaceA", PropertyAttribute.MAYBEVOID); 189cdf0e10cSrcweir registerProperty("ar2BoolA", PropertyAttribute.MAYBEVOID); 190cdf0e10cSrcweir registerProperty("boolClassA", PropertyAttribute.MAYBEVOID); 191cdf0e10cSrcweir registerProperty("charClassA", PropertyAttribute.MAYBEVOID); 192cdf0e10cSrcweir registerProperty("byteClassA", PropertyAttribute.MAYBEVOID); 193cdf0e10cSrcweir registerProperty("shortClassA", PropertyAttribute.MAYBEVOID); 194cdf0e10cSrcweir registerProperty("intClassA", PropertyAttribute.MAYBEVOID); 195cdf0e10cSrcweir registerProperty("longClassA", PropertyAttribute.MAYBEVOID); 196cdf0e10cSrcweir registerProperty("floatClassA", PropertyAttribute.MAYBEVOID); 197cdf0e10cSrcweir registerProperty("doubleClassA", PropertyAttribute.MAYBEVOID); 198cdf0e10cSrcweir registerProperty("roIntA", PropertyAttribute.READONLY); 199cdf0e10cSrcweir registerProperty("roIntClassA", PropertyAttribute.READONLY); 200cdf0e10cSrcweir registerProperty("roObjectA", PropertyAttribute.READONLY); 201cdf0e10cSrcweir registerProperty("roAnyA", PropertyAttribute.READONLY); 202cdf0e10cSrcweir registerProperty("bcBoolA",(short) ( PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED)); 203cdf0e10cSrcweir registerProperty("bcBoolClassA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID)); 204cdf0e10cSrcweir registerProperty("bcObjectA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID)); 205cdf0e10cSrcweir registerProperty("bcAnyA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED |PropertyAttribute.MAYBEVOID)); 206cdf0e10cSrcweir registerProperty("mvIntA", PropertyAttribute.MAYBEVOID); 207cdf0e10cSrcweir registerProperty("mvObjectA", PropertyAttribute.MAYBEVOID); 208cdf0e10cSrcweir registerProperty("mvAnyA", PropertyAttribute.MAYBEVOID); 209cdf0e10cSrcweir registerProperty("mvXinterfaceA", PropertyAttribute.MAYBEVOID); 210cdf0e10cSrcweir } 211*be8bac39Smseidel 212cdf0e10cSrcweir 213cdf0e10cSrcweir // XServiceName getImplementationName( )214cdf0e10cSrcweir public String getImplementationName( ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir return getClass().getName(); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir // XServiceName supportsService( String name )220cdf0e10cSrcweir public boolean supportsService( /*IN*/String name ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir if (name.equals(__serviceName)) 223cdf0e10cSrcweir return true; 224cdf0e10cSrcweir return false; 225cdf0e10cSrcweir } 226*be8bac39Smseidel 227cdf0e10cSrcweir //XServiceName getSupportedServiceNames( )228cdf0e10cSrcweir public String[] getSupportedServiceNames( ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir String[] retValue= new String[]{__serviceName}; 231cdf0e10cSrcweir return retValue; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir __getServiceFactory(String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)234cdf0e10cSrcweir public static XSingleServiceFactory __getServiceFactory(String implName, 235cdf0e10cSrcweir XMultiServiceFactory multiFactory, 236cdf0e10cSrcweir XRegistryKey regKey) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir XSingleServiceFactory xSingleServiceFactory = null; 239cdf0e10cSrcweir 240cdf0e10cSrcweir if (implName.equals( PropTest.class.getName()) ) 241cdf0e10cSrcweir xSingleServiceFactory = FactoryHelper.getServiceFactory( PropTest.class, 242cdf0e10cSrcweir PropTest.__serviceName, 243cdf0e10cSrcweir multiFactory, 244cdf0e10cSrcweir regKey); 245cdf0e10cSrcweir 246cdf0e10cSrcweir return xSingleServiceFactory; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir // This method not longer necessary since OOo 3.4 where the component registration 250cdf0e10cSrcweir // was changed to passive component registration. For more details see 251*be8bac39Smseidel // https://wiki.openoffice.org/wiki/Passive_Component_Registration 252cdf0e10cSrcweir 253*be8bac39Smseidel // public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) 254cdf0e10cSrcweir // { 255cdf0e10cSrcweir // return FactoryHelper.writeRegistryServiceInfo( PropTest.class.getName(), 256cdf0e10cSrcweir // PropTest.__serviceName, regKey); 257cdf0e10cSrcweir // } 258cdf0e10cSrcweir } 259*be8bac39Smseidel 260