org.docx4j.wml.RPr Java Examples

The following examples show how to use org.docx4j.wml.RPr. 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: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 隐藏单元格内容
 */
public static void setTcHidden(Tc tc, boolean hidden) {
    List<P> pList = getTcAllP(tc);
    for (P p : pList) {
        PPr ppr = getPPr(p);
        List<Object> objRList = getAllElementFromObject(p, R.class);
        if (objRList == null) {
            continue;
        }
        for (Object objR : objRList) {
            if (objR instanceof R) {
                R r = (R) objR;
                RPr rpr = getRPr(r);
                setRPrVanishStyle(rpr, hidden);
            }
        }
        setParaVanish(ppr, hidden);
    }
}
 
Example #2
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 设置字符边框
 */
public void addRPrBorderStyle(RPr runProperties, String size,
        STBorder bordType, String space, String color) {
    CTBorder value = new CTBorder();
    if (StringUtils.isNotBlank(color)) {
        value.setColor(color);
    }
    if (StringUtils.isNotBlank(size)) {
        value.setSz(new BigInteger(size));
    }
    if (StringUtils.isNotBlank(space)) {
        value.setSpace(new BigInteger(space));
    }
    if (bordType != null) {
        value.setVal(bordType);
    }
    runProperties.setBdr(value);
}
 
Example #3
Source File: Docx4j_创建批注_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public Comments.Comment createComment(ObjectFactory factory,  
        BigInteger commentId, String author, Date date,  
        String commentContent, RPr commentRPr) throws Exception {  
    Comments.Comment comment = factory.createCommentsComment();  
    comment.setId(commentId);  
    if (author != null) {  
        comment.setAuthor(author);  
    }  
    if (date != null) {  
        comment.setDate(toXMLCalendar(date));  
    }  
    P commentP = factory.createP();  
    comment.getEGBlockLevelElts().add(commentP);  
    R commentR = factory.createR();  
    commentP.getContent().add(commentR);  
    Text commentText = factory.createText();  
    commentR.getContent().add(commentText);  
    commentR.setRPr(commentRPr);  
    commentText.setValue(commentContent);  
    return comment;  
}
 
Example #4
Source File: Docx4j_创建批注_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public void createCommentRound(ObjectFactory factory, P p, String pContent,  
        String commentContent, RPr fontRPr, RPr commentRPr,  
        BigInteger commentId, Comments comments) throws Exception {  
    CommentRangeStart startComment = factory.createCommentRangeStart();  
    startComment.setId(commentId);  
    p.getContent().add(startComment);  
    R run = factory.createR();  
    Text txt = factory.createText();  
    txt.setValue(pContent);  
    run.getContent().add(txt);  
    run.setRPr(fontRPr);  
    p.getContent().add(run);  
    CommentRangeEnd endComment = factory.createCommentRangeEnd();  
    endComment.setId(commentId);  
    p.getContent().add(endComment);  
    Comment commentOne = createComment(factory, commentId, "系统管理员",  
            new Date(), commentContent, commentRPr);  
    comments.getComment().add(commentOne);  
    p.getContent().add(createRunCommentReference(factory, commentId));  
}
 
Example #5
Source File: Docx4J_简单例子2.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
public Ftr createFooterWithPageNr(ObjectFactory factory) {  
    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, "页");  
    setParagraphAlign(factory, paragraph, JcEnumeration.CENTER);  
    ftr.getContent().add(paragraph);  
    return ftr;  
}
 
Example #6
Source File: XsltFOFunctions.java    From docx4j-export-FO with Apache License 2.0 6 votes vote down vote up
/**
 * Use RunFontSelector to determine the correct font for the list item label.
 * 
 * @param context
 * @param foListItemLabelBody
 * @param pPr
 * @param rPr
 * @param text
 */
protected static void setFont(RunFontSelector runFontSelector, Element foListItemLabelBody, PPr pPr, RPr rPr, String text) {
	
	DocumentFragment result = (DocumentFragment)runFontSelector.fontSelector(pPr, rPr, text);
	log.debug(XmlUtils.w3CDomNodeToString(result));
	// eg <fo:inline xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">1)</fo:inline>
	
	// Now get the attribute value
	if (result!=null && result.getFirstChild()!=null) {
		Attr attr = ((Element)result.getFirstChild()).getAttributeNode("font-family");
		if (attr!=null) {
			foListItemLabelBody.setAttribute("font-family", attr.getValue());
		}
	}
			
}
 
