Hi Stephan,

> com.sun.star.container.XIndexAccess.getByIndex returns an ANY value,
> which in the Java-UNO binding maps to
> java.lang.Object/com.sun.star.uno.Any in a somewhat hard-to-use way:
> 
> PropertyValue[] oDateiMenuSettings;
> try {
>   oDateiMenuSettings = com.sun.star.uno.AnyConverter.toObject(
>     PropertyValue[].class, oMenuBarSettings.getByIndex(0));
> } catch (com.sun.star.lang.IllegalArgumentException e) {
>   throw new RuntimeException(e.toString());
> }

thanks for the hint. The code above does not work for me, because an
Object is returned and a PropertyValue[] is expected. I first have to
cast it. Here the code I use:

-----%<-----
PropertyValue[] oDateiMenuSettings = (PropertyValue[])
       UnoRuntime.queryInterface(PropertyValue[].class,
                oMenuBarSettings.getByIndex(0));
XIndexAccess xoDateiMenuSettings = (XIndexAccess)
       UnoRuntime.queryInterface(XIndexAccess.class,
                (Object)oDateiMenuSettings[2].Value);
PropertyValue[] speichernUnter = (PropertyValue[])
        UnoRuntime.queryInterface(PropertyValue[].class,
                xoDateiMenuSettings.getByIndex(8));
-----%<-----

> UnoRuntime.queryInterface is used to go from a reference of UNO
> interface type A to some UNO object to a reference of UNO interface type
> B to the same UNO object.

I read this in the dev-guide.

> AnyConverter is used to extract (the Java
> representations of) arbitrary UNO values contained in (the Java
> representaton of) a UNO ANY value.

This is new for me and interesting. I think I will use it in future.
This seems to be the "clean" way of my code above.

Thanks,

Tobias

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to