public static HeaderFooterType forInt(int i) { for (HeaderFooterType type : values()) { if (type.code == i) { return type; } } throw new IllegalArgumentException("Invalid HeaderFooterType code: " + i); } }
/** * Create a footer of the given type * * @param type {@link HeaderFooterType} enum * @return object of type {@link XWPFFooter} */ public XWPFFooter createFooter(HeaderFooterType type) { XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy(); // TODO this needs to be migrated out into section code if (type == HeaderFooterType.FIRST) { CTSectPr ctSectPr = getSection(); if (!ctSectPr.isSetTitlePg()) { CTOnOff titlePg = ctSectPr.addNewTitlePg(); titlePg.setVal(STOnOff.ON); } // } else if (type == HeaderFooterType.EVEN) { // TODO Add support for Even/Odd headings and footers } return hfPolicy.createFooter(STHdrFtr.Enum.forInt(type.toInt())); }
/** * Create a header of the given type * * @param type {@link HeaderFooterType} enum * @return object of type {@link XWPFHeader} */ public XWPFHeader createHeader(HeaderFooterType type) { XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy(); // TODO this needs to be migrated out into section code if (type == HeaderFooterType.FIRST) { CTSectPr ctSectPr = getSection(); if (!ctSectPr.isSetTitlePg()) { CTOnOff titlePg = ctSectPr.addNewTitlePg(); titlePg.setVal(STOnOff.ON); } // } else if (type == HeaderFooterType.EVEN) { // TODO Add support for Even/Odd headings and footers } return hfPolicy.createHeader(STHdrFtr.Enum.forInt(type.toInt())); }
/** * Create a header of the given type * * @param type {@link HeaderFooterType} enum * @return object of type {@link XWPFHeader} */ public XWPFHeader createHeader(HeaderFooterType type) { XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy(); // TODO this needs to be migrated out into section code if (type == HeaderFooterType.FIRST) { CTSectPr ctSectPr = getSection(); if (!ctSectPr.isSetTitlePg()) { CTOnOff titlePg = ctSectPr.addNewTitlePg(); titlePg.setVal(STOnOff.ON); } // } else if (type == HeaderFooterType.EVEN) { // TODO Add support for Even/Odd headings and footers } return hfPolicy.createHeader(STHdrFtr.Enum.forInt(type.toInt())); }
public static HeaderFooterType forInt(int i) { for (HeaderFooterType type : values()) { if (type.code == i) { return type; } } throw new IllegalArgumentException("Invalid HeaderFooterType code: " + i); } }
/** * Create a footer of the given type * * @param type {@link HeaderFooterType} enum * @return object of type {@link XWPFFooter} */ public XWPFFooter createFooter(HeaderFooterType type) { XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy(); // TODO this needs to be migrated out into section code if (type == HeaderFooterType.FIRST) { CTSectPr ctSectPr = getSection(); if (!ctSectPr.isSetTitlePg()) { CTOnOff titlePg = ctSectPr.addNewTitlePg(); titlePg.setVal(STOnOff.ON); } // } else if (type == HeaderFooterType.EVEN) { // TODO Add support for Even/Odd headings and footers } return hfPolicy.createFooter(STHdrFtr.Enum.forInt(type.toInt())); }