use of org.docx4j.wml.PPr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setParagraphSpacing.
/**
* @param isSpace
* 是否设置段前段后值
* @param before
* 段前磅数
* @param after
* 段后磅数
* @param beforeLines
* 段前行数
* @param afterLines
* 段后行数
* @param isLine
* 是否设置行距
* @param lineValue
* 行距值
* @param sTLineSpacingRule
* 自动auto 固定exact 最小 atLeast 1磅=20 1行=100 单倍行距=240
*/
public void setParagraphSpacing(P p, boolean isSpace, String before, String after, String beforeLines, String afterLines, boolean isLine, String lineValue, STLineSpacingRule sTLineSpacingRule) {
PPr pPr = getPPr(p);
Spacing spacing = pPr.getSpacing();
if (spacing == null) {
spacing = new Spacing();
pPr.setSpacing(spacing);
}
if (isSpace) {
if (StringUtils.isNotBlank(before)) {
// 段前磅数
spacing.setBefore(new BigInteger(before));
}
if (StringUtils.isNotBlank(after)) {
// 段后磅数
spacing.setAfter(new BigInteger(after));
}
if (StringUtils.isNotBlank(beforeLines)) {
// 段前行数
spacing.setBeforeLines(new BigInteger(beforeLines));
}
if (StringUtils.isNotBlank(afterLines)) {
// 段后行数
spacing.setAfterLines(new BigInteger(afterLines));
}
}
if (isLine) {
if (StringUtils.isNotBlank(lineValue)) {
spacing.setLine(new BigInteger(lineValue));
}
if (sTLineSpacingRule != null) {
spacing.setLineRule(sTLineSpacingRule);
}
}
}
use of org.docx4j.wml.PPr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method getPPr.
public PPr getPPr(P p) {
PPr ppr = p.getPPr();
if (ppr == null) {
ppr = new PPr();
p.setPPr(ppr);
}
return ppr;
}
use of org.docx4j.wml.PPr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setParagraghBorders.
/**
* @Description: 设置段落边框样式
*/
public void setParagraghBorders(P p, CTBorder topBorder, CTBorder bottomBorder, CTBorder leftBorder, CTBorder rightBorder) {
PPr ppr = getPPr(p);
PBdr pBdr = new PBdr();
if (topBorder != null) {
pBdr.setTop(topBorder);
}
if (bottomBorder != null) {
pBdr.setBottom(bottomBorder);
}
if (leftBorder != null) {
pBdr.setLeft(leftBorder);
}
if (rightBorder != null) {
pBdr.setRight(rightBorder);
}
ppr.setPBdr(pBdr);
}
use of org.docx4j.wml.PPr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setParagraphIndInfo.
/**
* @Description: 设置段落缩进信息 1厘米≈567
*/
public void setParagraphIndInfo(P p, String firstLine, String firstLineChar, String hanging, String hangingChar, String right, String rigthChar, String left, String leftChar) {
PPr ppr = getPPr(p);
Ind ind = ppr.getInd();
if (ind == null) {
ind = new Ind();
ppr.setInd(ind);
}
if (StringUtils.isNotBlank(firstLine)) {
ind.setFirstLine(new BigInteger(firstLine));
}
if (StringUtils.isNotBlank(firstLineChar)) {
ind.setFirstLineChars(new BigInteger(firstLineChar));
}
if (StringUtils.isNotBlank(hanging)) {
ind.setHanging(new BigInteger(hanging));
}
if (StringUtils.isNotBlank(hangingChar)) {
ind.setHangingChars(new BigInteger(hangingChar));
}
if (StringUtils.isNotBlank(left)) {
ind.setLeft(new BigInteger(left));
}
if (StringUtils.isNotBlank(leftChar)) {
ind.setLeftChars(new BigInteger(leftChar));
}
if (StringUtils.isNotBlank(right)) {
ind.setRight(new BigInteger(right));
}
if (StringUtils.isNotBlank(rigthChar)) {
ind.setRightChars(new BigInteger(rigthChar));
}
}
use of org.docx4j.wml.PPr in project flexmark-java by vsch.
the class QuotedFormatProvider method adjustPPrForFormatting.
@Override
public void adjustPPrForFormatting(PPr pPr) {
// here we need to adjust for inherited left margin
final BigInteger newLeftInd = myDocx.getHelper().safeIndLeft(pPr);
final PPr styledPPr = myDocx.getHelper().getExplicitPPr(pPr);
if (styledPPr != null && styledPPr.getPBdr() != null && newLeftInd != null && newLeftInd.compareTo(myLeftInd) > 0) {
// it grew, word has the border hanging and we want the we shift it by our left border spacing
CTBorder leftBorder = styledPPr.getPBdr().getLeft();
if (leftBorder != null && leftBorder.getSpace() != null && leftBorder.getSpace().compareTo(BigInteger.ZERO) > 0) {
// pPr.getInd().setLeft(newLeftInd.add(leftBorder.getSpace().multiply(BigInteger.valueOf(20))));
final T currentNode = myDocx.getContextFrame();
if (currentNode instanceof Paragraph) {
int tmp = 0;
}
}
}
}
Aggregations