public static Any createAny(Object o) { return new Any(new Type(o.getClass()), o); } }
boolean bAnyVal= setVal instanceof Any; if (bAnyVal) bVoidValue= ((Any) setVal).getObject() == null; else bVoidValue= setVal == null; convObj= new Any(new Type(XInterface.class), xint); convObj= new Any(new Type(), null); else convObj= new Any( ((Any)curVal[0]).getType(), null); convObj= new Any(new Type(setVal.getClass()), setVal);
public static XTextTable getTableByName(XComponent xComponent, String tableName) throws NoSuchElementException, WrappedTargetException { XNameAccess tables = as(XTextTablesSupplier.class, xComponent).getTextTables(); return (XTextTable) ((Any) tables.getByName(tableName)).getObject(); }
boolean bAnyVal= setVal instanceof Any; if (bAnyVal) bVoidValue= ((Any) setVal).getObject() == null; else bVoidValue= setVal == null; convObj= new Any(new Type(XInterface.class), xint); convObj= new Any(new Type(), null); else convObj= new Any( ((Any)curVal[0]).getType(), null); convObj= new Any(new Type(setVal.getClass()), setVal);
public static XTextTable getTableByName(XComponent xComponent, String tableName) throws NoSuchElementException, WrappedTargetException { XNameAccess tables = as(XTextTablesSupplier.class, xComponent).getTextTables(); return (XTextTable) ((Any) tables.getByName(tableName)).getObject(); }
public static Any createAny(Object o) { return new Any(new Type(o.getClass()), o); } }
private void writeAnyValue(Object value) { TypeDescription type; if (value == null || value instanceof XInterface) { type = TypeDescription.getTypeDescription(XInterface.class); } else if (value instanceof Any) { Any any = (Any) value; try { type = TypeDescription.getTypeDescription(any.getType()); } catch (ClassNotFoundException e) { throw new RuntimeException(e.toString()); } value = any.getObject(); } else if (value.getClass() == Object.class) { // Avoid StackOverflowError: throw new IllegalArgumentException( "Object instance does not represent UNO value"); } else { type = TypeDescription.getTypeDescription(value.getClass()); } writeType(type); writeValue(type, value); }
/** Complete a UNO <code>ANY</code> (make sure it is wrapped up as an <code>Any</code> instance). @param any a Java value representing a UNO <code>ANY</code> value. @return a complete Java value (that is, an <code>Any</code> instance) representing the same UNO <code>ANY</code> value as the given argument. @since UDK 3.2.3 */ public static final Any complete(Object any) { return any instanceof Any ? (Any) any : new Any( new Type(any == null ? XInterface.class : any.getClass()), any); }
private void writeAnyValue(Object value) throws ClassNotFoundException { TypeDescription type; if (value == null || value instanceof XInterface) { type = TypeDescription.getTypeDescription(XInterface.class); } else if (value instanceof Any) { Any any = (Any) value; type = TypeDescription.getTypeDescription(any.getType()); value = any.getObject(); } else if (value.getClass() == Object.class) { // Avoid StackOverflowError: throw new IllegalArgumentException( "Object instance does not represent UNO value"); } else { type = TypeDescription.getTypeDescription(value.getClass()); } writeType(type); writeValue(type, value); }
/** * Complete a UNO <code>ANY</code> (make sure it is wrapped up as an * <code>Any</code> instance). * * @param any a Java value representing a UNO <code>ANY</code> value. * @return a complete Java value (that is, an <code>Any</code> instance) * representing the same UNO <code>ANY</code> value as the given argument. * @since UDK 3.2.3 */ public static final Any complete(Object any) { return any instanceof Any ? (Any) any : new Any( new Type(any == null ? XInterface.class : any.getClass()), any); }
/** Determines the type of an any object. @param object any object @return type object */ static public Type getType( Object object ) { Type t; if (null == object) { t = m_XInterface_type; } else if (object instanceof Any) { t = ((Any)object).getType(); // nested any if (TypeClass.ANY_value == t.getTypeClass().getValue()) return getType( ((Any)object).getObject() ); } else { t = new Type( object.getClass() ); } return t; }
/** * Returns an Any containing a sequences of com.sun.star.beans.NamedValue. One NamedValue * contains the name "WINDOW" and the value is a Long representing the window handle. * The second NamedValue has the name "XEMBED" and the value is true, when the XEmbed * protocol shall be used fore embedding the native Window. */ protected Any getWrappedWindowHandle() { NamedValue window = new NamedValue( "WINDOW", new Any(new Type(Long.class), Long.valueOf(getNativeWindow()))); NamedValue xembed = new NamedValue( "XEMBED", new Any(new Type(Boolean.class), Boolean.FALSE)); if (getNativeWindowSystemType() == SystemDependent.SYSTEM_XWINDOW ) { String vendor = System.getProperty("java.vendor"); if ((vendor.equals("Sun Microsystems Inc.") || vendor.equals("Oracle Corporation")) && Boolean.getBoolean("sun.awt.xembedserver")) { xembed = new NamedValue( "XEMBED", new Any(new Type(Boolean.class), Boolean.TRUE)); } } return new Any( new Type("[]com.sun.star.beans.NamedValue"), new NamedValue[] {window, xembed}); }