// Set up Table style tree
tableTree.setRootElement(new Node<AugmentedStyle>(tableTree, "table-root", null)); // a dummy root node
for (String styleId : stylesInUse ) {
if (tableTree.get(styleId)==null) {
Style style = allStyles.get(styleId);
if (style == null ) {
log.warn("Couldn't find style: " + styleId);
continue;
} else if (style.getType()==null) {
log.warn("missing type: " + XmlUtils.marshaltoString(style));
} else
// Is it a table style?
if (style.getType().equals("table")) {
// Need to create a node for this
this.addNode(styleId, allStyles, tableTree);
}
}
}
// Set up Paragraph style tree
Style rootStyle = allStyles.get("DocDefaults");
if (rootStyle==null) {
pTree.setRootElement(new Node<AugmentedStyle>(pTree, "p-root", null));
} else {
AugmentedStyle as = new AugmentedStyle(rootStyle);
pTree.setRootElement(new Node<AugmentedStyle>(pTree, "DocDefaults", as));
}
for (String styleId : stylesInUse ) {
if (pTree.get(styleId)==null) {
Style style = allStyles.get(styleId);
if (style == null ) {
log.warn("Couldn't find style: " + styleId);
// See BrokenStyleRemediator for some causes of this, and potential fix
continue;
}
// Is it a paragraph style?
if (style.getType()!=null
&& style.getType().equals("paragraph")) {
// Need to create a node for this
log.debug("Adding '" + styleId + "' to paragraph tree" );
this.addNode(styleId, allStyles, pTree);
}
} else {
log.debug(styleId + " is already in paragraph tree");
}
}
// Set up Character style tree
cTree.setRootElement(new Node<AugmentedStyle>(cTree, "c-root", null));
for (String styleId : stylesInUse ) {
if (cTree.get(styleId)==null) {
Style style = allStyles.get(styleId);
if (style == null ) {
log.warn("Couldn't find style: " + styleId);
continue;
}
// Is it a character style?
if (style.getType()!=null
&& style.getType().equals("character")) {
// Need to create a node for this
this.addNode(styleId, allStyles, cTree);
}
} else {
log.debug(styleId + " is already in character tree");