}
return null;
}
+
+ /**
+ * Indicates whether this paragraph should be kept on the same page as the next one.
+ *
+ * @since POI 4.1.1
+ */
+ public boolean isKeepNext() {
+ if (getCTP() != null && getCTP().getPPr() != null && getCTP().getPPr().isSetKeepNext()) {
+ return getCTP().getPPr().getKeepNext().getVal() == STOnOff.ON;
+ }
+ return false;
+ }
+
+ /**
+ * Sets this paragraph to be kept on the same page as the next one or not.
+ *
+ * @since POI 4.1.1
+ */
+ public void setKeepNext(boolean keepNext) {
+ CTOnOff state = CTOnOff.Factory.newInstance();
+ state.setVal(keepNext ? STOnOff.ON : STOnOff.OFF);
+ getCTP().getPPr().setKeepNext(state);
+ }
/**
* Returns the text of the paragraph, but not of any objects in the
p.setPageBreak(false);
assertFalse(p.isPageBreak());
+ assertFalse(p.isKeepNext());
+ p.setKeepNext(true);
+ assertTrue(p.isKeepNext());
+ p.setKeepNext(false);
+ assertFalse(p.isKeepNext());
+
assertEquals(-1, p.getSpacingAfter());
p.setSpacingAfter(12);
assertEquals(12, p.getSpacingAfter());