Search in sources :

Example 1 with HeaderReference

use of org.docx4j.wml.HeaderReference in project docx4j-template by vindell.

the class Docx4J_例子2 method createHeaderReference.

public void createHeaderReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
    List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
    // There is always a section wrapper, but it might not contain a sectPr
    if (sectPr == null) {
        sectPr = factory.createSectPr();
        t.addObject(sectPr);
        sections.get(sections.size() - 1).setSectPr(sectPr);
    }
    HeaderReference headerReference = factory.createHeaderReference();
    headerReference.setId(relationship.getId());
    headerReference.setType(HdrFtrRef.DEFAULT);
    sectPr.getEGHdrFtrReferences().add(headerReference);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) HeaderReference(org.docx4j.wml.HeaderReference) SectPr(org.docx4j.wml.SectPr)

Example 2 with HeaderReference

use of org.docx4j.wml.HeaderReference in project docx4j-template by vindell.

the class Docx4J_简单例子 method createHeaderReference.

public void createHeaderReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
    List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
    // There is always a section wrapper, but it might not contain a sectPr
    if (sectPr == null) {
        sectPr = factory.createSectPr();
        t.addObject(sectPr);
        sections.get(sections.size() - 1).setSectPr(sectPr);
    }
    HeaderReference headerReference = factory.createHeaderReference();
    headerReference.setId(relationship.getId());
    headerReference.setType(HdrFtrRef.DEFAULT);
    sectPr.getEGHdrFtrReferences().add(headerReference);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) HeaderReference(org.docx4j.wml.HeaderReference) SectPr(org.docx4j.wml.SectPr)

Example 3 with HeaderReference

use of org.docx4j.wml.HeaderReference in project docx4j-template by vindell.

the class Docx4J_简单例子2 method createHeaderReference.

public void createHeaderReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
    List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
    SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
    // There is always a section wrapper, but it might not contain a sectPr
    if (sectPr == null) {
        sectPr = factory.createSectPr();
        t.addObject(sectPr);
        sections.get(sections.size() - 1).setSectPr(sectPr);
    }
    HeaderReference headerReference = factory.createHeaderReference();
    headerReference.setId(relationship.getId());
    headerReference.setType(HdrFtrRef.DEFAULT);
    sectPr.getEGHdrFtrReferences().add(headerReference);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) HeaderReference(org.docx4j.wml.HeaderReference) SectPr(org.docx4j.wml.SectPr)

Aggregations

SectionWrapper (org.docx4j.model.structure.SectionWrapper)3 HeaderReference (org.docx4j.wml.HeaderReference)3 SectPr (org.docx4j.wml.SectPr)3