Bernard Marcelly wrote:

> With OOo 2.0.4 on Win XP Home.
> In a writer document, I execute a macro which creates a new document 
> from an existing template. This template contains several textFields 
> (Date, Time) and a macro started at document creation, which writes on 
> the created document the number of textfields it contains. Then the 
> calling macro stores the document and closes it.
> 
> Case Hidden= False in loadComponentFromURL
> If the calling macro stores the new document after several seconds, or 
> after displaying a msgbox, I find the expected number of TextFields 
> written on the new document.
> If the calling macro stores too quickly, nothing is written on the new 
> document (even with no textField something should be written).

The reason for this is that the macro is not executed on creation of the
document but asynchronously after it. So if you call storeToURL()
immediately after returning from loadComponentFromURL() the event still
wasn't fired and your macro wasn't executed.

The reason for the asynchronous firing of the event is that we must
guarantee that the document window and all of its content is already
visible before we fire the event (as usual macros bound to this event
need this). Until now we didn't find a way to do this synchronously.

You have two options:

- bind your event on the "OnCreate" event (not possible via GUI, only
via API - perhaps we should change that)
- let the calling code wait until the event "OnNew" is fired before it
stores the document.

> Case Hidden= True
> nothing is written on the new document.

... because the event "OnNew" is never fired - this is and ever was a
pure UI event as decsribed above. Without a GUI the event isn't fired.
Typically these events in templates trigger dialogs to initialize
content in the document and that's nothing you want to see when you open
a document in "hidden" mode.

> The problem I found is not related to textFields, of course.
> 
> *Remark*
> There is no such problem with OOo 1.1.5. Everything is OK with exactly 
> the same macros.

1.1.5 had a lot of bugs in this area. So it "worked" for you by luck -
but never as it was meant to be.

Ciao,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [EMAIL PROTECTED] is a spam sink.

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

Reply via email to