本文整理汇总了Java中org.docx4j.wml.RPr类的典型用法代码示例。如果您正苦于以下问题:Java RPr类的具体用法?Java RPr怎么用?Java RPr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RPr类属于org.docx4j.wml包,在下文中一共展示了RPr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: runProperties
import org.docx4j.wml.RPr; //导入依赖的package包/类
private RPr runProperties(final String fontName, final int fontSize, final boolean bold) {
final RPr rpr = this.wmlObjectFactory.createRPr();
final RFonts font = this.wmlObjectFactory.createRFonts();
font.setAscii(fontName);
font.setHAnsi(fontName);
rpr.setRFonts(font);
final HpsMeasure size = this.wmlObjectFactory.createHpsMeasure();
size.setVal(BigInteger.valueOf(fontSize * 2));
rpr.setSz(size);
final BooleanDefaultTrue isBold = this.wmlObjectFactory.createBooleanDefaultTrue();
isBold.setVal(bold);
rpr.setB(isBold);
return rpr;
}
开发者ID:mizitch,项目名称:story-inspector,代码行数:19,代码来源:DocXReportSummaryWriter.java
示例2: addStyling
import org.docx4j.wml.RPr; //导入依赖的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);
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:32,代码来源:WordprocessingMLPackageRender.java
示例3: setTcHidden
import org.docx4j.wml.RPr; //导入依赖的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);
}
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:22,代码来源:Docx4j_工具类_S3_Test.java
示例4: addRPrBorderStyle
import org.docx4j.wml.RPr; //导入依赖的package包/类
/**
* @Description: 设置字符边框
*/
public void addRPrBorderStyle(RPr runProperties, String size,
STBorder bordType, String space, String color) {
CTBorder value = new CTBorder();
if (StringUtils.isNotBlank(color)) {
value.setColor(color);
}
if (StringUtils.isNotBlank(size)) {
value.setSz(new BigInteger(size));
}
if (StringUtils.isNotBlank(space)) {
value.setSpace(new BigInteger(space));
}
if (bordType != null) {
value.setVal(bordType);
}
runProperties.setBdr(value);
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:21,代码来源:Docx4j_工具类_S3_Test.java
示例5: addRPrStrikeStyle
import org.docx4j.wml.RPr; //导入依赖的package包/类
/**
* @Description: 设置删除线样式
*/
public void addRPrStrikeStyle(RPr runProperties, boolean isStrike,
boolean isDStrike) {
// 删除线
if (isStrike) {
BooleanDefaultTrue strike = new BooleanDefaultTrue();
strike.setVal(true);
runProperties.setStrike(strike);
}
// 双删除线
if (isDStrike) {
BooleanDefaultTrue dStrike = new BooleanDefaultTrue();
dStrike.setVal(true);
runProperties.setDstrike(dStrike);
}
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:19,代码来源:Docx4j_工具类_S3_Test.java
示例6: createCommentRound
import org.docx4j.wml.RPr; //导入依赖的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));
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:21,代码来源:Docx4j_创建批注_S3_Test.java
示例7: createComment
import org.docx4j.wml.RPr; //导入依赖的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;
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:22,代码来源:Docx4j_创建批注_S3_Test.java
示例8: createFooterWithPageNr
import org.docx4j.wml.RPr; //导入依赖的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;
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:25,代码来源:Docx4J_简单例子2.java
示例9: addStyling
import org.docx4j.wml.RPr; //导入依赖的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);
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:32,代码来源:TableWithStyledContent.java
示例10: createFooterWithPageNr
import org.docx4j.wml.RPr; //导入依赖的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;
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:25,代码来源:Docx4J_简单例子.java
示例11: setFont
import org.docx4j.wml.RPr; //导入依赖的package包/类
/**
* Use RunFontSelector to determine the correct font for the list item label.
*
* @param context
* @param foListItemLabelBody
* @param pPr
* @param rPr
* @param text
*/
protected static void setFont(FOConversionContext context, Element foListItemLabelBody, PPr pPr, RPr rPr, String text) {
DocumentFragment result = (DocumentFragment)context.getRunFontSelector().fontSelector(pPr, rPr, text);
log.debug(XmlUtils.w3CDomNodeToString(result));
// eg <fo:inline xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">1)</fo:inline>
// Now get the attribute value
if (result!=null && result.getFirstChild()!=null) {
Attr attr = ((Element)result.getFirstChild()).getAttributeNode("font-family");
if (attr!=null) {
foListItemLabelBody.setAttribute("font-family", attr.getValue());
}
}
}
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:25,代码来源:XsltFOFunctions.java
示例12: extractFormattingData
import org.docx4j.wml.RPr; //导入依赖的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);
}
}
开发者ID:mizitch,项目名称:story-inspector,代码行数:37,代码来源:DocXDocumentExtractor.java
示例13: 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;
}
开发者ID:mizitch,项目名称:story-inspector,代码行数:20,代码来源:DocXReportSummaryWriter.java
示例14: testFormatTextOfBlock
import org.docx4j.wml.RPr; //导入依赖的package包/类
@Test
public void testFormatTextOfBlock() throws Exception {
SdtElement contentControl = createPlainTextContentControl(SdtBlock.class);
RPr rPr = createRunProperties("<w:b/>");
contentControl.getSdtPr().getRPrOrAliasOrLock().add(rPr);
PlainTextContent plainTextContent = new PlainTextContent(contentControl);
plainTextContent.setContent("content");
String xmlString = XmlUtils.marshaltoString(
plainTextContent.getXmlElement(), true);
String content = getSdtContent(xmlString);
String expectedContent = "<w:p>"//
+ "<w:r>" //
+ "<w:rPr><w:b/></w:rPr>" // formatierung
+ "<w:t>content</w:t>" // text
+ "</w:r>"//
+ "</w:p>";
assertEquals(expectedContent, content);
}
开发者ID:wte4j,项目名称:wte4j,代码行数:21,代码来源:PlainTextContentTest.java
示例15: testFormatTextOfRun
import org.docx4j.wml.RPr; //导入依赖的package包/类
@Test
public void testFormatTextOfRun() throws Exception {
SdtElement contentControl = createPlainTextContentControl(SdtRun.class);
RPr rPr = createRunProperties("<w:b/>");
contentControl.getSdtPr().getRPrOrAliasOrLock().add(rPr);
PlainTextContent plainTextContent = new PlainTextContent(contentControl);
plainTextContent.setContent("content");
String xmlString = XmlUtils.marshaltoString(
plainTextContent.getXmlElement(), true);
String content = getSdtContent(xmlString);
String expectedContent = "<w:r>"//
+ "<w:rPr><w:b/></w:rPr>" // formatierung
+ "<w:t>content</w:t>" // text
+ "</w:r>";
assertEquals(expectedContent, content);
}
开发者ID:wte4j,项目名称:wte4j,代码行数:17,代码来源:PlainTextContentTest.java
示例16: 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;
}
开发者ID:trackplus,项目名称:Genji,代码行数:17,代码来源:InlineStyleUtil.java
示例17: setStyleMLA
import org.docx4j.wml.RPr; //导入依赖的package包/类
void setStyleMLA(Style style, boolean justify) {
ObjectFactory factory = Context.getWmlObjectFactory();
PPr paragraphProperties = factory.createPPr();
Jc justification = factory.createJc();
if (justify)
justification.setVal(JcEnumeration.BOTH);
else
justification.setVal(JcEnumeration.CENTER);
paragraphProperties.setJc(justification);
Spacing sp = factory.createPPrBaseSpacing();
sp.setAfter(BigInteger.ZERO);
sp.setBefore(BigInteger.ZERO);
sp.setLine(BigInteger.valueOf(482));
sp.setLineRule(STLineSpacingRule.AUTO);
paragraphProperties.setSpacing(sp);
style.setPPr(paragraphProperties);
RPr rpr = new RPr();
changeFont(rpr, "Times New Roman");
style.setRPr(rpr);
}
开发者ID:anubiann00b,项目名称:TextToDocx,代码行数:27,代码来源:Generator.java
示例18: addHyperlinkCellStyle
import org.docx4j.wml.RPr; //导入依赖的package包/类
private void addHyperlinkCellStyle(Tc tableCell, BandElement be, P hyperlink, Map<String, Object> style) {
setCellMargins(tableCell, style);
setBackground(tableCell, style);
setVerticalAlignment(tableCell, style);
setHorizontalAlignment(hyperlink, style);
setCellBorders(tableCell, style);
R run = (R) ((org.docx4j.wml.P.Hyperlink)hyperlink.getContent().get(0)).getContent().get(0);
RPr runProperties = run.getRPr();
setFont(tableCell, style, runProperties);
if (be != null) {
setTextDirection(tableCell, be.getTextRotation());
}
tableCell.getContent().add(hyperlink);
}
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:17,代码来源:DocxExporter.java
示例19: createPageNumParagraph
import org.docx4j.wml.RPr; //导入依赖的package包/类
private P createPageNumParagraph() {
CTSimpleField pgnum = factory.createCTSimpleField();
pgnum.setInstr(" PAGE \\* MERGEFORMAT ");
RPr RPr = factory.createRPr();
RPr.setNoProof(new BooleanDefaultTrue());
PPr ppr = factory.createPPr();
Jc jc = factory.createJc();
jc.setVal(JcEnumeration.CENTER);
ppr.setJc(jc);
PPrBase.Spacing pprbase = factory.createPPrBaseSpacing();
pprbase.setBefore(BigInteger.valueOf(240));
pprbase.setAfter(BigInteger.valueOf(0));
ppr.setSpacing(pprbase);
R run = factory.createR();
run.getContent().add(RPr);
pgnum.getContent().add(run);
JAXBElement<CTSimpleField> fldSimple = factory.createPFldSimple(pgnum);
P para = createParagraph();
para.getContent().add(fldSimple);
para.setPPr(ppr);
return para;
}
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:25,代码来源:DocxExporter.java
示例20: setDefaultFont
import org.docx4j.wml.RPr; //导入依赖的package包/类
/**
* 为 {@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);
}
开发者ID:vindell,项目名称:docx4j-template,代码行数:14,代码来源:PhysicalFontUtils.java
注:本文中的org.docx4j.wml.RPr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论