Search in sources :

Example 6 with Jc

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

the class Docx4J_例子2 method getTextFtr.

public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, boolean isUnderLine, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    Ftr ftr = factory.createFtr();
    P footerP = factory.createP();
    Text text = factory.createText();
    text.setValue(content);
    R run = factory.createR();
    run.getContent().add(text);
    footerP.getContent().add(run);
    PPr pPr = footerP.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    footerP.setPPr(pPr);
    setParagraphSpacing(factory, footerP, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    if (isUnderLine) {
        PBdr pBdr = pPr.getPBdr();
        if (pBdr == null) {
            pBdr = factory.createPPrBasePBdr();
        }
        CTBorder value = new CTBorder();
        value.setVal(STBorder.SINGLE);
        value.setColor("000000");
        value.setSpace(new BigInteger("0"));
        value.setSz(new BigInteger(underLineSz));
        pBdr.setBetween(value);
        pPr.setPBdr(pBdr);
        footerP.setPPr(pPr);
    }
    ftr.getContent().add(footerP);
    if (isUnderLine) {
        ftr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, underLineSz, jcEnumeration));
    }
    return ftr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) Ftr(org.docx4j.wml.Ftr) PBdr(org.docx4j.wml.PPrBase.PBdr) CTBorder(org.docx4j.wml.CTBorder) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) BigInteger(java.math.BigInteger) Text(org.docx4j.wml.Text)

Example 7 with Jc

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

the class Docx4J_例子2 method createHeaderBlankP.

public P createHeaderBlankP(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
    P p = factory.createP();
    R run = factory.createR();
    p.getContent().add(run);
    PPr pPr = p.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    PBdr pBdr = pPr.getPBdr();
    if (pBdr == null) {
        pBdr = factory.createPPrBasePBdr();
    }
    CTBorder value = new CTBorder();
    value.setVal(STBorder.SINGLE);
    value.setColor("000000");
    value.setSpace(new BigInteger("0"));
    value.setSz(new BigInteger(underLineSz));
    pBdr.setBetween(value);
    pPr.setPBdr(pBdr);
    p.setPPr(pPr);
    setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
    return p;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) PBdr(org.docx4j.wml.PPrBase.PBdr) CTBorder(org.docx4j.wml.CTBorder) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) BigInteger(java.math.BigInteger)

Example 8 with Jc

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

the class Docx4J_简单例子 method getTextHdr.

public Hdr getTextHdr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, JcEnumeration jcEnumeration) throws Exception {
    Hdr hdr = factory.createHdr();
    P headP = factory.createP();
    Text text = factory.createText();
    text.setValue(content);
    R run = factory.createR();
    run.getContent().add(text);
    headP.getContent().add(run);
    PPr pPr = headP.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    headP.setPPr(pPr);
    hdr.getContent().add(headP);
    return hdr;
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) PPr(org.docx4j.wml.PPr) Hdr(org.docx4j.wml.Hdr) Jc(org.docx4j.wml.Jc) Text(org.docx4j.wml.Text)

Example 9 with Jc

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

the class Docx4J_简单例子 method setTableAlign.

// 表格水平对齐方式
// TODO 垂直对齐没写
public void setTableAlign(ObjectFactory factory, Tbl table, JcEnumeration jcEnumeration) {
    TblPr tablePr = table.getTblPr();
    if (tablePr == null) {
        tablePr = factory.createTblPr();
    }
    Jc jc = tablePr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    tablePr.setJc(jc);
    table.setTblPr(tablePr);
}
Also used : Jc(org.docx4j.wml.Jc) TblPr(org.docx4j.wml.TblPr)

Example 10 with Jc

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

the class Docx4J_简单例子2 method setParagraphAlign.

// 水平对齐方式
// TODO 垂直对齐没写
public void setParagraphAlign(ObjectFactory factory, P p, JcEnumeration jcEnumeration) {
    PPr pPr = p.getPPr();
    if (pPr == null) {
        pPr = factory.createPPr();
    }
    Jc jc = pPr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    pPr.setJc(jc);
    p.setPPr(pPr);
}
Also used : PPr(org.docx4j.wml.PPr) STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc)

Aggregations

Jc (org.docx4j.wml.Jc)33 PPr (org.docx4j.wml.PPr)29 CTVerticalJc (org.docx4j.wml.CTVerticalJc)23 STVerticalJc (org.docx4j.wml.STVerticalJc)23 R (org.docx4j.wml.R)18 P (org.docx4j.wml.P)16 BigInteger (java.math.BigInteger)11 Text (org.docx4j.wml.Text)10 CTBorder (org.docx4j.wml.CTBorder)8 PBdr (org.docx4j.wml.PPrBase.PBdr)8 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)5 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)5 Drawing (org.docx4j.wml.Drawing)5 TblPr (org.docx4j.wml.TblPr)5 Ftr (org.docx4j.wml.Ftr)4 RPr (org.docx4j.wml.RPr)4 Hdr (org.docx4j.wml.Hdr)3 Ind (org.docx4j.wml.PPrBase.Ind)2 Spacing (org.docx4j.wml.PPrBase.Spacing)2 ParaRPr (org.docx4j.wml.ParaRPr)2