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);
}
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());
}
Aggregations