/* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ package integration.forms;
publicclass ListSelection extends integration.forms.TestCase
{ /** Creates a new instance of ListSelection */ public ListSelection()
{ super( DocumentType.CALC );
}
/* ------------------------------------------------------------------ */
@Override public String getTestObjectName()
{ return"Form Control List Selection Test";
}
/* ------------------------------------------------------------------ */ publicvoid checkUserListSelection() throws com.sun.star.uno.Exception, java.lang.Exception
{ int runs = 5; for ( int i = 0; i < runs; ++i )
{
log.println( "Round " + ( i + 1 ) + " of " + runs );
prepareDocument();
impl_clickListBox(); synchronized( this ) { this.wait( 1000 ); }
closeDocument();
}
}
/* ------------------------------------------------------------------ */ finalprivatevoid impl_clickListBox()
{ try
{ finalint runs = 10;
java.util.Random generator = new java.util.Random(); for ( int i = 0; i < runs; ++i )
{ // obtain the active sheet
XSpreadsheetView view = m_document.getCurrentView().query( XSpreadsheetView.class );
XSpreadsheet activeSheet = view.getActiveSheet();
// Accessibility access to the list box control in this sheet
XAccessible accessibleListBox = UnoRuntime.queryInterface(
XAccessible.class, getListBoxControl( activeSheet ) );
XAccessibleContext context = accessibleListBox.getAccessibleContext();
// the first "accessible child" of a list box is its list
XAccessibleSelection accessibleList = UnoRuntime.queryInterface(
XAccessibleSelection.class, context.getAccessibleChild( 1 ) );
// delete all sheets except one
String[] sheetNames = sheets.getElementNames(); for ( short i = 1; i < sheetNames.length; ++i )
sheets.removeByName( sheetNames[ i ] );
// need 5 sheets
String[] newSheetNames = new String[] { "first", "second", "third", "forth", "fifth" };
// give the first one the right name
XNamed sheet = UnoRuntime.queryInterface( XNamed.class,
sheets.getByName( sheetNames[ 0 ] )
);
sheet.setName( newSheetNames[ 0 ] );
// add some dummy buttons for ( int i = 0; i < 4; ++i )
{
XPropertySet buttonModel = m_formLayer.createControlAndShape( "CommandButton", 10, 10 + i * 10, 30, 8 );
impl_assignStarBasicScript( buttonModel, "XActionListener", "actionPerformed", "document:default.callbacks.onButtonClicked" );
}
// and a list box
XPropertySet listBox = m_formLayer.createControlAndShape( "ListBox", 50, 10, 40, 6 );
listBox.setPropertyValue( "Dropdown", Boolean.TRUE );
listBox.setPropertyValue( "StringItemList", newSheetNames );
listBox.setPropertyValue( "Name", "ListBox" );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.