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 14:48:44
Hi Stephan,

I extend the code below for better understanding, what I
mean.

>> -----%<-----
>> 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);
>> -----%<-----

Am I right when I assume that myComp is the same as in the
first line
and that it does not make a difference in using it?

If so, why is the xStorable derived from myComp = null and
the xStorable
derived from this.xComponent the correct value?

Maybe this behaviour is correct. If so, please tell me why.
What I want
to explain all the time is, that I think there should be no
difference
using myComp and this.xComponent, but it is a great
difference.

> Excuse my ignorance, but in how far does myComp not
offer the
> functionality of an XComponent?  The functionality of
XComponent is to
> offer a protocol (see the UNOIDL documentation of
XComponent for
> details) involving the three methods dispose,
addEventListener,
> removeEventListener.  Your above code does not make any
use of myComp
> that would back your claim that myComp "does NOT
offer the functionality
> of an XComponent."

Thank you for your patience and that you do not give up
understanding
me. I really appreciate your efforts in understanding me!

Greetings, Tobias

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

Getting the XComponent out of a XFrame in a UNO Component
user name
2006-12-20 17:28:25
Tobias Krais wrote:

> Hi Stephan,
> 
> I extend the code below for better understanding, what
I mean.
> 
> -----%<-----
> 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);
>>> -----%<-----
> 
> Am I right when I assume that myComp is the same as in
the first line
> and that it does not make a difference in using it?

No.

> If so, why is the xStorable derived from myComp = null
and the xStorable
> derived from this.xComponent the correct value?

myComp points to a Controller object. This object doesn not
support
XStorable.

this.xComponent points to a Model object. This object *does*
support
XStorable.

Both objects OTOH support XComponent (as some others do).
And *all*
objects support XInterface. Where is the problem?

It seems that you mixed up the "component" of a
frame (an abstract term
for the "something" that a frame may contain) with
the interface
XComponent that can be (and is) implemented by a lot of
objects in OOo,
most of them will never become attached to a frame.

> 
> Maybe this behaviour is correct. If so, please tell me
why. What I want
> to explain all the time is, that I think there should
be no difference
> using myComp and this.xComponent, but it is a great
difference.

myComp and this.xComponent from your example are interface
references
that belong to different objects. You should read the
chapter about
Frames, Controllers, Models in the DevGuide to understand
the difference
between models and controllers.

Ciao,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/Gu
llFOSS
Please don't reply to "nospamformbagmx.de".
I use it for the OOo lists and only rarely read other mails
sent to it.

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

Getting the XComponent out of a XFrame in a UNO Component
user name
2006-12-23 17:50:50
Hi Matthias,

>> Am I right when I assume that myComp is the same as
in the first line
>> and that it does not make a difference in using it?
> 
> No.
> 
>> If so, why is the xStorable derived from myComp =
null and the xStorable
>> derived from this.xComponent the correct value?
> 
> myComp points to a Controller object. This object doesn
not support
> XStorable.
> 
> this.xComponent points to a Model object. This object
*does* support
> XStorable.
> 
> Both objects OTOH support XComponent (as some others
do). And *all*
> objects support XInterface. Where is the problem?
> 
> It seems that you mixed up the "component" of
a frame (an abstract term
> for the "something" that a frame may contain)
with the interface
> XComponent that can be (and is) implemented by a lot of
objects in OOo,
> most of them will never become attached to a frame.
> 
>> Maybe this behaviour is correct. If so, please tell
me why. What I want
>> to explain all the time is, that I think there
should be no difference
>> using myComp and this.xComponent, but it is a great
difference.
> 
> myComp and this.xComponent from your example are
interface references
> that belong to different objects. You should read the
chapter about
> Frames, Controllers, Models in the DevGuide to
understand the difference
> between models and controllers.

Now the things I wanted to do are working. Thank you for
your
explanations. Now I see, that your tip to read the capter
about
Frames,... is really useful for me. I mixed up something.
Sorry for
taking so long time. But thanks a lot for your great help!

Greetings, Tobias

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

Getting the XComponent out of a XFrame in a UNO Component
user name
2006-12-23 19:11:50
Hi again,

one addition:

> Now the things I wanted to do are working. Thank you
for your
> explanations.

I had a method taking an XComponent. After your explanations
I
understood, that I can give over a XModel instead. The
method did not
complain. That is one thing I did not understand.

Greetings and thanks again,

Tobias

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

[1-4]

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