本文整理汇总了Java中org.docx4j.wml.R类的典型用法代码示例。如果您正苦于以下问题:Java R类的具体用法?Java R怎么用?Java R使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
R类属于org.docx4j.wml包,在下文中一共展示了R类的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: writeImage
import org.docx4j.wml.R; //导入依赖的package包/类
@Override
public void writeImage(final BufferedImage image) {
final P imageParagraph = this.wmlObjectFactory.createP();
final R imageRun = this.wmlObjectFactory.createR();
imageParagraph.getContent().add(imageRun);
final Drawing drawing = this.wmlObjectFactory.createDrawing();
imageRun.getContent().add(drawing);
try {
final ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
ImageIO.write(image, "PNG", byteOutputStream);
final BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(this.extractedDocument.getDocumentPackage(),
byteOutputStream.toByteArray());
final Inline imageInline = imagePart.createImageInline("Filename", "An image", nextUniqueImageId(), nextUniqueImageId(), false);
drawing.getAnchorOrInline().add(imageInline);
} catch (final Exception e) {
throw new RuntimeException(e);
}
addParagraph(imageParagraph);
}
示例3: setTcHidden
import org.docx4j.wml.R; //导入依赖的package包/类
/**
* @Description: 隐藏单元格内容
*/
public void setTcHidden(Tc tc, boolean hidden) {
List<P> pList = getTcAllP(tc);
for (P p : pList) {
PPr ppr = getPPr(p);
List<Object> objRList = getAllElementFromObject(p, R.class);
if (objRList == null) {
continue;
}
for (Object objR : objRList) {
if (objR instanceof R) {
R r = (R) objR;
RPr rpr = getRPr(r);
setRPrVanishStyle(rpr, hidden);
}
}
setParaVanish(ppr, hidden);
}
}
示例4: setNewTcContent
import org.docx4j.wml.R; //导入依赖的package包/类
/**
* 设置单元格内容
*
* @param tc
* @param content
*/
public static void setNewTcContent(Tc tc, String content) {
P p = factory.createP();
tc.getContent().add(p);
R run = factory.createR();
p.getContent().add(run);
if (content != null) {
String[] contentArr = content.split("\n");
Text text = factory.createText();
text.setSpace("preserve");
text.setValue(contentArr[0]);
run.getContent().add(text);
for (int i = 1, len = contentArr.length; i < len; i++) {
Br br = factory.createBr();
run.getContent().add(br);// 换行
text = factory.createText();
text.setSpace("preserve");
text.setValue(contentArr[i]);
run.getContent().add(text);
}
}
}
示例5: 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));
}
示例6: 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;
}
示例7: 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;
}
示例8: 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);
}
示例9: newImage
import org.docx4j.wml.R; //导入依赖的package包/类
public P newImage(WordprocessingMLPackage wordMLPackage,
ObjectFactory factory, byte[] bytes, String filenameHint,
String altText, int id1, int id2, long cx) throws Exception {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
.createImagePart(wordMLPackage, bytes);
Inline inline = imagePart.createImageInline(filenameHint, altText, id1,
id2, cx, false);
// Now add the inline in w:p/w:r/w:drawing
P p = factory.createP();
R run = factory.createR();
p.getContent().add(run);
Drawing drawing = factory.createDrawing();
run.getContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
return p;
}
示例10: 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;
}
示例11: getFormattedTextForLineElement
import org.docx4j.wml.R; //导入依赖的package包/类
private static void getFormattedTextForLineElement(List<WordType> lines, P p, MainDocumentPart mdp) throws Exception{
int wordCount = 0;
int nrWords = lines.size();
for (WordType word : lines){
getFormattedTextForShapeElement((ITrpShapeType) word, p, mdp);
//add empty space after each word
if (wordCount < nrWords-1){
org.docx4j.wml.Text t = factory.createText();
t.setValue(" ");
t.setSpace("preserve");
org.docx4j.wml.R run = factory.createR();
p.getContent().add(run);
run.getContent().add(t);
}
wordCount++;
}
}
示例12: createComment
import org.docx4j.wml.R; //导入依赖的package包/类
private static org.docx4j.wml.Comments.Comment createComment(java.math.BigInteger commentId,
String author, Calendar date, String message) {
org.docx4j.wml.Comments.Comment comment = factory.createCommentsComment();
comment.setId( commentId );
if (author!=null) {
comment.setAuthor(author);
}
if (date!=null) {
// String dateString = RFC3339_FORMAT.format(date.getTime()) ;
// comment.setDate(value)
// TODO - at present this is XMLGregorianCalendar
}
org.docx4j.wml.P commentP = factory.createP();
comment.getEGBlockLevelElts().add(commentP);
org.docx4j.wml.R commentR = factory.createR();
commentP.getContent().add(commentR);
org.docx4j.wml.Text commentText = factory.createText();
commentR.getContent().add(commentText);
commentText.setValue(message);
return comment;
}
示例13: createPageBreak
import org.docx4j.wml.R; //导入依赖的package包/类
public static P createPageBreak() {
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
// Create object for p
P p = wmlObjectFactory.createP();
// Create object for r
R r = wmlObjectFactory.createR();
p.getContent().add(r);
// Create object for br
Br br = wmlObjectFactory.createBr();
r.getContent().add(br);
br.setType(org.docx4j.wml.STBrType.PAGE);
return p;
}
示例14: extractTextFromParagraph
import org.docx4j.wml.R; //导入依赖的package包/类
/**
* Extract text from the paragraph and append it to the provided {@link StringBuilder}.
*
* @param stringBuilder
* The {@link StringBuilder} to append text to.
* @param formattingData
* Formatting data map to update with ranges of paragraph that are formatted.
* @param paragraph
* The docx4j paragraph object
* @param paragraphProperties
* The docx4j paragraph properties
* @param styleMap
* The extracted styles from the main document
* @param mainDoc
* The main document object
*/
private void extractTextFromParagraph(final StringBuilder stringBuilder, final Map<FormattingType, Set<TextRange>> formattingData,
final P paragraph, final PPr paragraphProperties, final Map<String, Style> styleMap, final MainDocumentPart mainDoc) {
for (final Object paragraphChild : paragraph.getContent()) {
if (paragraphChild instanceof R) {
final R run = (R) paragraphChild;
for (final Object runChild : run.getContent()) {
if (runChild instanceof JAXBElement && ((JAXBElement<?>) runChild).getDeclaredType() == Text.class) {
final String childText = ((Text) ((JAXBElement<?>) runChild).getValue()).getValue();
final TextRange childRange = new TextRange(stringBuilder.length(), stringBuilder.length() + childText.length());
stringBuilder.append(childText);
extractFormattingData(run, childRange, formattingData, paragraphProperties, styleMap, mainDoc);
}
}
}
}
}
示例15: extractFormattingData
import org.docx4j.wml.R; //导入依赖的package包/类
/**
* Updates the provided formatting data map based on the provided data about the text run.
*
* @param run
* The provided text run
* @param childRange
* The text range this run covers
* @param formattingData
* The formatting data map to update
* @param paragraphProperties
* The docx4j paragraph properties object
* @param styleMap
* The extracted styles of the main document.
* @param mainDoc
* The main document object
*/
private void extractFormattingData(final R run, final TextRange childRange, final Map<FormattingType, Set<TextRange>> formattingData,
final PPr paragraphProperties, final Map<String, Style> styleMap, final MainDocumentPart mainDoc) {
final RPr runProperties = run.getRPr();
final BooleanDefaultTrue isBold = getRunProperty(runProperties, paragraphProperties, RPr::getB, styleMap, mainDoc);
final BooleanDefaultTrue isItalics = getRunProperty(runProperties, paragraphProperties, RPr::getI, styleMap, mainDoc);
final U underlining = getRunProperty(runProperties, paragraphProperties, RPr::getU, styleMap, mainDoc);
if (isBold != null && isBold.isVal()) {
formattingData.get(FormattingType.BOLD).add(childRange);
}
if (isItalics != null && isItalics.isVal()) {
formattingData.get(FormattingType.ITALICS).add(childRange);
}
if (underlining != null && underlining.getVal() != UnderlineEnumeration.NONE) {
formattingData.get(FormattingType.UNDERLINE).add(childRange);
}
}