Java Code Examples for org.docx4j.wml.P#getPPr()

The following examples show how to use org.docx4j.wml.P#getPPr() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Docx4J_简单例子.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage,
		ObjectFactory factory, Part sourcePart, String content,
		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);
	ftr.getContent().add(footerP);
	return ftr;
}
 
Example 2
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage,  
        ObjectFactory factory, Part sourcePart, String content,  
        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);  
    ftr.getContent().add(footerP);  
    return ftr;  
}
 
Example 3
Source File: Docx4J_简单例子.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public void setParagraphSpacing(ObjectFactory factory, P p,  
        JcEnumeration jcEnumeration,String before,String after) {  
    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);  
      
    Spacing spacing=new Spacing();  
    spacing.setBefore(new BigInteger(before));  
    spacing.setAfter(new BigInteger(after));  
    spacing.setLineRule(STLineSpacingRule.AUTO);  
    pPr.setSpacing(spacing);  
    p.setPPr(pPr);  
}
 
Example 5
Source File: Docx4j_创建批注_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public void setParagraphAlign(ObjectFactory factory, P p,  
        JcEnumeration jcEnumeration, TextAlignment textAlign) {  
    PPr pPr = p.getPPr();  
    if (pPr == null) {  
        pPr = factory.createPPr();  
    }  
    if (jcEnumeration != null) {  
        Jc jc = pPr.getJc();  
        if (jc == null) {  
            jc = new Jc();  
        }  
        jc.setVal(jcEnumeration);  
        pPr.setJc(jc);  
    }  
    if (textAlign != null) {  
        pPr.setTextAlignment(textAlign);  
    }  
    p.setPPr(pPr);  
}
 
Example 6
Source File: Docx4J_简单例子.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public P newImage(WordprocessingMLPackage wordMLPackage,  
        ObjectFactory factory, Part sourcePart, byte[] bytes,  
        String filenameHint, String altText, int id1, int id2,  
        JcEnumeration jcEnumeration) throws Exception {  
    BinaryPartAbstractImage imagePart = BinaryPartAbstractImage  
            .createImagePart(wordMLPackage, sourcePart, bytes);  
    Inline inline = imagePart.createImageInline(filenameHint, altText, id1,  
            id2, false);  
    P p = factory.createP();  
    R run = factory.createR();  
    p.getContent().add(run);  
    Drawing drawing = factory.createDrawing();  
    run.getContent().add(drawing);  
    drawing.getAnchorOrInline().add(inline);  
    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);  
      
    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("3"));  
    pBdr.setBetween(value);  
    pPr.setPBdr(pBdr);  
    setParagraphSpacing(factory, p, jcEnumeration, "0", "0");  
    return p;  
}
 
Example 8
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public P createImageParagraph(WordprocessingMLPackage wordMLPackage,  
        ObjectFactory factory,P p,String fileName, String content,byte[] bytes,  
        JcEnumeration jcEnumeration) throws Exception {  
    BinaryPartAbstractImage imagePart = BinaryPartAbstractImage  
            .createImagePart(wordMLPackage, bytes);  
    Inline inline = imagePart.createImageInline(fileName, "这是图片", 1,  
            2, false);  
    Text text = factory.createText();  
    text.setValue(content);  
    text.setSpace("preserve");  
    R run = factory.createR();  
    p.getContent().add(run);  
    run.getContent().add(text);  
    Drawing drawing = factory.createDrawing();  
    run.getContent().add(drawing);  
    drawing.getAnchorOrInline().add(inline);  
    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);  
    setParagraphSpacing(factory, p, jcEnumeration, "0", "0");  
    return p;  
}
 
Example 9
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
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);  
}
 
