Antoine POURCHEZ wrote:
> Hello,
> I want to load and next update an ODT in a java
program. To do that, i
> write this code :
> Object vDesktop = OoBootstrap.createDesktop();
> XComponentLoader vCompLoader =
(XComponentLoader)
> UnoRuntime.queryInterface(XComponentLoader.class,
vDesktop);
>
> String vUrl =
"_file://".concat(((File_)
> pSrc).toURL().toExternalForm().substring(5));
> PropertyValue vProps[] = new
PropertyValue[1];
> vProps[0] = new PropertyValue();
> vProps[0].Name = "Hidden";
> vProps[0].Value = Boolean.TRUE;
> Object vDocSrc =
vCompLoader.loadComponentFromURL(vUrl,
> "_blank", 0, vProps);
>
> XFrame vFrameDoc = ((XModel)
> UnoRuntime.queryInterface(XModel.class,
> vDocSrc)).getCurrentController().getFrame();
>
> XDispatchHelper vDipatchHelper =
>
(XDispatchHelper)UnoRuntime.queryInterface(XDispatchHelper.c
lass,
>
OoBootstrap.createService("com.sun.star.frame.Dispatch
Helper"));
>
>
>
vDipatchHelper.executeDispatch((XDispatchProvider)UnoRuntime
.queryInterface(XDispatchProvider.class,
> vFrameDoc), ".uno:UpdateAllIndexes",
"", 0, null);
>
> In some big documents, this generate a crash of
openOffice : i think
> that the document is not totaly load when
"executeDispatch" is execute.
The document is loaded completely after
loadComponentFromURL() returned
the model. But might be there are some asynchronous layout
routines.
On the other side such asynchronous layout must deal with
the situation
that it will be disturbed from outside. And further you
loaded the
document with HIDDEN=TRUE so there is no need for such
operations after
loading.
For me it looks like a "simple .-)" bug. If it
can be reproduced by you
with some special documents, please file an issue attaching
one or two
test documents.
>
> Can XComponentLoader generate an event when all the
document is load?
There is already such event. But it's not generated by the
component
loader itself. It's generated by the document, which was
loaded and will
be broadcasted by another singleton instance named
com.sun.star.frame.GlobalEventBroadcaster (which implements
the
interface css.document.XEventBroadcaster.
The callback css.document.XEventListener.notifyEvent()
contains a
reference to the model. For loading (or creating empty)
documents exists
different events.
OnNew => for creating a new empty (visible) doc
OnLoad => for loading an existing doc (visible) from disc
OnCreate => for creating an empty (hidden) doc
OnLoadFinished => for loading an existing doc (hidden)
from disc
> Thank you.
> Antoine POURCHEZ
> antoine.pourchez kelis.fr
>
Regards
Andreas
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|