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 5eb18f4a83
commit 81dbf1edc9
1 changed files with 8 additions and 26 deletions

View File

@ -784,37 +784,19 @@ public class XSLFTextParagraph implements TextParagraph<XSLFShape,XSLFTextParagr
cur.push(); cur.push();
if ((cur.toChild(nsPML, "txStyles") && cur.toChild(nsPML, defaultStyleSelector)) || if ((cur.toChild(nsPML, "txStyles") && cur.toChild(nsPML, defaultStyleSelector)) ||
(cur.pop() && cur.toChild(nsPML, "notesStyle"))) { (cur.pop() && cur.toChild(nsPML, "notesStyle"))) {
if (cur.toChild(nsDML, "lvl" +(level+1)+ "pPr")) { while (level >= 0) {
return (CTTextParagraphProperties)cur.getObject(); cur.push();
} if (cur.toChild(nsDML, "lvl" +(level+1)+ "pPr")) {
return (CTTextParagraphProperties)cur.getObject();
}
cur.pop();
level--;
}
} }
} finally { } finally {
cur.dispose(); 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; return null;
} }