|
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 |

|
2006-12-18 08:47:23 |
Hi together,
this is my last day working for my current company and I'm
hanging on
following thing: I have to write one more UNO package. In
this
component, I need to get the current XComponent. I asked the
question
how to get the current XComponent out of an XFrame last
march and got
following answer:
-----%<-----
XComponent xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class, xFrame);
-----%<-----
The xFrame seems to be correctly initialized, because a
System.out.println(xFrame); says:
-----%<-----
CO> com.sun.star.bridges.jni_uno.JNI_proxy 911f71
[oid=86836f4;gcc3[0];836f2b8c8e7111dba26edb1441d9eca5,
type=com.sun.star.frame.XFrame]
-----%<-----
And now something horrible happens. As I query for the
XComponent as
described above, a System.out.println(xComponent); says:
-----%<----
CO> com.sun.star.bridges.jni_uno.JNI_proxy 911f71
[oid=86836f4;gcc3[0];836f2b8c8e7111dba26edb1441d9eca5,
type=com.sun.star.frame.XFrame]
-----%<----
This is the xFrame, not a xComponent!
Afterwards my package crashes with a NullPointerException
when using the
assumed XComponent. Why is the xComponent and xFrame exactly
the same?
Is there an other way to query for the XComponent?
Please help me!
Greetings, Tobias
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Getting the XComponent out of a XFrame
in a UNO Component |

|
2006-12-18 15:04:10 |
Hi together,
after testing, I wrote this little test method:
-----%<-----
public void test() {
XModel xModel =
(XModel)UnoRuntime.queryInterface(XModel.class,
this.xComponent);
com.sun.star.frame.XController xController =
xModel.getCurrentController();
System.out.println(this.xComponent);
System.out.println(xController);
XComponent myComp = (XComponent)
UnoRuntime.queryInterface(XComponent.class,
xController);
System.out.println(myComp.equals(this.xComponent));
}
-----%<-----
In my Opinion the last line should return true. Am I right?
But for me,
it prints false...
Greetings, Tobias
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Getting the XComponent out of a XFrame
in a UNO Component |

|
2006-12-18 14:20:42 |
Hi Tobias,
> after testing, I wrote this little test method:
> -----%<-----
> public void test() {
> XModel xModel =
(XModel)UnoRuntime.queryInterface(XModel.class,
> this.xComponent);
> com.sun.star.frame.XController xController =
> xModel.getCurrentController();
>
> System.out.println(this.xComponent);
>
> System.out.println(xController);
>
> XComponent myComp = (XComponent)
> UnoRuntime.queryInterface(XComponent.class,
> xController);
>
> System.out.println(myComp.equals(this.xComponent));
> }
> -----%<-----
>
> In my Opinion the last line should return true. Am I
right? But for
> me,
> it prints false...
Nope ... the java method equals won't work properly with
UNO-Objects
and as far as I remember always return false.
Beside this you seem to compare the XComponent gained from
the
document with the one gained from the document view which
are
unlikely to be equal anyway.
Regards
Stephan
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Getting the XComponent out of a XFrame
in a UNO Component |

|
2006-12-19 08:28:06 |
Tobias Krais wrote:
> Hi together,
>
> this is my last day working for my current company and
I'm hanging on
> following thing: I have to write one more UNO package.
In this
> component, I need to get the current XComponent. I
asked the question
> how to get the current XComponent out of an XFrame last
march and got
> following answer:
> -----%<-----
> XComponent xComponent = (XComponent)
> UnoRuntime.queryInterface(XComponent.class, xFrame);
> -----%<-----
I don't know who gave you this answer but it is either wrong
or you have
been misunderstood (or your question was misleading).
A frame is an object implementing XComponent (amongst other
interfaces)
and the code above retrieves this interface. As XFrame is
derived from
XComponent it is not surprising that both interfaces
references are the
same proxy object. This also means that the queryInterface
call is
superfluous as an XFrame "is" an XComponent.
The frame may contain a component that in case of documents
attached to
the frame is a controller object that also implements
XComponent. The
controller itself belongs to a model that also implements
XComponent.
Also here both object implement a lot more interfaces and
XController
and XModel again are derived from XComponent so again you
don't need to
use queryInterface if to get the XComponent interface from
an
XController or XModel interface.
So the question remains what the "current"
component of a frame should
be. It must be either the controller or the model object. I
assume it
should be the same object that you get as
"CurrentComponent" from the
desktop in case the frame in question is the
"current" one. As this is
the model I assume that frame.getController().getModel()
will give you
your "current component".
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 "nospamformba gmx.de".
I use it for the OOo lists and only rarely read other mails
sent to it.
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Getting the XComponent out of a XFrame
in a UNO Component |

|
2006-12-20 16:15:27 |
Hi Matthias,
> A frame is an object implementing XComponent (amongst
other interfaces)
> and the code above retrieves this interface. As XFrame
is derived from
> XComponent it is not surprising that both interfaces
references are the
> same proxy object. This also means that the
queryInterface call is
> superfluous as an XFrame "is" an XComponent.
Thank you for your answer. You may wonder, why I persevere
on the
XComponent, although I can us the XModel or XFrame. The
reason is, that
I have a ready class with the functionality I want. All I
have to do is
to instantciate this class. But the constructor needs a
XComponent.
After I read your mail, I reimplemented the class and made
it fitting
for the XModel. It worked out fine. So thanks for your help.
Greetings, Tobias
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
[1-5]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|