Hi Mathias,
getting back to this after a too long time - sorry.
>> If you have a small self-contained sample document which shows this
>> behaviour, I'd be interested in having a look at it.
>
> You have mail. ;-)
For completeness (and for other readers who, as I originally did,
overlooked important items in your original description :):
- we have a form and a sub form
- the main form is moved to the insert row
- this implicitly causes a reload on the sub form
- when this reload is finished, a certain initialization
should happen
Okay, problems:
- observing the isLoaded at the sub form doesn't help, as the sub form
is always loaded - but it is *re*loaded when the main form has moved
to the insertion row
- There's indeed some asynchronous action involved: The implicit
reloading of the sub form is done asynchronously, with a slight delay.
The reason here is that otherwise, the sub form would be constantly
reloading when you scroll fast through the main form
To overcome this, you need to add a load listener to the sub form (code
below). In its "reloaded" method, you can reset the control as you want.
Ouch, next problem:
- The load listener is invoked *before* the actual reset on the sub form
happens. That is, the main form is moved to the insertion row, this
causes a delayed reload of the sub form, which causes a notification
of the load listeners *followed* by a reset of the sub form, it case
it is also on the insertion row after the reload.
I tend to think the order - first notify load listeners, then reset the
form - is a bug and should be the other way 'round, but this doesn't
help here.
Okay, ney iteration: also add a reset listener to the sub form. In the
"resetted" call directly after the "reloaded" call, reset the sub
control to what you want it to display.
This, finally, works. Complete code, based on the example you sent me,
is below:
REM ***** BASIC *****
Option Explicit
Global oLoadListener as Object
Global oResetListener as Object
Global bNextResetIsAfterReload as Boolean
Global oForm as Object
Global oSubForm as Object
Global oControl as Object
Sub init
oForm = ThisComponent.DrawPage.Forms.getByName( "MainForm" )
oSubForm = oForm.getByName( "SubForm" )
oControl = oSubForm.getByName( "txtGruppe" )
bNextResetIsAfterReload = false
oLoadListener = createUnoListener( "LoadListener_", _
"com.sun.star.form.XLoadListener" )
oSubForm.addLoadListener( oLoadListener )
oResetListener = createUnoListener( "ResetListener_", _
"com.sun.star.form.XResetListener" )
oSubForm.addResetListener( oResetListener )
End Sub
Function ResetListener_approveReset( Event as Object ) As Boolean
ResetListener_approveReset = true
End Function
Sub ResetListener_resetted( Event as Object )
oomr_setControlValue
End Sub
Sub LoadListener_loaded( Event as Object )
bNextResetIsAfterReload = False
End Sub
Sub LoadListener_unloading( Event as Object )
bNextResetIsAfterReload = False
End Sub
Sub LoadListener_unloaded( Event as Object )
bNextResetIsAfterReload = False
End Sub
Sub LoadListener_reloading( Event as Object )
bNextResetIsAfterReload = False
End Sub
Sub LoadListener_reloaded( Event as Object )
bNextResetIsAfterReload = True
End Sub
Sub ooomr_moveWithWait()
ooomr_moveToInsertRow( TRUE )
End Sub
Sub ooomr_moveWithoutWait()
ooomr_moveToInsertRow( FALSE )
End Sub
Sub ooomr_moveToInsertRow( bWait As Boolean )
oForm.moveToInsertRow()
If bWait Then Wait( 3000 )
oomr_setControlValue
End Sub
Sub oomr_setControlValue
oControl.setString( "*** neue Gruppe ***" )
End Sub
Notes:
- You need to implement Subs for all methods of an interface, even if
they do not contain any code. Else, the Basic runtime complains when
it comes to invoking those listener methods.
- The "init" sub needs to be ran once. Since it is currently not
possible to bind events to the "OnLoad" etc. events of an embedded
form, you probably need to do this manually after loading the form
document
- It might also work (didn't try) to add the reset listener to the
control instead of the sub form, and then return false it its
approveReset function. Then, the LoadListener_reloaded sub could
already call oomr_setControlValue
Ciao
Frank
--
- Frank Schönheit, Software Engineer [EMAIL PROTECTED] -
- Sun Microsystems http://www.sun.com/staroffice -
- OpenOffice.org Base http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]