Java Code Examples for org.docx4j.wml.RPr#setB()

The following examples show how to use org.docx4j.wml.RPr#setB() . 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_例子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 2
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 3
Source File: Docx4J_简单例子.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 4
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
/**
 * @Description: 加粗
 */
public static void addRPrBoldStyle(RPr runProperties) {
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    b.setVal(true);
    runProperties.setB(b);
}
 
Example 5
Source File: WordprocessingMLPackageRender.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public void addBoldStyle(RPr runProperties) {  
    BooleanDefaultTrue b = new BooleanDefaultTrue();  
    b.setVal(true);  
    runProperties.setB(b);  
}
 
Example 6
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
/**
 * @Description: 加粗
 */
public void addRPrBoldStyle(RPr runProperties) {
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    b.setVal(true);
    runProperties.setB(b);
}
 
Example 7
Source File: Docx4j_创建批注_S3_Test.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public RPr getRPrStyle(ObjectFactory factory, String fontFamily,  
        String colorVal, String fontSize, STHint sTHint, boolean isBlod,  
        boolean isItalic, boolean isStrike, boolean isUnderLine,  
        UnderlineEnumeration underLineStyle, String underLineColor,  
        boolean isHightLight, String hightLightValue, boolean isShd,  
        STShd shdValue, String shdColor, CTVerticalAlignRun stRunEnum) {  
    RPr rPr = factory.createRPr();  
    RFonts rf = new RFonts();  
    if (sTHint != null) {  
        rf.setHint(sTHint);  
    }  
    if (fontFamily != null) {  
        rf.setAscii(fontFamily);  
        rf.setEastAsia(fontFamily);  
        rf.setHAnsi(fontFamily);  
    }  
    rPr.setRFonts(rf);  
    if (colorVal != null) {  
        Color color = new Color();  
        color.setVal(colorVal);  
        rPr.setColor(color);  
    }  
    if (fontSize != null) {  
        HpsMeasure sz = new HpsMeasure();  
        sz.setVal(new BigInteger(fontSize));  
        rPr.setSz(sz);  
        rPr.setSzCs(sz);  
    }  
  
    BooleanDefaultTrue bdt = factory.createBooleanDefaultTrue();  
    if (isBlod) {  
        rPr.setB(bdt);  
    }  
    if (isItalic) {  
        rPr.setI(bdt);  
    }  
    if (isStrike) {  
        rPr.setStrike(bdt);  
    }  
    if (isUnderLine) {  
        U underline = new U();  
        if (underLineStyle != null) {  
            underline.setVal(underLineStyle);  
        }  
        if (underLineColor != null) {  
            underline.setColor(underLineColor);  
        }  
        rPr.setU(underline);  
    }  
    if (isHightLight) {  
        Highlight hight = new Highlight();  
        hight.setVal(hightLightValue);  
        rPr.setHighlight(hight);  
    }  
    if (isShd) {  
        CTShd shd = new CTShd();  
        if (shdColor != null) {  
            shd.setColor(shdColor);  
        }  
        if (shdValue != null) {  
            shd.setVal(shdValue);  
        }  
        rPr.setShd(shd);  
    }  
    if (stRunEnum != null) {  
        rPr.setVertAlign(stRunEnum);  
    }  
    return rPr;  
}
 
Example 8
Source File: TableWithStyledContent.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
/**
 *  本方法给可运行块属性添加粗体属性. BooleanDefaultTrue是设置b属性的Docx4j对象, 严格
 *  来说我们不需要将值设置为true, 因为这是它的默认值.
 */
private static void addBoldStyle(RPr runProperties) {
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    b.setVal(true);
    runProperties.setB(b);
}
 
Example 9
Source File: Docx4j_创建表格_S5_Test.java    From docx4j-template with Apache License 2.0 4 votes vote down vote up
public void addBoldStyle(RPr runProperties) {  
    BooleanDefaultTrue b = new BooleanDefaultTrue();  
    b.setVal(true);  
    runProperties.setB(b);  
}