public TestEnvironment createTestEnvironment( TestParameters Param,
PrintWriter log ) throws StatusException {
XInterface oObj = null;
XFrame xFrame = null;
XDispatchRecorder xDR = null;
try {
SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)Param.getMSF());
oDoc = SOF.createTextDoc(null);
try {
Thread.sleep(1000);
}
catch (InterruptedException ex) {
}
XModel model = (XModel) UnoRuntime.queryInterface(XModel.class, oDoc);
xFrame = model.getCurrentController().getFrame();
XPropertySet xFramePS = (XPropertySet) UnoRuntime.queryInterface
(XPropertySet.class, xFrame);
XDispatchRecorderSupplier xDRS = null;
xDRS = (XDispatchRecorderSupplier) AnyConverter.toObject(
new Type(XDispatchRecorderSupplier.class),
xFramePS.getPropertyValue("DispatchRecorderSupplier"));
if (xDRS == null) {
Object oDRS = ((XMultiServiceFactory)Param.getMSF()).createInstance(
"com.sun.star.comp.framework.DispatchRecorderSupplier");
xFramePS.setPropertyValue("DispatchRecorderSupplier", oDRS);
xDRS = (XDispatchRecorderSupplier)
UnoRuntime.queryInterface(XDispatchRecorderSupplier.class,oDRS);
}
xDR = xDRS.getDispatchRecorder();
if (xDR != null) {
oObj = xDR;
} else {
oObj = (XInterface)((XMultiServiceFactory)Param.getMSF()).createInstance(
"com.sun.star.comp.framework.DispatchRecorder");
xDR = (XDispatchRecorder) UnoRuntime.queryInterface
(XDispatchRecorder.class, oObj);
xDRS.setDispatchRecorder(xDR);
}
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create component", e);
}
// fill recorder with content. It's needed for XIndexReplace
URL dispURL = utils.parseURL((XMultiServiceFactory) Param.getMSF(), ".uno:InsertDateField");
PropertyValue prop = new PropertyValue();
prop.Name = "Text";
prop.Value = "XDispatchRecorder.recordDispatch()";
PropertyValue[] dispArgs = new PropertyValue[] {prop};
xDR.recordDispatch(dispURL, dispArgs);
TestEnvironment tEnv = new TestEnvironment( oObj );
// INSTANCEn : _XIndexReplace