doc.getCurrentController() );
docUI.connect();
// display the table
XComponent tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
XFormController tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
tableViewComp );
XPropertySet tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
tableViewController.getCurrentControl().getModel() );
// change the table's formatting
tableControlModel.setPropertyValue( "FontName", "Andale Sans UI" );
tableControlModel.setPropertyValue( "FontHeight", Float.valueOf( 20 ) );
tableControlModel.setPropertyValue( "FontSlant", FontSlant.ITALIC );
// close the table
docUI.closeSubComponents();
// save and close the database document
database.getDatabase().store();
database.close();
// load a copy of the document
// normally, it should be sufficient to load the same doc. However, there might be objects in the Java VM
// which are not yet freed, and which effectively hold the document alive. More precise: The document (|doc|)
// is certainly disposed, but other objects might hold a reference to one of the many other components
// around the database document, the data source, the connection, etc. As long as those objects are
// not cleaned up, the "database model impl" - the structure holding all document data - will
// stay alive, and subsequent requests to load the doc will just reuse it, without really loading it.
docURL = copyToTempFile( docURL );
doc = (XModel)UnoRuntime.queryInterface( XModel.class,
loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );
docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
doc.getCurrentController() );
docUI.connect();
// display the table, again
tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
tableViewComp );
tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
tableViewController.getCurrentControl().getModel() );
// verify the properties
assureEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) );
assureEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue() );
assureEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) );