} catch (RuntimeException e) { /* expected */ }
// XWordCursor
xText.setString("Two words");
xTextCursor.gotoStart(false);
XWordCursor xWordCursor = (XWordCursor)
UnoRuntime.queryInterface(XWordCursor.class, xTextCursor);
bSuccess = xWordCursor.gotoNextWord(true);
assure("gotoNextWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
assure("gotoNextWord(): wrong string: " + string,
"Two ".equals(string));
}
bSuccess = xWordCursor.gotoNextWord(false);
assure("gotoNextWord(): succeeded", !bSuccess);
xTextCursor.collapseToEnd();
bSuccess = xWordCursor.gotoPreviousWord(true);
assure("gotoPreviousWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
assure("gotoPreviousWord(): wrong string: " + string,
"words".equals(string));
}
bSuccess = xWordCursor.gotoPreviousWord(false);
assure("gotoPreviousWord(): succeeded", !bSuccess);
bSuccess = xWordCursor.gotoEndOfWord(true);
assure("gotoEndOfWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
assure("gotoEndOfWord(): wrong string: " + string,
"Two".equals(string));
}
xTextCursor.gotoEnd(false);
bSuccess = xWordCursor.gotoStartOfWord(true);
assure("gotoStartOfWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
assure("gotoStartOfWord(): wrong string: " + string,
"words".equals(string));
}
xText.setString("");
bSuccess = xWordCursor.gotoEndOfWord(false);
assure("gotoEndOfWord(): succeeded", !bSuccess);
bSuccess = xWordCursor.gotoStartOfWord(false);
assure("gotoStartOfWord(): succeeded", !bSuccess);
// XSentenceCursor
xText.setString("This is a sentence. Another sentence.");
xTextCursor.gotoStart(false);