// get the bodytext of textdocument here
log.println("getting the TextCursor");
final XSimpleText aText = xTextDoc.getText();
final XTextCursor textCursor = aText.createTextCursor();
oObj = textCursor;
log.println("inserting some text");
try {
for (int i = 0; i < 3; i++) {
aText.insertString(textCursor, "" + (3 - i), false);
for (int j = 0; j < 5; j++) {
aText.insertString(textCursor, "XTextCursor,XTextCursor",
false);
aText.insertString(textCursor, "The quick brown fox ",
false);
aText.insertString(textCursor, "jumps over the lazy dog ",
false);
}
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertControlCharacter(textCursor,
ControlCharacter.LINE_BREAK,
false);
}
} catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("Error, insert text to text document.");
e.printStackTrace(log);
}
log.println("creating a new environment for SwXTextCursor object");
TestEnvironment tEnv = new TestEnvironment(oObj);
tEnv.addObjRelation("XTEXT", xTextDoc.getText());
XPropertySet xCursorProp = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, oObj);
tEnv.addObjRelation("PropertyNames", getPropertyNames(xCursorProp));
//Adding relation for util.XSortable
final XParagraphCursor paragrCursor = (XParagraphCursor) UnoRuntime.queryInterface(
XParagraphCursor.class,
oObj);
final PrintWriter finalLog = log;
tEnv.addObjRelation("SORTCHECKER",
new ifc.util._XSortable.XSortChecker() {
PrintWriter out = finalLog;
public void setPrintWriter(PrintWriter log) {
out = log;
}
public void prepareToSort() {
textCursor.gotoEnd(false);
try {
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertString(textCursor, "4", false);
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertString(textCursor, "b", false);
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertString(textCursor, "3", false);
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertString(textCursor, "a", false);
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertString(textCursor, "23", false);
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
aText.insertString(textCursor, "ab", false);
aText.insertControlCharacter(textCursor,
ControlCharacter.PARAGRAPH_BREAK,
false);
} catch (com.sun.star.lang.IllegalArgumentException e) {
out.println("Unexpected exception:" + e);
}