common-crawl-regression-fix: fallback to higher template level for default font, in case the style reference can't be determined

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1750034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-06-24 00:12:25 +00:00
parent 5fce29e432
commit a3718f8166

View File

@ -784,37 +784,19 @@ public class XSLFTextParagraph implements TextParagraph<XSLFShape,XSLFTextParagr
cur.push();
if ((cur.toChild(nsPML, "txStyles") && cur.toChild(nsPML, defaultStyleSelector)) ||
(cur.pop() && cur.toChild(nsPML, "notesStyle"))) {
if (cur.toChild(nsDML, "lvl" +(level+1)+ "pPr")) {
return (CTTextParagraphProperties)cur.getObject();
}
while (level >= 0) {
cur.push();
if (cur.toChild(nsDML, "lvl" +(level+1)+ "pPr")) {
return (CTTextParagraphProperties)cur.getObject();
}
cur.pop();
level--;
}
}
} finally {
cur.dispose();
}
}
// for (CTTextBody txBody : (CTTextBody[])xo.selectPath(nsDecl+".//p:txBody")) {
// CTTextParagraphProperties defaultPr = null, lastPr = null;
// boolean hasLvl = false;
// for (CTTextParagraph p : txBody.getPArray()) {
// CTTextParagraphProperties pr = p.getPPr();
// if (pr.isSetLvl()) {
// hasLvl |= true;
// lastPr = pr;
// if (pr.getLvl() == level) return pr;
// } else {
// defaultPr = pr;
// }
// }
// if (!hasLvl) continue;
// if (level == 0 && defaultPr != null) return defaultPr;
// if (lastPr != null) return lastPr;
// break;
// }
//
// String err = "Failed to fetch default style for " + defaultStyleSelector + " and level=" + level;
// throw new IllegalArgumentException(err);
return null;
}