UnoRuntime.queryInterface(
XCustomPresentationSupplier.class, xImpressDoc);
XInterface oObj = oPS.getCustomPresentations();
XSingleServiceFactory oSingleMSF = (XSingleServiceFactory)
UnoRuntime.queryInterface(XSingleServiceFactory.class, oObj);
XInterface oInstance = null;
XInterface oSecondInstance = null;
try{
oInstance = (XInterface) oSingleMSF.createInstance();
oSecondInstance = (XInterface) oSingleMSF.createInstance();
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create instance", e);
}
XNameContainer aContainer = (XNameContainer)
UnoRuntime.queryInterface(XNameContainer.class, oObj);
if (aContainer.hasByName("FirstPresentation")) {
try {
aContainer.removeByName("FirstPresentation");
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException("Exception while removing instance", e);
} catch (com.sun.star.container.NoSuchElementException e) {
e.printStackTrace(log);
throw new StatusException("Exception while removing instance", e);
}
}
try {
aContainer.insertByName("FirstPresentation",oInstance);
} catch (com.sun.star.lang.WrappedTargetException e){
e.printStackTrace(log);
throw new StatusException("Could't insert Instance", e);
} catch (com.sun.star.container.ElementExistException e){
e.printStackTrace(log);
throw new StatusException("Could't insert Instance", e);
} catch (com.sun.star.lang.IllegalArgumentException e){
e.printStackTrace(log);
throw new StatusException("Could't insert Instance", e);
}
log.println( "creating a new environment for XPresentation object" );
TestEnvironment tEnv = new TestEnvironment( oObj );
// adding an instance for insertByName ('XNameContainer')
tEnv.addObjRelation("SecondInstance", oSecondInstance);
int THRCNT = 1;
if ((String)Param.get("THRCNT") != null) {
THRCNT = Integer.parseInt((String)Param.get("THRCNT"));
}
// INDEX : _XNameContainer
log.println( "adding XNameContainerINDEX as mod relation to environment" );
tEnv.addObjRelation("XNameContainerINDEX",
(new Integer(THRCNT)).toString());
// INSTANCEn : _XNameContainer; _XNameReplace
log.println( "adding INSTANCEn as mod relation to environment" );
try {
for (int n = 1; n < (2*THRCNT+1) ;n++ ) {
log.println( "adding INSTANCE" + n
+" as mod relation to environment" );
oInstance = (XInterface) oSingleMSF.createInstance();
tEnv.addObjRelation("INSTANCE" + n, oInstance);
}
} catch (com.sun.star.uno.Exception e) {
log.println("Could't adding INSTANCEn: " + e);
}