本文整理汇总了Java中org.docx4j.wml.RPr.setRStyle方法的典型用法代码示例。如果您正苦于以下问题:Java RPr.setRStyle方法的具体用法?Java RPr.setRStyle怎么用?Java RPr.setRStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.docx4j.wml.RPr
的用法示例。
在下文中一共展示了RPr.setRStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRun
import org.docx4j.wml.RPr; //导入方法依赖的package包/类
private R createRun(final String styleId, final String text) {
final R r = this.wmlObjectFactory.createR();
final RPr rpr = this.wmlObjectFactory.createRPr();
r.setRPr(rpr);
if (styleId != null) {
final RStyle rstyle = this.wmlObjectFactory.createRStyle();
rstyle.setVal(styleId);
rpr.setRStyle(rstyle);
}
final Text textElement = this.wmlObjectFactory.createText();
textElement.setValue(text);
final JAXBElement<Text> wrappedText = this.wmlObjectFactory.createRT(textElement);
r.getContent().add(wrappedText);
return r;
}
示例2: apply
import org.docx4j.wml.RPr; //导入方法依赖的package包/类
@Override
public void apply(R r, Object parent, List<Object> siblings) {
SingleTraversalUtilVisitorCallback runVisitor = new SingleTraversalUtilVisitorCallback(new TraversalUtiltextVisitor());
runVisitor.walkJAXBElements(r);
if (textFound) {
runWithTextFound = true;
ObjectFactory wmlObjectFactory = new ObjectFactory();
RPr rpr = wmlObjectFactory.createRPr();
r.setRPr(rpr);
// Create object for rStyle
RStyle rstyle = wmlObjectFactory.createRStyle();
rpr.setRStyle(rstyle);
rstyle.setVal(inlineStyleId);
}
textFound = false;
}
示例3: setPlaceHolderContent
import org.docx4j.wml.RPr; //导入方法依赖的package包/类
public void setPlaceHolderContent(String text) {
contentControl.getSdtContent().getContent().clear();
Text t = wFactory.createText();
t.setValue(text);
RStyle style = wFactory.createRStyle();
style.setVal("PlaceholderText");
RPr placeHolderProperties = wFactory.createRPr();
placeHolderProperties.setRStyle(style);
R run = wFactory.createR();
run.setRPr(placeHolderProperties);
run.getContent().add(t);
setContent(run);
}
示例4: newHyperlink
import org.docx4j.wml.RPr; //导入方法依赖的package包/类
public org.docx4j.wml.P.Hyperlink newHyperlink(MainDocumentPart mdp, String text, String url) {
try {
// We need to add a relationship to word/_rels/document.xml.rels but since its external, we don't use
// the usual wordMLPackage.getMainDocumentPart().addTargetPart mechanism
org.docx4j.relationships.ObjectFactory factory = new org.docx4j.relationships.ObjectFactory();
org.docx4j.relationships.Relationship rel = factory.createRelationship();
rel.setType(Namespaces.HYPERLINK);
rel.setTarget(url);
rel.setTargetMode("External");
mdp.getRelationshipsPart().addRelationship(rel);
// addRelationship sets the rel's @Id
org.docx4j.wml.P.Hyperlink hyp = new org.docx4j.wml.P.Hyperlink();
hyp.setId(rel.getId());
R run = Context.getWmlObjectFactory().createR();
hyp.getContent().add(run);
RPr rpr = new RPr();
RStyle rStyle = new RStyle();
rStyle.setVal("Hyperlink");
rpr.setRStyle(rStyle);
run.setRPr(rpr);
Text t = new Text();
t.setValue(text);
run.getContent().add(t);
// String hpl = "<w:hyperlink r:id=\"" + rel.getId()
// + "\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" "
// + "xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" >" + "<w:r>" + "<w:rPr>"
// + "<w:rStyle w:val=\"Hyperlink\" />" +
// "</w:rPr>" + "<w:t>" + text + "</w:t>" + "</w:r>" + "</w:hyperlink>";
// return (org.docx4j.wml.P.Hyperlink) XmlUtils.unmarshalString(hpl);
return hyp;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}