}
}
selected = null;
mbFinishFindInHeaderFooter = true;
}
OdfElement rootElement = null;
try {
if (mElement != null) {
rootElement = mElement;
} else {
rootElement = mDocument.getContentRoot();
}
} catch (Exception ex) {
Logger.getLogger(TextNavigation.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
}
if (selected == null) {
OdfElement element = (OdfElement) getNextMatchElementInTree(rootElement, rootElement);
if (element != null) {
return createSelection(element, mNextIndex);
} else {
return null;
}
}
OdfElement containerElement = selected.getContainerElement();
int index = selected.getIndex();
String content = TextExtractor.getText(containerElement);
int nextIndex = -1;
Matcher matcher = mPattern.matcher(content);
// start from the end index of the selected item
if (((content.length() > index + selected.getText().length()))
&& (matcher.find(index + selected.getText().length()))) {
// here just consider \n\r\t occupy one char
nextIndex = matcher.start();
int eIndex = matcher.end();
mNextText = content.substring(nextIndex, eIndex);
}
if (nextIndex != -1) {
return createSelection(selected.getContainerElement(), nextIndex);
} else {
OdfElement element = (OdfElement) getNextMatchElementInTree(containerElement, rootElement);
if (element != null) {
return createSelection(element, mNextIndex);
} else {
return null;
}