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