// The last boundary in this case is same as the offset, so the above gives a wordStart
// equal to the offset, when in most cases what we want is the wordstart to be the "x".
String text = DocumentUtils.getText(doc, rowStart, offsetInRow) + "X";
BreakIterator it = BreakIterator.getWordInstance();
it.setText(text);
int wordStart = it.last();
if (wordStart == BreakIterator.DONE) {
return rowStart;
}
if (wordStart == (offsetInRow + 1)) {
// This is the case we guarded against by added an "X" to the string we're testing.