use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr in project poi by apache.
the class XWPFHeaderFooterPolicy method createFooter.
/**
* Creates a new footer of the specified type, to which the
* supplied (and previously unattached!) paragraphs are
* added to.
*/
public XWPFFooter createFooter(Enum type, XWPFParagraph[] pars) {
XWPFFooter footer = getFooter(type);
if (footer == null) {
FtrDocument ftrDoc = FtrDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.FOOTER;
int i = getRelationIndex(relation);
XWPFFooter wrapper = (XWPFFooter) doc.createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
String pStyle = "Footer";
CTHdrFtr ftr = buildFtr(type, pStyle, wrapper, pars);
wrapper.setHeaderFooter(ftr);
ftrDoc.setFtr(ftr);
assignFooter(wrapper, type);
footer = wrapper;
}
return footer;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr in project poi by apache.
the class XWPFHeaderFooterPolicy method buildHdrFtr.
/**
* MB 24 May 2010. Created this overloaded buildHdrFtr() method because testing demonstrated
* that the XWPFFooter or XWPFHeader object returned by calls to the createHeader(int, XWPFParagraph[])
* and createFooter(int, XWPFParagraph[]) methods or the getXXXXXHeader/Footer methods where
* headers or footers had been added to a document since it had been created/opened, returned
* an object that contained no XWPFParagraph objects even if the header/footer itself did contain
* text. The reason was that this line of code; CTHdrFtr ftr = CTHdrFtr.Factory.newInstance();
* created a brand new instance of the CTHDRFtr class which was then populated with data when
* it should have recovered the CTHdrFtr object encapsulated within the XWPFHeaderFooter object
* that had previoulsy been instantiated in the createHeader(int, XWPFParagraph[]) or
* createFooter(int, XWPFParagraph[]) methods.
*/
private CTHdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper) {
CTHdrFtr ftr = wrapper._getHdrFtr();
if (paragraphs != null) {
for (int i = 0; i < paragraphs.length; i++) {
CTP p = ftr.addNewP();
ftr.setPArray(i, paragraphs[i].getCTP());
}
// } else {
// CTP p = ftr.addNewP();
// CTBody body = doc.getDocument().getBody();
// if (body.sizeOfPArray() > 0) {
// CTP p0 = body.getPArray(0);
// if (p0.isSetRsidR()) {
// byte[] rsidr = p0.getRsidR();
// byte[] rsidrdefault = p0.getRsidRDefault();
// p.setRsidP(rsidr);
// p.setRsidRDefault(rsidrdefault);
// }
// }
// CTPPr pPr = p.addNewPPr();
// pPr.addNewPStyle().setVal(pStyle);
}
return ftr;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr in project poi by apache.
the class XWPFHeaderFooterPolicy method createHeader.
/**
* Creates a new header of the specified type, to which the
* supplied (and previously unattached!) paragraphs are
* added to.
*/
public XWPFHeader createHeader(Enum type, XWPFParagraph[] pars) {
XWPFHeader header = getHeader(type);
if (header == null) {
HdrDocument hdrDoc = HdrDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.HEADER;
int i = getRelationIndex(relation);
XWPFHeader wrapper = (XWPFHeader) doc.createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
String pStyle = "Header";
CTHdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);
wrapper.setHeaderFooter(hdr);
hdrDoc.setHdr(hdr);
assignHeader(wrapper, type);
header = wrapper;
}
return header;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr in project poi by apache.
the class XWPFHeaderFooterPolicy method buildHdr.
private CTHdrFtr buildHdr(Enum type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
//CTHdrFtr hdr = buildHdrFtr(pStyle, pars); // MB 24 May 2010
// MB 24 May 2010
CTHdrFtr hdr = buildHdrFtr(pStyle, pars, wrapper);
setHeaderReference(type, wrapper);
return hdr;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr in project poi by apache.
the class XWPFHeaderFooterPolicy method buildFtr.
private CTHdrFtr buildFtr(Enum type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
//CTHdrFtr ftr = buildHdrFtr(pStyle, pars); // MB 24 May 2010
// MB 24 May 2010
CTHdrFtr ftr = buildHdrFtr(pStyle, pars, wrapper);
setFooterReference(type, wrapper);
return ftr;
}
Aggregations