Example 10
Source File: Docx4j_创建批注_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void setParagraphSpacing(ObjectFactory factory, P p,  
        boolean isSpace, String before, String after, boolean isLines,  
        String beforeLines, String afterLines, boolean isLineRule,  
        String lineValue, STLineSpacingRule sTLineSpacingRule) {  
    PPr pPr = p.getPPr();  
    if (pPr == null) {  
        pPr = factory.createPPr();  
    }  
    Spacing spacing = new Spacing();  
    if (isSpace) {  
        if (before != null) {  
            // 段前磅数  
            spacing.setBefore(new BigInteger(before));  
        }  
        if (after != null) {  
            // 段后磅数  
            spacing.setAfter(new BigInteger(after));  
        }  
    }  
    if (isLines) {  
        if (beforeLines != null) {  
            // 段前行数  
            spacing.setBeforeLines(new BigInteger(beforeLines));  
        }  
        if (afterLines != null) {  
            // 段后行数  
            spacing.setAfterLines(new BigInteger(afterLines));  
        }  
    }  
    if (isLineRule) {  
        if (lineValue != null) {  
            spacing.setLine(new BigInteger(lineValue));  
        }  
        spacing.setLineRule(sTLineSpacingRule);  
    }  
    pPr.setSpacing(spacing);  
    p.setPPr(pPr);  
}
 
Example 11
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public P createImageParagraph(WordprocessingMLPackage wordMLPackage,
		ObjectFactory factory, P p, String fileName, String content,
		byte[] bytes, JcEnumeration jcEnumeration) throws Exception {
	BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
			.createImagePart(wordMLPackage, bytes);
	Inline inline = imagePart.createImageInline(fileName, "这是图片", 1, 2,
			false);
	Text text = factory.createText();
	text.setValue(content);
	text.setSpace("preserve");
	R run = factory.createR();
	p.getContent().add(run);
	run.getContent().add(text);
	Drawing drawing = factory.createDrawing();
	run.getContent().add(drawing);
	drawing.getAnchorOrInline().add(inline);
	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);
	setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null,
			null, true, "240", STLineSpacingRule.AUTO);
	return p;
}
 
Example 13
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void setParagraphInd(ObjectFactory factory, P p,
		JcEnumeration jcEnumeration, boolean firstLine,
		String firstLineValue, boolean hangLine, String hangValue) {
	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);

	Ind ind = pPr.getInd();
	if (ind == null) {
		ind = new Ind();
	}
	if (firstLine) {
		if (firstLineValue != null) {
			ind.setFirstLineChars(new BigInteger(firstLineValue));
		}
	}
	if (hangLine) {
		if (hangValue != null) {
			ind.setHangingChars(new BigInteger(hangValue));
		}
	}
	pPr.setInd(ind);
	p.setPPr(pPr);
}
 
