* </ul>
*/
protected synchronized TestEnvironment createTestEnvironment
(TestParameters Param, PrintWriter log) {
XAutoTextEntry oEntry = null;
XAutoTextContainer oContainer;
XInterface oObj = null;
int n = 0;
int nCount = 0;
log.println( "creating a test environment" );
try {
XMultiServiceFactory myMSF = (XMultiServiceFactory)Param.getMSF();
Object oInst = myMSF.createInstance
("com.sun.star.text.AutoTextContainer");
oContainer = (XAutoTextContainer)
UnoRuntime.queryInterface(XAutoTextContainer.class,oInst);
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create AutoTextContainer", e);
}
XNameAccess oContNames = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oContainer);
String contNames[] = oContNames.getElementNames();
for (int i =0; i < contNames.length; i++){
log.println("ContainerNames[ "+ i + "]: " + contNames[i]);
}
try{
oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class),oContNames.getByName("mytexts"));
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't get AutoTextGroup", e);
}
oGroup = (XAutoTextGroup) UnoRuntime.queryInterface
(XAutoTextGroup.class, oObj);
String[] oENames = oGroup.getElementNames();
for (int i=0; i<oENames.length; i++) {
log.println("AutoTextEntryNames[" + i + "]: " + oENames[i]);
}
XText oText = xTextDoc.getText();
oText.insertString(oText.getStart(), "New AutoText", true);
XTextRange oTextRange = (XTextRange) oText;
try {
if ( oGroup.hasByName("NewEntryName") ) {
oGroup.removeByName("NewEntryName");
log.println("Element 'NewEntryName' exists, removing...");
}
log.println("Adding new element 'NewEntryName' to group...");
oGroup.insertNewByName("NewEntryName", "NewEntryTitle", oTextRange);
oEntry = (XAutoTextEntry) AnyConverter.toObject(
new Type(XAutoTextEntry.class),oGroup.getByName("NewEntryName"));
} catch ( com.sun.star.container.ElementExistException e ) {
e.printStackTrace(log);
} catch ( com.sun.star.container.NoSuchElementException e ) {
e.printStackTrace(log);
} catch ( com.sun.star.lang.WrappedTargetException e ) {
e.printStackTrace(log);
} catch ( com.sun.star.lang.IllegalArgumentException e ) {
e.printStackTrace(log);
}
oObj = oEntry;
log.println("Trying to use XText as TextRange in the method applyTo");
oEntry.applyTo(oTextRange);
oTextRange = oText.createTextCursor();
log.println("Trying to use XTextCursor as TextRange in the method applyTo");
oEntry.applyTo(oTextRange);
log.println( "creating a new environment for AutoTextEntry object" );
TestEnvironment tEnv = new TestEnvironment( oObj );
// adding relation for XText