try {
xMSF = (XMultiServiceFactory)Param.getMSF();
XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(
XNameAccess.class,
xMSF.createInstance("com.sun.star.sdb.DatabaseContext"));
// we use the first datasource
XDataSource xDS = (XDataSource)UnoRuntime.queryInterface(
XDataSource.class, xNameAccess.getByName( "Bibliography" ));
log.println("check XMultiServiceFactory");
XMultiServiceFactory xConn = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class,
xDS.getConnection(new String(),new String()));
log.println("check getAvailableServiceNames");
String[] sServiceNames = xConn.getAvailableServiceNames();
if (! sServiceNames[0].equals("com.sun.star.sdb.SingleSelectQueryComposer"))
{
log.println("Service 'SingleSelectQueryComposer' not supported");
}
oInterface = (XInterface) xConn.createInstance( sServiceNames[0]);
if (oInterface == null) {
log.println("Service wasn't created") ;
throw new StatusException("Service wasn't created",
new NullPointerException()) ;
}
Object oRowSet = xMSF.createInstance("com.sun.star.sdb.RowSet") ;
XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface
(XPropertySet.class, oRowSet) ;
xSetProp.setPropertyValue("DataSourceName", "Bibliography") ;
xSetProp.setPropertyValue("Command", "biblio") ;
xSetProp.setPropertyValue("CommandType",
new Integer(CommandType.TABLE)) ;
com.sun.star.sdbc.XRowSet xORowSet = (com.sun.star.sdbc.XRowSet)
UnoRuntime.queryInterface(com.sun.star.sdbc.XRowSet.class,
oRowSet) ;
xORowSet.execute() ;
XColumnsSupplier xColSup = (XColumnsSupplier)
UnoRuntime.queryInterface(XColumnsSupplier.class, oRowSet);
XNameAccess xCols = xColSup.getColumns();
XPropertySet xCol = (XPropertySet) AnyConverter.toObject(
new Type(XPropertySet.class),
xCols.getByName(xCols.getElementNames()[0]));
XSingleSelectQueryAnalyzer xQueryAna = (XSingleSelectQueryAnalyzer)
UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class,
oInterface);
// XSingleSelectQueryComposer
XSingleSelectQueryComposer xComposer = (XSingleSelectQueryComposer)
UnoRuntime.queryInterface(XSingleSelectQueryComposer.class,
xQueryAna);
xQueryAna.setQuery("SELECT * FROM \"biblio\"");
oObj = (XInterface) oInterface;
log.println("ImplementationName: " + utils.getImplName(oObj));
log.println( " creating a new environment for object" );
TestEnvironment tEnv = new TestEnvironment( oObj );
// for XSingleSelectQueryAnalyzer
tEnv.addObjRelation("xComposer", xComposer);
// for XSingleSelectQueryComposer
tEnv.addObjRelation("xQueryAna", xQueryAna);
tEnv.addObjRelation("xProp", xCol);
tEnv.addObjRelation("colName", xCols.getElementNames()[0]);
envCreatedOK = true ;
return tEnv;
} catch(com.sun.star.uno.Exception e) {