Search in sources :

Example 36 with RPr

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

the class PhysicalFontUtils method setDefaultFont.

/**
 * 为 {@link org.docx4j.openpackaging.packages.WordprocessingMLPackage} 配置默认字体
 */
public static void setDefaultFont(WordprocessingMLPackage wmlPackage, String fontName) throws Docx4JException {
    // 设置文件默认字体
    RFonts rfonts = Context.getWmlObjectFactory().createRFonts();
    rfonts.setAsciiTheme(null);
    rfonts.setAscii(fontName);
    rfonts.setHAnsi(fontName);
    rfonts.setEastAsia(fontName);
    RPr rpr = wmlPackage.getMainDocumentPart().getPropertyResolver().getDocumentDefaultRPr();
    rpr.setRFonts(rfonts);
}
Also used : RPr(org.docx4j.wml.RPr) RFonts(org.docx4j.wml.RFonts)

Example 37 with RPr

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

the class SdtFinder_2 method printSdtPrContent.

// 解析样式,区分纯文本和格式文本
public void printSdtPrContent(SdtPr sdtPr) {
    StringBuffer sb = new StringBuffer();
    List<Object> rprList = sdtPr.getRPrOrAliasOrLock();
    boolean flag = false;
    for (Object obj : rprList) {
        if (obj instanceof JAXBElement) {
            String eName = ((JAXBElement) obj).getName().getLocalPart();
            // 布尔类型特殊处理
            if ("temporary".equals(eName)) {
                sb.append(" 替换后是否删除内容控件:").append("是");
            } else if ("text".equals(eName)) {
                // 纯文本是否允许回车特殊处理
                // CTSdtText判断是否回车代码不准确
                // if (this.multiLine == null) {
                // return true;
                // }
                flag = true;
                String textXml = XmlUtils.marshaltoString(obj, true, true);
                if (textXml.indexOf("w:multiLine") != -1) {
                    sb.append(" 是否允许回车:").append("是");
                }
            }
            obj = XmlUtils.unwrap(obj);
            if (obj instanceof Alias) {
                Alias alias = (Alias) obj;
                if (alias != null) {
                    sb.append(" 标题:").append(alias.getVal());
                }
            } else if (obj instanceof CTLock) {
                CTLock lock = (CTLock) obj;
                if (lock != null) {
                    if (lock.getVal().value().toUpperCase().equals("CONTENTLOCKED")) {
                        sb.append(" 锁定方式:").append("无法编辑内容");
                    } else if (lock.getVal().value().toUpperCase().equals("SDTLOCKED")) {
                        sb.append(" 锁定方式:").append("无法删除内容控件");
                    } else if (lock.getVal().value().toUpperCase().equals("SDTCONTENTLOCKED")) {
                        sb.append(" 锁定方式:").append("无法删除内容控件,无法编辑内容");
                    } else {
                        sb.append(" 锁定方式:").append(lock.getVal());
                    }
                }
            } else if (obj instanceof RPr) {
                RPr rpr = (RPr) obj;
                if (rpr != null) {
                    RStyle rprStyle = rpr.getRStyle();
                    if (rprStyle != null) {
                        sb.append(" 样式名称:").append(rprStyle.getVal());
                    }
                }
            }
        } else if (obj instanceof Tag) {
            Tag tag = (Tag) obj;
            if (tag != null) {
                sb.append(" tag标记:").append(tag.getVal());
            }
        } else if (obj instanceof Id) {
            Id id = (Id) obj;
            if (id != null) {
                sb.append(" id:").append(id.getVal());
            }
        }
    }
    if (flag) {
        sb.append(" 内容控件类型:").append("纯文本");
    } else {
        sb.append(" 内容控件类型:").append("格式文本");
    }
    System.out.println(sb.toString());
}
Also used : CTLock(org.docx4j.wml.CTLock) RPr(org.docx4j.wml.RPr) Alias(org.docx4j.wml.SdtPr.Alias) RStyle(org.docx4j.wml.RStyle) JAXBElement(javax.xml.bind.JAXBElement) Tag(org.docx4j.wml.Tag) Id(org.docx4j.wml.Id)

Aggregations

RPr (org.docx4j.wml.RPr)37 P (org.docx4j.wml.P)21 R (org.docx4j.wml.R)19 Text (org.docx4j.wml.Text)12 BooleanDefaultTrue (org.docx4j.wml.BooleanDefaultTrue)9 BigInteger (java.math.BigInteger)8 ParaRPr (org.docx4j.wml.ParaRPr)8 U (org.docx4j.wml.U)7 Color (org.docx4j.wml.Color)6 PPr (org.docx4j.wml.PPr)6 RFonts (org.docx4j.wml.RFonts)6 Tbl (org.docx4j.wml.Tbl)6 Tr (org.docx4j.wml.Tr)6 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)5 HpsMeasure (org.docx4j.wml.HpsMeasure)5 ObjectFactory (org.docx4j.wml.ObjectFactory)5 File (java.io.File)4 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)4 STHint (org.docx4j.wml.STHint)4 Ftr (org.docx4j.wml.Ftr)3