Makaray wrote:

> Hi, i have problem with embedded object. I'm using
> XTextEmbeddedObjectsSupplier in writter document, to get access to
> this object. This object give me a list of all embedded elements in
> document. Property "Model" should give me a XComponent object, but
> sometimes it's null value. Does anybody know why ??
Embedded objects can have several states. Usually they are in "loaded"
state. That means, only a small component wrapper is instantiated. The
whole component behind the embedded object is only loaded if the object
is put into "running" state. This way documents with many embedded
objects use less memory and display faster.

So if you didn't get a "model" most probably your object is in "loaded"
state. You must first retrieve the "Component" property of the embeddded
object. It provides an interface com.sun.star.embed.XEmbeddedObject with
the method "changeState" that can be used to set the object into the
state com.sun.star.embed.EmbedStates.RUNNING. As the object may be in
other states (e.g. active) you should whether the object's state is
com.sun.star.embed.LOADED before and only then switch the state.

If the object is in "running" (or active) state the "model" property
should be non-zero.

As correctly pointed out by Sascha there are some objects that don't
have a model - even in running state (e.g. plugins, Java applets or
floating frames). And other embedded objects even refuse to enter the
"running state" (e.g. Windows OLE-objects without a server installed).
So be prepared for exceptions in changeState() calls!

Ciao,
Matias

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

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

Reply via email to