Rony G. Flatscher wrote:
Hi there,
maybe I am overlooking the obvious.
When creating a service object like:
o =
context.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop",
context );
and therafter using reflection (theCoreReflection is a reference to
"/singletons/com.sun.star.reflection.theCoreReflection" from a default
bootstraped context, ie. context=Bootstrap.bootstrap()):
XIdlClass xidl=theCoreReflection.getType(o);
String name=xidl.getName(); // returns the fully qualified type name
will return as type "com.sun.star.uno.XInterface" instead of
"com.sun.star.frame.Desktop". This is true for any service one
instantiates via Java.
The documentation for com.sun.star.reflection.XIdlReflection.getType has
this to say:
---8<---
/** [...] This method takes
the type of the object the any contains into account. [...]
*/
com::sun::star::reflection::XIdlClass getType( [in] any aObj );
---8<---
Which shows that getType takes an argument of type "any" (which should
be an "any" that contains an interface type), and returns an XIdlClass
that represents the interface type contained in the "any" (in other
words, that method is pretty useless, and definitely confusing to use).
In the Java UNO language binding, a Java reference to Object is
acceptable as a value of type "any", but will be interpreted at runtime
as an "any" of type com.sun.star.uno.XInterface (see
<http://udk.openoffice.org/java/man/types.html>). Hence, your xidl
represents com.sun.star.uno.XInterface.
If you want to find out what (interface) types a given UNO object
supports, use com.sun.star.lang.XTypeProvider.
-Stephan
---
Also, any interface object will also return an XIdlClass representing
"com.sun.star.uno.XInterface" instead of the class representing the
respective interface class.
---.
Is this working as designed (the behaviour is the same on OOo 1.5 and
2.0) ? If so, how can one unambiguously retrieve the typename of any
object at runtime from Java (ie. get its fully qualified class name)?
Regards,
---rony
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]