Example 14
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public void createHyperlink(WordprocessingMLPackage wordMLPackage,
		MainDocumentPart t, ObjectFactory factory,P paragraph, String url,
		String value, String fontName, String fontSize,JcEnumeration jcEnumeration) throws Exception {
	org.docx4j.relationships.ObjectFactory reFactory = new org.docx4j.relationships.ObjectFactory();
	org.docx4j.relationships.Relationship rel = reFactory
			.createRelationship();
	rel.setType(Namespaces.HYPERLINK);
	rel.setTarget(url);
	rel.setTargetMode("External");
	t.getRelationshipsPart().addRelationship(rel);
	StringBuffer sb = new StringBuffer();
	// addRelationship sets the rel's @Id
	sb.append("<w:hyperlink r:id=\"");
	sb.append(rel.getId());
	sb.append("\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ");
	sb.append("xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" >");
	sb.append("<w:r><w:rPr><w:rStyle w:val=\"Hyperlink\" />");
	sb.append("<w:rFonts  w:ascii=\"");
	sb.append(fontName);
	sb.append("\"  w:hAnsi=\"");
	sb.append(fontName);
	sb.append("\"  w:eastAsia=\"");
	sb.append(fontName);
	sb.append("\" w:hint=\"eastAsia\"/>");
	sb.append("<w:sz w:val=\"");
	sb.append(fontSize);
	sb.append("\"/><w:szCs w:val=\"");
	sb.append(fontSize);
	sb.append("\"/></w:rPr><w:t>");
	sb.append(value);
	sb.append("</w:t></w:r></w:hyperlink>");

	Hyperlink link = (Hyperlink) XmlUtils.unmarshalString(sb.toString());
	paragraph.getContent().add(link);
	setParagraphSpacing(factory, paragraph, jcEnumeration, true, "0",
			"0", null, null, true, "240", STLineSpacingRule.AUTO);
	PPr ppr = paragraph.getPPr();
	if (ppr == null) {
		ppr = factory.createPPr();
	}
	RFonts fonts = new RFonts();
	fonts.setAscii("微软雅黑");
	fonts.setHAnsi("微软雅黑");
	fonts.setEastAsia("微软雅黑");
	fonts.setHint(STHint.EAST_ASIA);
	ParaRPr rpr = new ParaRPr();
	rpr.setRFonts(fonts);
	ppr.setRPr(rpr);
	paragraph.setPPr(ppr);
}
 
Example 15
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public P newImage(WordprocessingMLPackage wordMLPackage,
		ObjectFactory factory, Part sourcePart, byte[] bytes,
		String filenameHint, String altText, int id1, int id2,
		boolean isUnderLine, String underLineSize,
		JcEnumeration jcEnumeration) throws Exception {
	BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
			.createImagePart(wordMLPackage, sourcePart, bytes);
	Inline inline = imagePart.createImageInline(filenameHint, altText, id1,
			id2, false);
	P p = factory.createP();
	R run = factory.createR();
	p.getContent().add(run);
	Drawing drawing = factory.createDrawing();
	run.getContent().add(drawing);
	drawing.getAnchorOrInline().add(inline);
	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);

	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(underLineSize));
		pBdr.setBetween(value);
		pPr.setPBdr(pBdr);
	}
	setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null,
			null, true, "240", STLineSpacingRule.AUTO);
	return p;
}
 
Example 16
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public void addTableCell(ObjectFactory factory,  
        WordprocessingMLPackage wordMLPackage, Tr tableRow, String content,  
        RPr rpr, JcEnumeration jcEnumeration, boolean hasBgColor,  
        String backgroudColor) {  
    Tc tableCell = factory.createTc();  
    P p = factory.createP();  
    setParagraphAlign(factory, p, jcEnumeration);  
    Text t = factory.createText();  
    t.setValue(content);  
    R run = factory.createR();  
    // 设置表格内容字体样式  
    run.setRPr(rpr);  
      
    TcPr tcPr = tableCell.getTcPr();  
    if (tcPr == null) {  
        tcPr = factory.createTcPr();  
    }  
      
    CTVerticalJc valign = factory.createCTVerticalJc();  
    valign.setVal(STVerticalJc.CENTER);  
    tcPr.setVAlign(valign);  
      
    run.getContent().add(t);  
    p.getContent().add(run);  
      
    PPr ppr=p.getPPr();  
    if(ppr==null){  
        ppr=factory.createPPr();  
    }  
    //设置段后距离  
    Spacing spacing=new Spacing();  
    spacing.setAfter(new BigInteger("0"));  
    spacing.setLineRule(STLineSpacingRule.AUTO);  
    ppr.setSpacing(spacing);  
    p.setPPr(ppr);  
      
    tableCell.getContent().add(p);  
    if (hasBgColor) {  
        CTShd shd = tcPr.getShd();  
        if (shd == null) {  
            shd = factory.createCTShd();  
        }  
        shd.setColor("auto");  
        shd.setFill(backgroudColor);  
        tcPr.setShd(shd);  
        tableCell.setTcPr(tcPr);  
    }  
    tableRow.getContent().add(tableCell);  
}
 