Example #7
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 设置删除线样式
 */
public void addRPrStrikeStyle(RPr runProperties, boolean isStrike,
        boolean isDStrike) {
    // 删除线
    if (isStrike) {
        BooleanDefaultTrue strike = new BooleanDefaultTrue();
        strike.setVal(true);
        runProperties.setStrike(strike);
    }
    // 双删除线
    if (isDStrike) {
        BooleanDefaultTrue dStrike = new BooleanDefaultTrue();
        dStrike.setVal(true);
        runProperties.setDstrike(dStrike);
    }
}
 
Example #8
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 设置字符边框
 */
public static void addRPrBorderStyle(RPr runProperties, String size, STBorder bordType, String space, String color) {
    CTBorder value = new CTBorder();
    if (StringUtils.isNotBlank(color)) {
        value.setColor(color);
    }
    if (StringUtils.isNotBlank(size)) {
        value.setSz(new BigInteger(size));
    }
    if (StringUtils.isNotBlank(space)) {
        value.setSpace(new BigInteger(space));
    }
    if (bordType != null) {
        value.setVal(bordType);
    }
    runProperties.setBdr(value);
}
 
Example #9
Source File: TableWithStyledContent.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 *  这里我们添加实际的样式信息, 首先创建一个段落, 然后创建以单元格内容作为值的文本对象; 
 *  第三步, 创建一个被称为运行块的对象, 它是一块或多块拥有共同属性的文本的容器, 并将文本对象添加
 *  到其中. 随后我们将运行块R添加到段落内容中.
 *  直到现在我们所做的还没有添加任何样式, 为了达到目标, 我们创建运行块属性对象并给它添加各种样式.
 *  这些运行块的属性随后被添加到运行块. 最后段落被添加到表格的单元格中.
 */
private static void addStyling(Tc tableCell, String content, boolean bold, String fontSize) {
    P paragraph = factory.createP();
 
    Text text = factory.createText();
    text.setValue(content);
 
    R run = factory.createR();
    run.getContent().add(text);
 
    paragraph.getContent().add(run);
 
    RPr runProperties = factory.createRPr();
    if (bold) {
        addBoldStyle(runProperties);
    }
 
    if (fontSize != null && !fontSize.isEmpty()) {
        setFontSize(runProperties, fontSize);
    }
 
    run.setRPr(runProperties);
 
    tableCell.getContent().add(paragraph);
}
 
Example #10
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 隐藏单元格内容
 */
public void setTcHidden(Tc tc, boolean hidden) {
    List<P> pList = getTcAllP(tc);
    for (P p : pList) {
        PPr ppr = getPPr(p);
        List<Object> objRList = getAllElementFromObject(p, R.class);
        if (objRList == null) {
            continue;
        }
        for (Object objR : objRList) {
            if (objR instanceof R) {
                R r = (R) objR;
                RPr rpr = getRPr(r);
                setRPrVanishStyle(rpr, hidden);
            }
        }
        setParaVanish(ppr, hidden);
    }
}
 
Example #11
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 添加图片到段落
 */
public void addImageToPara(WordprocessingMLPackage wordMLPackage,
        ObjectFactory factory, P paragraph, String filePath,
        String content, RPr rpr, String altText, int id1, int id2)
        throws Exception {
    R run = factory.createR();
    if (content != null) {
        Text text = factory.createText();
        text.setValue(content);
        text.setSpace("preserve");
        run.setRPr(rpr);
        run.getContent().add(text);
    }

    InputStream is = new FileInputStream(filePath);
    byte[] bytes = IOUtils.toByteArray(is);
    BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
            .createImagePart(wordMLPackage, bytes);
    Inline inline = imagePart.createImageInline(filePath, altText, id1,
            id2, false);
    Drawing drawing = factory.createDrawing();
    drawing.getAnchorOrInline().add(inline);
    run.getContent().add(drawing);
    paragraph.getContent().add(run);
}
 
Example #12
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 添加图片到段落
 */
