private static Type sequenceComponentType(Type sequenceType) { // assert sequenceType.getTypeClass() == TypeClass.SEQUENCE; String n = sequenceType.getTypeName(); final String PREFIX = "[]"; // assert n.startsWith(PREFIX); return new Type(n.substring(PREFIX.length())); }
/** retrieves the current value */ public Object getValue(com.sun.star.uno.Type type) throws com.sun.star.form.binding.IncompatibleTypesException { if (!type.equals(getStringType())) throw new com.sun.star.form.binding.IncompatibleTypesException(); return m_cellText.getString(); }
public String getClassName() { String sClassName = ""; if (m_nNodeType == XUnoNode.nINTERFACE) { sClassName = aType.getTypeName(); } else if (m_nNodeType == XUnoNode.nSERVICE) { sClassName = sLabel; } return sClassName; }
private boolean hasRefHolder(String oid, Type type) { synchronized (refHolders) { LinkedList<RefHolder> l = refHolders.get(oid); if (l != null) { for (RefHolder rh : l) { if (type.isSupertypeOf(rh.getType())) { return true; } } } } return false; }
protected static String[] getDisplayValuesofPrimitiveArray(Object _oUnoObject) { String[] sDisplayValues = null; try { Type aType = AnyConverter.getType(_oUnoObject); TypeClass aTypeClass = aType.getTypeClass(); int nTypeValue = aTypeClass.getValue(); if (nTypeValue == TypeClass.SEQUENCE_value) { nTypeValue = (sequenceComponentType(aType)).getTypeClass().getValue(); } switch (nTypeValue) { case TypeClass.BOOLEAN_value: boolean[] bBooleans = (boolean[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[bBooleans.length]; for (int i = 0; i < bBooleans.length; i++) { sDisplayValues[i] = Boolean.toString(bBooleans[i]); } break; case TypeClass.BYTE_value: byte[] bBytes = (byte[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[bBytes.length]; for (int i = 0; i < bBytes.length; i++) { sDisplayValues[i] = "" + bBytes[i]; } break; case TypeClass.DOUBLE_value: double[] fdoubles = (double[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[fdoubles.length]; for (int i = 0; i < fdoubles.length; i++) { sDisplayValues[i] = String.valueOf(fdoubles[i]); } break; case TypeClass.FLOAT_value: float[] ffloats = (float[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[ffloats.length]; for (int i = 0; i < ffloats.length; i++) { sDisplayValues[i] = String.valueOf(ffloats[i]); } break; case TypeClass.LONG_value: int[] nints = (int[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[nints.length]; for (int i = 0; i < nints.length; i++) { sDisplayValues[i] = String.valueOf(nints[i]); } break; case TypeClass.HYPER_value: long[] nlongs = (long[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[nlongs.length]; for (int i = 0; i < nlongs.length; i++) { sDisplayValues[i] = String.valueOf(nlongs[i]); } break; case TypeClass.SHORT_value: short[] nShorts = (short[]) AnyConverter.toArray(_oUnoObject); sDisplayValues = new String[nShorts.length]; for (int i = 0; i < nShorts.length; i++) { sDisplayValues[i] = "" + nShorts[i]; } break; case TypeClass.CHAR_value: break; default: System.out.println( "Value could not be retrieved: " + aType.getTypeClass().getClass().getName()); } return sDisplayValues; } catch (Exception e) { System.err.println(e); return null; } }
/** determines whether a given value type is supported */ public boolean supportsType(com.sun.star.uno.Type type) { return type.equals(getStringType()); }