Java Code Examples for org.docx4j.wml.PPr#getJc()

The following examples show how to use org.docx4j.wml.PPr#getJc() . 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_简单例子.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 3
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 4
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 5
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 6
Source File: Docx4J_简单例子.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);
	return p;
}
 
Example 7
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 8
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,  
        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("3"));  
    pBdr.setBetween(value);  
    pPr.setPBdr(pBdr);  
    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 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 10
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 11
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 5 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);  
      
    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);  
    headP.setPPr(pPr);  
    setParagraphSpacing(factory, headP, jcEnumeration, "0", "0");  
    hdr.getContent().add(headP);  
    hdr.getContent().add(createHeaderBlankP(wordprocessingMLPackage, factory, jcEnumeration));  
    return hdr;  
}
 
Example 12
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 13
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 14
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 15
Source File: XsltFOFunctions.java    From docx4j-export-FO with Apache License 2.0 4 votes vote down vote up
private static void createFoAttributes(OpcPackage opcPackage, PPr pPr, Element foBlockElement, boolean inList, boolean ignoreBorders){
		
    	List<Property> properties = PropertyFactory.createProperties(opcPackage, pPr);
    	
    	for( Property p :  properties ) {
			if (p!=null) {
				
				if (ignoreBorders &&
						((p instanceof PBorderTop)
								|| (p instanceof PBorderBottom))) {
					continue;
				}
								
				if (inList && !(p instanceof Indent) ) { 
					// Don't set start-indent in 
					// fo:list-item-body/fo:block.
					// This has to be handled above using something like 
					//  <fo:list-block provisional-distance-between-starts="0.5in" start-indent="2in">
					p.setXslFO(foBlockElement);
				} else if (!inList) {
					p.setXslFO(foBlockElement);
				}
			}
    	}
    	
    	if (pPr==null) return;
		
    	// Special case, since bidi is translated to align right
    	// Handle interaction between w:pPr/w:bidi and w:pPr/w:jc/@w:val='right'
    	if (pPr.getBidi()!=null && pPr.getBidi().isVal()) {
    		
    		if (pPr.getJc()!=null) {
    			if (pPr.getJc().getVal().equals(JcEnumeration.RIGHT)) {
    				// set it to left!
    				foBlockElement.setAttribute(Justification.FO_NAME,  "left");
    			} else if (pPr.getJc().getVal().equals(JcEnumeration.LEFT)) {
    				// set it to right!
    				foBlockElement.setAttribute(Justification.FO_NAME,  "right");
    			}
    		}
    	}
    	
    	// Table of contents dot leader needs text-align-last="justify"
    	// Are we in a TOC?
    	if (pPr.getTabs()!=null
    			
    			// PStyle is not included in our effective pPr!
//    			&& pPr.getPStyle()!=null 
//    			&& pPr.getPStyle().getVal()!=null
//    			&& pPr.getPStyle().getVal().startsWith("TOC")  
    			) {
    		
    		CTTabStop tabStop = pPr.getTabs().getTab().get(0);
    		if (tabStop!=null
    				//&& tabStop.getLeader().equals(STTabTlc.DOT)
    				&& tabStop.getVal().equals(STTabJc.RIGHT) ) {
    			
    			foBlockElement.setAttribute("text-align-last",  "justify");
    		}
    	}
    	
	}
 
Example 16
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 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: FOExporterVisitorGenerator.java    From docx4j-export-FO with Apache License 2.0 4 votes vote down vote up
protected void createFoAttributes(FOConversionContext conversionContext, PPr pPr, Element foBlockElement, boolean inList, boolean ignoreBorders){
		
    	List<Property> properties = PropertyFactory.createProperties(conversionContext.getWmlPackage(), pPr);
    	
    	for( Property p :  properties ) {
			if (p!=null) {
				
				if (ignoreBorders &&
						((p instanceof PBorderTop)
								|| (p instanceof PBorderBottom))) {
					continue;
				}
								
				if (inList && !(p instanceof Indent) ) { 
					// Don't set start-indent in 
					// fo:list-item-body/fo:block.
					// This has to be handled above using something like 
					//  <fo:list-block provisional-distance-between-starts="0.5in" start-indent="2in">
					p.setXslFO(foBlockElement);
				} else if (!inList) {
					p.setXslFO(foBlockElement);
				}
			}
    	}
    	
    	if (pPr==null) return;
		
    	// Special case, since bidi is translated to align right
    	// Handle interaction between w:pPr/w:bidi and w:pPr/w:jc/@w:val='right'
    	if (pPr.getBidi()!=null && pPr.getBidi().isVal()) {
    		
    		if (pPr.getJc()!=null) {
    			if (pPr.getJc().getVal().equals(JcEnumeration.RIGHT)) {
    				// set it to left!
    				foBlockElement.setAttribute(Justification.FO_NAME,  "left");
    			} else if (pPr.getJc().getVal().equals(JcEnumeration.LEFT)) {
    				// set it to right!
    				foBlockElement.setAttribute(Justification.FO_NAME,  "right");
    			}
    		}
    	}   
    	
    	// Table of contents dot leader needs text-align-last="justify"
    	// Are we in a TOC?
    	if (pPr.getTabs()!=null
    			
    			// PStyle is not included in our effective pPr!
//    			&& pPr.getPStyle()!=null 
//    			&& pPr.getPStyle().getVal()!=null
//    			&& pPr.getPStyle().getVal().startsWith("TOC")  
    			) {
    		
    		CTTabStop tabStop = pPr.getTabs().getTab().get(0);
    		if (tabStop!=null
    				//&& tabStop.getLeader().equals(STTabTlc.DOT)
    				&& tabStop.getVal().equals(STTabJc.RIGHT) ) {
    			
    			foBlockElement.setAttribute("text-align-last",  "justify");
    		}
    	}
    	
    	
	}
 
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);
}