Example 17
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 18
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public Hdr getTextHdr(WordprocessingMLPackage wordprocessingMLPackage,
		ObjectFactory factory, Part sourcePart, String content,
		boolean isUnderLine, String underLineSz, 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);

	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);
		headP.setPPr(pPr);
	}
	setParagraphSpacing(factory, headP, jcEnumeration, true, "0", "0",
			null, null, true, "240", STLineSpacingRule.AUTO);
	hdr.getContent().add(headP);
	if (isUnderLine) {
		hdr.getContent().add(
				createHeaderBlankP(wordprocessingMLPackage, factory,
						underLineSz, jcEnumeration));
	}
	return hdr;
}
 
Example 19
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public Ftr createFooterWithPageNr(
		WordprocessingMLPackage wordprocessingMLPackage,
		ObjectFactory factory, boolean isUnderLine, String underLineSz,
		JcEnumeration jcEnumeration) throws Exception {
	Ftr ftr = factory.createFtr();
	P paragraph = factory.createP();
	RPr fontRPr = getRPr(factory, "宋体", "000000", "20", STHint.EAST_ASIA,
			false, false, false, false);
	R run = factory.createR();
	run.setRPr(fontRPr);
	paragraph.getContent().add(run);

	addPageTextField(factory, paragraph, "第");
	addFieldBegin(factory, paragraph);
	addPageNumberField(factory, paragraph);
	addFieldEnd(factory, paragraph);
	addPageTextField(factory, paragraph, "页");

	addPageTextField(factory, paragraph, " 总共");
	addFieldBegin(factory, paragraph);
	addTotalPageNumberField(factory, paragraph);
	addFieldEnd(factory, paragraph);
	addPageTextField(factory, paragraph, "页");
	setParagraphSpacing(factory, paragraph, jcEnumeration, true, "0", "0",
			null, null, true, "240", STLineSpacingRule.AUTO);
	PPr pPr = paragraph.getPPr();
	if (pPr == null) {
		pPr = factory.createPPr();
	}
	Jc jc = pPr.getJc();
	if (jc == null) {
		jc = new Jc();
	}
	jc.setVal(jcEnumeration);
	pPr.setJc(jc);
	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);
		paragraph.setPPr(pPr);
	}
	ftr.getContent().add(paragraph);
	if (isUnderLine) {
		ftr.getContent().add(
				createHeaderBlankP(wordprocessingMLPackage, factory,
						underLineSz, jcEnumeration));
	}
	return ftr;
}
 
Example 20
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
/**
 * @param jcEnumeration
 *            对齐方式
 * @param isSpace
 *            是否设置段前段后值
 * @param before
 *            段前磅数
 * @param after
 *            段后磅数
 * @param beforeLines
 *            段前行数
 * @param afterLines
 *            段后行数
 * @param isLine
 *            是否设置行距
 * @param lineValue
 *            行距值
 * @param sTLineSpacingRule
 *            自动auto 固定exact 最小 atLeast
 */
public void setParagraphSpacing(ObjectFactory factory, P p,
		JcEnumeration jcEnumeration, boolean isSpace, String before,
		String after, String beforeLines, String afterLines,
		boolean isLine, String lineValue,
		STLineSpacingRule sTLineSpacingRule) {
	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);

	Spacing spacing = new Spacing();
	if (isSpace) {
		if (before != null) {
			// 段前磅数
			spacing.setBefore(new BigInteger(before));
		}
		if (after != null) {
			// 段后磅数
			spacing.setAfter(new BigInteger(after));
		}
		if (beforeLines != null) {
			// 段前行数
			spacing.setBeforeLines(new BigInteger(beforeLines));
		}
		if (afterLines != null) {
			// 段后行数
			spacing.setAfterLines(new BigInteger(afterLines));
		}
	}
	if (isLine) {
		if (lineValue != null) {
			spacing.setLine(new BigInteger(lineValue));
		}
		spacing.setLineRule(sTLineSpacingRule);
	}
	pPr.setSpacing(spacing);
	p.setPPr(pPr);
}