/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ /* This example shows a UNO component that inherits com.sun.star.lib.uno.helper.PropertySet in order to provide implementations of these interfaces: com.sun.star.beans.XPropertySet com.sun.star.beans.XMultiPropertySet com.sun.star.beans.XFastPropertySet com.sun.star.lang.XComponent com.sun.star.uno.XWeak com.sun.star.lang.XTypeProvider */ import com.sun.star.lib.uno.helper.PropertySet; import com.sun.star.comp.loader.FactoryHelper; import com.sun.star.lang.XServiceInfo; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XSingleServiceFactory; import com.sun.star.registry.XRegistryKey; import com.sun.star.uno.Any; import com.sun.star.uno.Type; import com.sun.star.uno.XInterface; import com.sun.star.lang.XTypeProvider; import com.sun.star.beans.PropertyAttribute; /** This component contains the following properties: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Property Name Type Name PropertyAttribute
boolABOOLEAN - *
charACHAR -
byteABYTE -
shortASHORT -
intALONG -
longAHYPER -
floatAFLOAT -
doubleADOUBLE -
stringASTRING -
objectAANY -
anyAANY -
typeATYPE -
xinterfaceAINTERFACE -
xtypeproviderAINTERFACE -
arBoolA[]boolean -
arCharA[]char -
arByteA[]byte -
arShortA[]short -
arIntA[]long -
arLongA[]hyper -
arFloatA[]float -
arDoubleA[]double -
arStringA[]string -
arObjectA[]any -
arXinterfaceA[]com.sun.star.uno.XInterface -
ar2BoolA[][]boolean -
boolClassAboolean -
charClassAchar -
byteClassAbyte -
shortClassAshort -
intClassAlong -
longClassAhyper -
floatClassAfloat -
doubleClassAdouble -
roIntAlongREADONLY
roIntClassAlongREADONLY
roObjectAanyREADONLY
roAnyAanyREADONLY
bcBoolAbooleanBOUND,CONSTRAINED
bcBoolClassAbooleanBOUND,CONSTRAINED
bcObjectAanyBOUND,CONSTRAINED
bcAnyAanyBOUND,CONSTRAINED
mvIntAlongMAYBEVOID
mvObjectAanyMAYBEVOID
mvAnyAanyMAYBEVOID
mvXinterfaceAanyMAYBEVOID
*/ public class PropTest extends PropertySet implements XServiceInfo { public boolean boolA; public char charA; public byte byteA; public short shortA; public int intA; public long longA; public float floatA; public double doubleA; public String stringA; // MAYBEVOID public Object objectA; // MAYBEVOID public Any anyA; // MAYBEVOID public Type typeA;// MAYBEVOID public XInterface xinterfaceA;// MAYBEVOID public XTypeProvider xtypeproviderA;// MAYBEVOID public boolean[] arBoolA; // MAYBEVOID public char[] arCharA; // MAYBEVOID public byte[] arByteA; // MAYBEVOID public short[] arShortA; // MAYBEVOID public int[] arIntA; // MAYBEVOID public long[] arLongA; // MAYBEVOID public float[] arFloatA; // MAYBEVOID public double[] arDoubleA; // MAYBEVOID public String[] arStringA; // MAYBEVOID public Object[] arObjectA; // MAYBEVOID public Any[] arAnyA; // MAYBEVOID public XInterface[] arXinterfaceA; // MAYBEVOID public boolean[][] ar2BoolA; // MAYBEVOID public Boolean boolClassA; // MAYBEVOID public Character charClassA; // MAYBEVOID public Byte byteClassA; // MAYBEVOID public Short shortClassA; // MAYBEVOID public Integer intClassA; // MAYBEVOID public Long longClassA; // MAYBEVOID public Float floatClassA; // MAYBEVOID public Double doubleClassA; // MAYBEVOID // readonly public int roIntA= 100; public Integer roIntClassA= new Integer(100); public Object roObjectA= new Integer(101); public Any roAnyA= new Any( new Type(int.class), new Integer(102)); // BOUND & CONSTRAINED public boolean bcBoolA; public Boolean bcBoolClassA; // MAYBEVOID public Object bcObjectA; // MAYBEVOID public Any bcAnyA; // MAYBEVOID // MAYBEVOID public Integer mvIntA; public Object mvObjectA; public Any mvAnyA; public XInterface mvXinterfaceA; public static final String __serviceName="PropTest"; public PropTest() { registerProperty("boolA", (short) 0); registerProperty("charA", (short) 0); registerProperty("byteA", (short) 0); registerProperty("shortA", (short) 0); registerProperty("intA", (short) 0); registerProperty("longA", (short) 0); registerProperty("floatA", (short) 0); registerProperty("doubleA", (short) 0); registerProperty("stringA", PropertyAttribute.MAYBEVOID); registerProperty("objectA", PropertyAttribute.MAYBEVOID); registerProperty("anyA", PropertyAttribute.MAYBEVOID); registerProperty("typeA", PropertyAttribute.MAYBEVOID); registerProperty("xinterfaceA", PropertyAttribute.MAYBEVOID); registerProperty("xtypeproviderA", PropertyAttribute.MAYBEVOID); registerProperty("arBoolA", PropertyAttribute.MAYBEVOID); registerProperty("arCharA", PropertyAttribute.MAYBEVOID); registerProperty("arByteA", PropertyAttribute.MAYBEVOID); registerProperty("arShortA", PropertyAttribute.MAYBEVOID); registerProperty("arIntA", PropertyAttribute.MAYBEVOID); registerProperty("arLongA", PropertyAttribute.MAYBEVOID); registerProperty("arFloatA", PropertyAttribute.MAYBEVOID); registerProperty("arDoubleA", PropertyAttribute.MAYBEVOID); registerProperty("arStringA", PropertyAttribute.MAYBEVOID); registerProperty("arObjectA", PropertyAttribute.MAYBEVOID); registerProperty("arAnyA", PropertyAttribute.MAYBEVOID); registerProperty("arXinterfaceA", PropertyAttribute.MAYBEVOID); registerProperty("ar2BoolA", PropertyAttribute.MAYBEVOID); registerProperty("boolClassA", PropertyAttribute.MAYBEVOID); registerProperty("charClassA", PropertyAttribute.MAYBEVOID); registerProperty("byteClassA", PropertyAttribute.MAYBEVOID); registerProperty("shortClassA", PropertyAttribute.MAYBEVOID); registerProperty("intClassA", PropertyAttribute.MAYBEVOID); registerProperty("longClassA", PropertyAttribute.MAYBEVOID); registerProperty("floatClassA", PropertyAttribute.MAYBEVOID); registerProperty("doubleClassA", PropertyAttribute.MAYBEVOID); registerProperty("roIntA", PropertyAttribute.READONLY); registerProperty("roIntClassA", PropertyAttribute.READONLY); registerProperty("roObjectA", PropertyAttribute.READONLY); registerProperty("roAnyA", PropertyAttribute.READONLY); registerProperty("bcBoolA",(short) ( PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED)); registerProperty("bcBoolClassA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID)); registerProperty("bcObjectA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID)); registerProperty("bcAnyA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED |PropertyAttribute.MAYBEVOID)); registerProperty("mvIntA", PropertyAttribute.MAYBEVOID); registerProperty("mvObjectA", PropertyAttribute.MAYBEVOID); registerProperty("mvAnyA", PropertyAttribute.MAYBEVOID); registerProperty("mvXinterfaceA", PropertyAttribute.MAYBEVOID); } // XServiceName public String getImplementationName( ) { return getClass().getName(); } // XServiceName public boolean supportsService( /*IN*/String name ) { if (name.equals(__serviceName)) return true; return false; } //XServiceName public String[] getSupportedServiceNames( ) { String[] retValue= new String[]{__serviceName}; return retValue; } public static XSingleServiceFactory __getServiceFactory(String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) { XSingleServiceFactory xSingleServiceFactory = null; if (implName.equals( PropTest.class.getName()) ) xSingleServiceFactory = FactoryHelper.getServiceFactory( PropTest.class, PropTest.__serviceName, multiFactory, regKey); return xSingleServiceFactory; } // This method not longer necessary since OOo 3.4 where the component registration // was changed to passive component registration. For more details see // https://wiki.openoffice.org/wiki/Passive_Component_Registration // public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) // { // return FactoryHelper.writeRegistryServiceInfo( PropTest.class.getName(), // PropTest.__serviceName, regKey); // } }