public static void addImageToPara(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, P paragraph,
        String filePath, String content, RPr rpr, String altText, int id1, int id2) throws Exception {
    R run = factory.createR();
    if (content != null) {
        Text text = factory.createText();
        text.setValue(content);
        text.setSpace("preserve");
        run.setRPr(rpr);
        run.getContent().add(text);
    }

    InputStream is = new FileInputStream(filePath);
    byte[] bytes = IOUtils.toByteArray(is);
    BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
    Inline inline = imagePart.createImageInline(filePath, altText, id1, id2, false);
    Drawing drawing = factory.createDrawing();
    drawing.getAnchorOrInline().add(inline);
    run.getContent().add(drawing);
    paragraph.getContent().add(run);
}
 
Example #13
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置字体信息
 */
public void setFontStyle(RPr runProperties, String cnFontFamily,
        String enFontFamily, String fontSize, String color) {
    setFontFamily(runProperties, cnFontFamily, enFontFamily);
    setFontSize(runProperties, fontSize);
    setFontColor(runProperties, color);
}
 
Example #14
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置字体大小
 */
public void setFontSize(RPr runProperties, String fontSize) {
    if (StringUtils.isNotBlank(fontSize)) {
        HpsMeasure size = new HpsMeasure();
        size.setVal(new BigInteger(fontSize));
        runProperties.setSz(size);
        runProperties.setSzCs(size);
    }
}
 
Example #15
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 5 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();
	setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null,
			null, true, "240", STLineSpacingRule.AUTO);
	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);
	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 #16
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置字体颜色
 */
public void setFontColor(RPr runProperties, String color) {
    if (color != null) {
        Color c = new Color();
        c.setVal(color);
        runProperties.setColor(c);
    }
}
 
Example #17
Source File: Docx4j_Helper.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/** 
 * 设置段落内容 
 */  
private static void setParagraphContent(P p, RPr rpr,String content) {  
    Text t = Docx4j_Helper.factory.createText();  
    t.setSpace("preserve");  
    t.setValue(content);  
    R run = Docx4j_Helper.factory.createR();  
    run.setRPr(rpr);  
    run.getContent().add(t);  
    p.getContent().add(run);  
}
 
Example #18
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置字体大小
 */
public static void setFontSize(RPr runProperties, String fontSize) {
    if (StringUtils.isNotBlank(fontSize)) {
        HpsMeasure size = new HpsMeasure();
        size.setVal(new BigInteger(fontSize));
        runProperties.setSz(size);
        runProperties.setSzCs(size);
    }
}
 
Example #19
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description:着重号
 */
public void addRPrEmStyle(RPr runProperties, STEm emType) {
    if (emType != null) {
        CTEm em = new CTEm();
        em.setVal(emType);
        runProperties.setEm(em);
    }
}
 
Example #20
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * 创建字体
 * 
 * @param isBlod
 *            粗体
 * @param isUnderLine
 *            下划线
 * @param isItalic
 *            斜体
 * @param isStrike
 *            删除线
 */
public RPr getRPr(ObjectFactory factory, String fontFamily,
		String colorVal, String fontSize, STHint sTHint, boolean isBlod,
		boolean isUnderLine, boolean isItalic, boolean isStrike) {
	RPr rPr = factory.createRPr();
	RFonts rf = new RFonts();
	rf.setHint(sTHint);
	rf.setAscii(fontFamily);
	rf.setHAnsi(fontFamily);
	rPr.setRFonts(rf);

	BooleanDefaultTrue bdt = factory.createBooleanDefaultTrue();
	rPr.setBCs(bdt);
	if (isBlod) {
		rPr.setB(bdt);
	}
	if (isItalic) {
		rPr.setI(bdt);
	}
	if (isStrike) {
		rPr.setStrike(bdt);
	}
	if (isUnderLine) {
		U underline = new U();
		underline.setVal(UnderlineEnumeration.SINGLE);
		rPr.setU(underline);
	}

	Color color = new Color();
	color.setVal(colorVal);
	rPr.setColor(color);

	HpsMeasure sz = new HpsMeasure();
	sz.setVal(new BigInteger(fontSize));
	rPr.setSz(sz);
	rPr.setSzCs(sz);
	return rPr;
}
 
