github-53: fix NPE when iterating over paragraphs in certain *.docx files. Thanks to Praful Kumar Vaishnav! This closes #53.
https://github.com/apache/poi/pull/53 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1795254 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5c62492ffb
commit
fac98b5bef
@ -817,15 +817,31 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
|
|||||||
* @return boolean - if page break is set
|
* @return boolean - if page break is set
|
||||||
*/
|
*/
|
||||||
public boolean isPageBreak() {
|
public boolean isPageBreak() {
|
||||||
CTPPr ppr = getCTPPr();
|
final CTPPr ppr = getCTPPr();
|
||||||
CTOnOff ctPageBreak = ppr.isSetPageBreakBefore() ? ppr
|
final CTOnOff ctPageBreak = ppr.isSetPageBreakBefore() ? ppr.getPageBreakBefore() : null;
|
||||||
.getPageBreakBefore() : null;
|
if (ctPageBreak == null) {
|
||||||
if (ctPageBreak != null
|
|
||||||
&& ctPageBreak.getVal().intValue() == STOnOff.INT_TRUE) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return isTruelike(ctPageBreak.getVal(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isTruelike(final STOnOff.Enum value, boolean defaultValue) {
|
||||||
|
if (value == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
switch (value.intValue()) {
|
||||||
|
case STOnOff.INT_TRUE:
|
||||||
|
case STOnOff.INT_X_1:
|
||||||
|
case STOnOff.INT_ON:
|
||||||
|
return true;
|
||||||
|
case STOnOff.INT_FALSE:
|
||||||
|
case STOnOff.INT_X_0:
|
||||||
|
case STOnOff.INT_OFF:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies that when rendering this document in a paginated
|
* Specifies that when rendering this document in a paginated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user