本文整理汇总了Java中org.docx4j.wml.R.setRPr方法的典型用法代码示例。如果您正苦于以下问题:Java R.setRPr方法的具体用法?Java R.setRPr怎么用?Java R.setRPr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.docx4j.wml.R
的用法示例。
在下文中一共展示了R.setRPr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addStyling
import org.docx4j.wml.R; //导入方法依赖的package包/类
/**
* 这里我们添加实际的样式信息, 首先创建一个段落, 然后创建以单元格内容作为值的文本对象;
* 第三步, 创建一个被称为运行块的对象, 它是一块或多块拥有共同属性的文本的容器, 并将文本对象添加
* 到其中. 随后我们将运行块R添加到段落内容中.
* 直到现在我们所做的还没有添加任何样式, 为了达到目标, 我们创建运行块属性对象并给它添加各种样式.
* 这些运行块的属性随后被添加到运行块. 最后段落被添加到表格的单元格中.
*/
public 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);
}
示例2: createCommentRound
import org.docx4j.wml.R; //导入方法依赖的package包/类
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));
}
示例3: createComment
import org.docx4j.wml.R; //导入方法依赖的package包/类
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;
}
示例4: createFooterWithPageNr
import org.docx4j.wml.R; //导入方法依赖的package包/类
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;
}
示例5: addStyling
import org.docx4j.wml.R; //导入方法依赖的package包/类
/**
* 这里我们添加实际的样式信息, 首先创建一个段落, 然后创建以单元格内容作为值的文本对象;
* 第三步, 创建一个被称为运行块的对象, 它是一块或多块拥有共同属性的文本的容器, 并将文本对象添加
* 到其中. 随后我们将运行块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);
}
示例6: createFooterWithPageNr
import org.docx4j.wml.R; //导入方法依赖的package包/类
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;
}
示例7: createRun
import org.docx4j.wml.R; //导入方法依赖的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;
}
示例8: apply
import org.docx4j.wml.R; //导入方法依赖的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;
}
示例9: addImageToPara
import org.docx4j.wml.R; //导入方法依赖的package包/类
/**
* @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);
}
示例10: setParagraphContent
import org.docx4j.wml.R; //导入方法依赖的package包/类
/**
* 设置段落内容
*/
private 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);
}
示例11: addTableCell
import org.docx4j.wml.R; //导入方法依赖的package包/类
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);
}
示例12: createCommentEnd
import org.docx4j.wml.R; //导入方法依赖的package包/类
public void createCommentEnd(ObjectFactory factory, P p, String pContent,
String commentContent, RPr fontRPr, RPr commentRPr,
BigInteger commentId, Comments comments) throws Exception{
Text txt = factory.createText();
txt.setValue(pContent);
R run = factory.createR();
run.getContent().add(txt);
run.setRPr(fontRPr);
p.getContent().add(run);
Comment commentOne = createComment(factory, commentId, "系统管理员",new Date(), commentContent, commentRPr);
comments.getComment().add(commentOne);
p.getContent().add(createRunCommentReference(factory, commentId));
}
示例13: addCellStyle
import org.docx4j.wml.R; //导入方法依赖的package包/类
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);
}
}
示例14: addTableCell
import org.docx4j.wml.R; //导入方法依赖的package包/类
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();
setParagraphAlign(factory, p, jcEnumeration);
Text t = factory.createText();
t.setValue(content);
R run = factory.createR();
// 设置表格内容字体样式
run.setRPr(rpr);
run.getContent().add(t);
p.getContent().add(run);
tableCell.getContent().add(p);
if (hasBgColor) {
TcPr tcPr = tableCell.getTcPr();
if (tcPr == null) {
tcPr = factory.createTcPr();
}
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);
}
示例15: createFillerP
import org.docx4j.wml.R; //导入方法依赖的package包/类
private static P createFillerP() {
org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();
P p = wmlObjectFactory.createP();
// Create object for pPr
PPr ppr = wmlObjectFactory.createPPr();
p.setPPr(ppr);
// Create object for rPr
ParaRPr pararpr = wmlObjectFactory.createParaRPr();
// Create object for spacing
PPrBase.Spacing pprbasespacing = wmlObjectFactory.createPPrBaseSpacing();
ppr.setSpacing(pprbasespacing);
pprbasespacing.setBefore( BigInteger.valueOf( 800) );
pprbasespacing.setAfter( BigInteger.valueOf( 800) );
// Create object for r
R r = wmlObjectFactory.createR();
p.getContent().add( r);
// Create object for rPr
RPr rpr = wmlObjectFactory.createRPr();
r.setRPr(rpr);
// Create object for sz
HpsMeasure hpsmeasure3 = wmlObjectFactory.createHpsMeasure();
rpr.setSz(hpsmeasure3);
hpsmeasure3.setVal( BigInteger.valueOf( 96) );
// Create object for t (wrapped in JAXBElement)
Text text = wmlObjectFactory.createText();
JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
r.getContent().add( textWrapped);
text.setValue( "BODY CONTENT");
return p;
}