Example #21
Source File: Docx4J_例子2.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void createTableTest(WordprocessingMLPackage wordMLPackage,
		MainDocumentPart t, ObjectFactory factory) throws Exception {
	RPr titleRpr = getRPr(factory, "宋体", "000000", "22", STHint.EAST_ASIA,
			true, false, false, false);
	RPr contentRpr = getRPr(factory, "宋体", "000000", "22",
			STHint.EAST_ASIA, false, false, false, false);
	Tbl table = factory.createTbl();
	addBorders(table, "2");

	double[] colWidthPercent = new double[] { 15, 20, 20, 20, 25 };// 百分比
	setTableGridCol(wordMLPackage, factory, table, 100, colWidthPercent);
	List<String> columnList = new ArrayList<String>();
	columnList.add("序号");
	columnList.add("姓名信息|姓甚|名谁");
	columnList.add("名刺信息|籍贯|营生");
	addTableTitleCell(factory, wordMLPackage, table, columnList, titleRpr,
			JcEnumeration.CENTER, true, "C6D9F1");

	for (int i = 0; i < 10; i++) {
		Tr contentRow = factory.createTr();
		addTableCell(factory, wordMLPackage, contentRow, i + "",
				contentRpr, JcEnumeration.CENTER, false, null);
		addTableCell(factory, wordMLPackage, contentRow, "无名氏", contentRpr,
				JcEnumeration.CENTER, false, null);
		addTableCell(factory, wordMLPackage, contentRow, "佚名", contentRpr,
				JcEnumeration.CENTER, false, null);
		addTableCell(factory, wordMLPackage, contentRow, "武林", contentRpr,
				JcEnumeration.CENTER, false, null);
		addTableCell(factory, wordMLPackage, contentRow, "吟诗赋曲",
				contentRpr, JcEnumeration.CENTER, false, null);
		table.getContent().add(contentRow);
	}
	setTableAlign(factory, table, JcEnumeration.CENTER);
	t.addObject(table);
}
 
Example #22
Source File: PStyle12PtInTableNormalOverrideFalseTest.java    From docx4j-export-FO with Apache License 2.0 5 votes vote down vote up
@Test
public void testTblStyle_P12() throws Exception {
	
	WordprocessingMLPackage wordMLPackage = test(mdpXml_direct_12pt, styles_no_font_sz, 20); // uses implicit DocDefault, but irrelevant
	
	//wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
	
	/* In this case, our result correctly preserves the direct rPr formatting
	 * (so the contents of Normal-TableGrid-BR is irrelevant)
	 * 
        <w:tc>
          <w:p>
            <w:pPr>
              <w:pStyle w:val="Normal-TableGrid-BR"/>
            </w:pPr>
            <w:r>
              <w:rPr>
                <w:sz w:val="24"/>
                <w:szCs w:val="24"/>
              </w:rPr>
              <w:t xml:space="preserve">some latin text here </w:t>
            </w:r>
          </w:p>
        </w:tc>
        */
	
	List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
	RPr rPr = ((RPr)xpathResults.get(0));
	Assert.assertTrue(rPr.getSz().getVal().intValue()==24); 

	
}
 
Example #23
Source File: Docx4j_创建表格_S5_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void addCellStyle(ObjectFactory factory, Tc tableCell,  
        String content, Docx4jStyle_S3 style) {  
    if (style != null) {  
        P paragraph = factory.createP();  
        Text text = factory.createText();  
        text.setValue(content);  
        R run = factory.createR();  
        run.getContent().add(text);  
        paragraph.getContent().add(run);  
        setHorizontalAlignment(paragraph, style.getHorizAlignment());  
        RPr runProperties = factory.createRPr();  
        if (style.isBold()) {  
            addBoldStyle(runProperties);  
        }  
        if (style.isItalic()) {  
            addItalicStyle(runProperties);  
        }  
        if (style.isUnderline()) {  
            addUnderlineStyle(runProperties);  
        }  
        setFontSize(runProperties, style.getFontSize());  
        setFontColor(runProperties, style.getFontColor());  
        setFontFamily(runProperties, style.getCnFontFamily(),style.getEnFontFamily());  
        setCellMargins(tableCell, style.getTop(), style.getRight(),  
                style.getBottom(), style.getLeft());  
        setCellColor(tableCell, style.getBackground());  
        setVerticalAlignment(tableCell, style.getVerticalAlignment());  
        setCellBorders(tableCell, style.isBorderTop(),  
                style.isBorderRight(), style.isBorderBottom(),  
                style.isBorderLeft());  
        run.setRPr(runProperties);  
        tableCell.getContent().add(paragraph);  
    }  
}
 
