Search in sources :

Example 16 with PPr

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);
        }
    }
}
Also used : PPr(org.docx4j.wml.PPr) BigInteger(java.math.BigInteger) Spacing(org.docx4j.wml.PPrBase.Spacing)

Example 17 with PPr

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;
}
Also used : PPr(org.docx4j.wml.PPr)

Example 18 with 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);
}
Also used : PPr(org.docx4j.wml.PPr) PBdr(org.docx4j.wml.PPrBase.PBdr)

Example 19 with PPr

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));
    }
}
Also used : PPr(org.docx4j.wml.PPr) BigInteger(java.math.BigInteger) Ind(org.docx4j.wml.PPrBase.Ind)

Example 20 with PPr

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;
            }
        }
    }
}
Also used : PPr(org.docx4j.wml.PPr) CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) Paragraph(com.vladsch.flexmark.ast.Paragraph)

Aggregations

PPr (org.docx4j.wml.PPr)48 Jc (org.docx4j.wml.Jc)29 R (org.docx4j.wml.R)23 P (org.docx4j.wml.P)22 CTVerticalJc (org.docx4j.wml.CTVerticalJc)21 STVerticalJc (org.docx4j.wml.STVerticalJc)20 BigInteger (java.math.BigInteger)17 Text (org.docx4j.wml.Text)14 PBdr (org.docx4j.wml.PPrBase.PBdr)10 CTBorder (org.docx4j.wml.CTBorder)9 RPr (org.docx4j.wml.RPr)6 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)5 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)5 Drawing (org.docx4j.wml.Drawing)5 Spacing (org.docx4j.wml.PPrBase.Spacing)5 Ftr (org.docx4j.wml.Ftr)4 ObjectFactory (org.docx4j.wml.ObjectFactory)4 ParaRPr (org.docx4j.wml.ParaRPr)4 Ind (org.docx4j.wml.PPrBase.Ind)3 Tc (org.docx4j.wml.Tc)3