use of org.docx4j.wml.Text in project docx4j-template by vindell.
the class Docx4J_简单例子2 method getTextFtr.
public Ftr getTextFtr(WordprocessingMLPackage wordprocessingMLPackage, ObjectFactory factory, Part sourcePart, String content, JcEnumeration jcEnumeration) throws Exception {
Ftr ftr = factory.createFtr();
P footerP = factory.createP();
Text text = factory.createText();
text.setValue(content);
R run = factory.createR();
run.getContent().add(text);
footerP.getContent().add(run);
PPr pPr = footerP.getPPr();
if (pPr == null) {
pPr = factory.createPPr();
}
Jc jc = pPr.getJc();
if (jc == null) {
jc = new Jc();
}
jc.setVal(jcEnumeration);
pPr.setJc(jc);
footerP.setPPr(pPr);
ftr.getContent().add(footerP);
return ftr;
}
use of org.docx4j.wml.Text in project docx4j-template by vindell.
the class Docx4j_Helper method setParagraphContent.
/**
* 设置段落内容
*/
private static 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);
}
use of org.docx4j.wml.Text in project docx4j-template by vindell.
the class Docx4j_创建批注_S3_Test method createCommentEnd.
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));
}
use of org.docx4j.wml.Text in project docx4j-template by vindell.
the class Docx4jStyle_S3 method addCellStyle.
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);
}
}
use of org.docx4j.wml.Text in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setTcContent.
/**
* @Description:设置单元格内容,content为null则清除单元格内容
*/
public void setTcContent(Tc tc, RPr rpr, String content) {
List<Object> pList = tc.getContent();
P p = null;
if (pList != null && pList.size() > 0) {
if (pList.get(0) instanceof P) {
p = (P) pList.get(0);
}
} else {
p = new P();
tc.getContent().add(p);
}
R run = null;
List<Object> rList = p.getContent();
if (rList != null && rList.size() > 0) {
for (int i = 0, len = rList.size(); i < len; i++) {
// 清除内容(所有的r
p.getContent().remove(0);
}
}
run = new R();
p.getContent().add(run);
if (content != null) {
String[] contentArr = content.split("\n");
Text text = new Text();
text.setSpace("preserve");
text.setValue(contentArr[0]);
run.setRPr(rpr);
run.getContent().add(text);
for (int i = 1, len = contentArr.length; i < len; i++) {
Br br = new Br();
// 换行
run.getContent().add(br);
text = new Text();
text.setSpace("preserve");
text.setValue(contentArr[i]);
run.setRPr(rpr);
run.getContent().add(text);
}
}
}
Aggregations