final int runs = 10;
java.util.Random generator = new java.util.Random();
for ( int i = 0; i < runs; ++i )
{
// obtain the active sheet
XSpreadsheetView view = (XSpreadsheetView)m_document.getCurrentView().query( XSpreadsheetView.class );
XSpreadsheet activeSheet = view.getActiveSheet();
// Accessibility access to the list box control in this sheet
XAccessible accessibleListBox = (XAccessible)UnoRuntime.queryInterface(
XAccessible.class, getListBoxControl( activeSheet ) );
XAccessibleContext context = accessibleListBox.getAccessibleContext();
// open the popup of the list box (not really necessary, but to better
// simlate user action ...)
/* XAccessibleAction listBoxActions = (XAccessibleAction)UnoRuntime.queryInterface(
XAccessibleAction.class, context );
listBoxActions.doAccessibleAction( 0 );
*/
// the first "accessible child" of a list box is its list
XAccessibleSelection accessibleList = (XAccessibleSelection)UnoRuntime.queryInterface(
XAccessibleSelection.class, context.getAccessibleChild( 1 ) );
int selectPosition = generator.nextInt( 5 );
String selectSheetName = getListBoxControl( activeSheet ).getItem( (short)selectPosition );
accessibleList.selectAccessibleChild( selectPosition );
try
{
synchronized( this )
{
this.wait( 500 );
}
}
catch( java.lang.InterruptedException e ) { }
XNamed sheetName = (XNamed)UnoRuntime.queryInterface( XNamed.class, view.getActiveSheet() );
assure( "sheet was not selected as expected!", sheetName.getName().equals( selectSheetName ) );
}
}
catch( com.sun.star.uno.Exception e )
{