try
{
final XChild modelAsChild = UnoRuntime.queryInterface( XChild.class, i_controlModel );
final XIndexContainer parentForm = UnoRuntime.queryInterface( XIndexContainer.class, modelAsChild.getParent() );
final XEventAttacherManager manager = UnoRuntime.queryInterface( XEventAttacherManager.class, parentForm );
int containerPosition = -1;
for ( int i = 0; i < parentForm.getCount(); ++i )
{
final XPropertySet child = UnoRuntime.queryInterface( XPropertySet.class, parentForm.getByIndex( i ) );
if ( UnoRuntime.areSame( child, i_controlModel ) )
{
containerPosition = i;
break;
}
}
assertFalse( "could not find the given control model within its parent", containerPosition == -1 );
manager.registerScriptEvent( containerPosition, new ScriptEventDescriptor(
i_interfaceName,
i_interfaceMethod,
"",
"Script",
i_scriptURI