List Info

Thread: Getting the XComponent out of a XFrame in a UNO Component




Getting the XComponent out of a XFrame in a UNO Component
user name
2006-12-20 20:04:41
Hi Stephan

>>>> -----%<-----
>>>> System.out.println(this.xComponent);
>>>>
>>>> XModel xModel =
(XModel)UnoRuntime.queryInterface(XModel.class,
>>>>     this.xComponent);
>>>> System.out.println(xModel);
>>>>
>>>> XController xController =
xModel.getCurrentController();
>>>> System.out.println(xController);
>>>>
>>>> XComponent myComp = (XComponent)
>>>>    
UnoRuntime.queryInterface(XComponent.class,
>>>>              xController);
>>>> System.out.println(myComp);
>>
>> XStorable xStorable = (XStorable)
>>          
UnoRuntime.queryInterface(XStorable.class, myComp);
>>
>> // This will be null
>> System.out.println(xStorable);
>>
>> xStorable = (XStorable)
>>     UnoRuntime.queryInterface(XStorable.class,
this.xComponent);
>>
>> // This is the correct XStorable
>> System.out.println(xStorable);
>>>> -----%<-----

> Obviously not.  You have two different UNO objects
here,
> "this.xComponent" and
"xModel.getCurrentController".  The UNO object
> "this.xComponent" obviously supports XModel
and XStorable (as querying
> that UNO object for those interfaces returns a non-null
reference), and
> the UNO object "xModel.getCurrentController"
obviously supports
> XController and XComponent, but not XStorable (as
querying that UNO
> object for that interface returns a null reference).

True. But why does myComp not support the XStorable,
although it is the
same document with the same URL?

> I know much about UNO technology in general, but little
about the
> specifics of the OOo API, so I have no idea whether
this.xComponent and
> ((XModel)this.xComponent).getCurrentController() should
reference the
> same UNO object.  I saw Mathias Bauer (who does know
all the specifics
> of the OOo API) already answer on this thread, maybe
you should re-read
> his post.

I read his answer carefully and it helped me to solve my
problem with
the code. But I don't understand why there is a difference
between the
this.xComponent and myComp. Maybe Mathias can answer me.

Greetings, Tobias

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )