mbFinishFindInHeaderFooter = false;
}
//the matched text might exist in header/footer
private TextSelection findInHeaderFooter(TextSelection selected) {
OdfFileDom styledom = null;
OdfOfficeMasterStyles masterpage = null;
OdfElement element = null;
if (selected != null) {
OdfElement containerElement = selected.getContainerElement();
int index = selected.getIndex();
OdfWhitespaceProcessor textProcessor = new OdfWhitespaceProcessor();
String content = textProcessor.getText(containerElement);
int nextIndex = -1;
Pattern pattern = Pattern.compile(mPatternText);
Matcher matcher = pattern.matcher(content);
//start from the end index of the selected item
if (matcher.find(index + selected.getText().length())) {
// here just consider \n\r\t occupy one char
nextIndex = matcher.start();
int eIndex = matcher.end();
mCurrentText = content.substring(nextIndex, eIndex);
}
if (nextIndex != -1) {
TextSelection item = new TextSelection(mCurrentText, selected.getContainerElement(), nextIndex);
return item;
}
}
try {
styledom = mTextDocument.getStylesDom();
NodeList list = styledom.getElementsByTagName("office:master-styles");
if (styledom == null) {
return null;
}
if (list.getLength() > 0) {
masterpage = (OdfOfficeMasterStyles) list.item(0);