Example #24
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置隐藏
 */
public void setRPrVanishStyle(RPr runProperties, boolean isVanish) {
    BooleanDefaultTrue vanish = runProperties.getVanish();
    if (vanish != null) {
        vanish.setVal(isVanish);
    } else {
        vanish = new BooleanDefaultTrue();
        vanish.setVal(isVanish);
        runProperties.setVanish(vanish);
    }
}
 
Example #25
Source File: ChangingTheStyleSheet.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
private static RPr getRunPropertiesAndRemoveThemeInfo(Style style) {
    // We only want to change some settings, so we get the existing run
    // properties from the style.
    RPr rpr = style.getRPr();
    removeThemeFontInformation(rpr);
    return rpr;
}
 
Example #26
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置底纹
 */
public void addRPrShdStyle(RPr runProperties, STShd shdtype) {
    if (shdtype != null) {
        CTShd shd = new CTShd();
        shd.setVal(shdtype);
        runProperties.setShd(shd);
    }
}
 
Example #27
Source File: ChangingTheStyleSheet.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 *  For this style, we get the existing run properties from the style and
 *  remove the theme font information from them. Then we also remove the bold
 *  styling, change the font size (half-points) and add an underline.
 */
private static void alterHeading2Style(Style style) {
    RPr rpr = getRunPropertiesAndRemoveThemeInfo(style);
    removeBoldStyle(rpr);
    changeFontSize(rpr, 24);
    addUnderline(rpr);
}
 
Example #28
Source File: PStyle12PtInTableGridOverrideTrueTest.java    From docx4j-export-FO with Apache License 2.0 5 votes vote down vote up
@Test
//@Ignore
public void testTblStyle_P12() throws Exception {
	
	WordprocessingMLPackage wordMLPackage = test(mdpXml_direct_12pt, styles_no_font_sz, 40);
	
	//wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
	
	/* In this case, our result correctly preserves the direct rPr formatting
	 * (so the contents of Normal-TableGrid-BR is irrelevant)
	 * 
        <w:tc>
          <w:p>
            <w:pPr>
              <w:pStyle w:val="Normal-TableGrid-BR"/>
            </w:pPr>
            <w:r>
              <w:rPr>
                <w:sz w:val="24"/>
                <w:szCs w:val="24"/>
              </w:rPr>
              <w:t xml:space="preserve">some latin text here </w:t>
            </w:r>
          </w:p>
        </w:tc>
        */
	
	List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
	RPr rPr = ((RPr)xpathResults.get(0));
	Assert.assertTrue(rPr.getSz().getVal().intValue()==24); 

	
}
 
Example #29
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 添加下划线
 */
public void addRPrUnderlineStyle(RPr runProperties,
        UnderlineEnumeration enumType) {
    U val = new U();
    val.setVal(enumType);
    runProperties.setU(val);
}
 
Example #30
Source File: PStyle12PtInTableNormalOverrideTrueTest.java    From docx4j-export-FO with Apache License 2.0 5 votes vote down vote up
@Test
public void testTblStyle_P12() throws Exception {
	
	WordprocessingMLPackage wordMLPackage = test(mdpXml_direct_12pt, styles_no_font_sz, 20); // uses implicit DocDefault, but irrelevant
	
	//wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
	
	/* In this case, our result correctly preserves the direct rPr formatting
	 * (so the contents of Normal-TableNormal-BR is irrelevant)
	 * 
        <w:tc>
          <w:p>
            <w:pPr>
              <w:pStyle w:val="Normal-TableNormal-BR"/>
            </w:pPr>
            <w:r>
              <w:rPr>
                <w:sz w:val="24"/>
                <w:szCs w:val="24"/>
              </w:rPr>
              <w:t xml:space="preserve">some latin text here </w:t>
            </w:r>
          </w:p>
        </w:tc>
        */
	
	List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
	RPr rPr = ((RPr)xpathResults.get(0));
	Assert.assertTrue(rPr.getSz().getVal().intValue()==EXPECTED_RESULT); 

	
}