defaultStyles.put(defStyle.getFamilyName(), defStyle);
}
NodeList styleList = mTextDocument.getDocumentStyles().getElementsByTagName("style:style");
for (int i = 0; i < styleList.getLength(); i++) {
OdfStyle sStyle = (OdfStyle) styleList.item(i);
//get default properties and style properties
Map<OdfStyleProperty, String> map = sStyle.getStylePropertiesDeep();
//check if properties include all search properties and value equal
Iterator<OdfStyleProperty> pIter = mProps.keySet().iterator();
boolean isStyle = false;
while (pIter.hasNext()) {
isStyle = false;
OdfStyleProperty p = pIter.next();
if (map.containsKey(p)) {
if (map.get(p).equals(mProps.get(p))) {
isStyle = true;
} else {
break;
}
} else {
break;
}
}
//put all match style names
if (isStyle) {
sname = sStyle.getStyleNameAttribute();
//if(sname.contains("default"))sname="defaultstyle";
styleNames.add(sname);
}
}
//get all automatic styles
Iterator<OdfStyle> cStyles = mTextDocument.getContentDom().getAutomaticStyles().getAllStyles().iterator();
while (cStyles.hasNext()) {
OdfStyle cStyle = cStyles.next();
//get default properties and style properties
Map<OdfStyleProperty, String> map = cStyle.getStylePropertiesDeep();
if (cStyle.getParentStyle() == null) {
if (cStyle.getFamilyName().equals("text")) {
if (defaultStyles.containsKey("text")) {
getTextDefaultProperties("text", defaultStyles, map);
} else {
getTextDefaultProperties("paragraph", defaultStyles, map);
}
}
}
//check if the search properties is in properties
Iterator<OdfStyleProperty> pIter = mProps.keySet().iterator();
boolean isStyle = false;
while (pIter.hasNext()) {
isStyle = false;
OdfStyleProperty p = pIter.next();
if (map.containsKey(p)) {
if (map.get(p).equals(mProps.get(p))) {
isStyle = true;
} else {
break;
}
} else {
break;
}
}
//put all match style names
if (isStyle) {
styleNames.add(cStyle.getStyleNameAttribute());
}
}
} catch (Exception e1) {
Logger.getLogger(TextStyleNavigation.class.getName()).log(Level.SEVERE, e1.getMessage(), e1);