Example usage for org.apache.poi.xwpf.usermodel XWPFParagraph setSpacingAfter

List of usage examples for org.apache.poi.xwpf.usermodel XWPFParagraph setSpacingAfter

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFParagraph setSpacingAfter.

Prototype

public void setSpacingAfter(int spaces) 

Source Link

Document

Specifies the spacing that should be added after the last line in this paragraph in the document in absolute units.

Usage

From source file:com.bxf.hradmin.testgen.service.impl.DocxTestGenerator.java

License:Open Source License

private void adjustLineHeight(XWPFParagraph paragraph) {
    // ??//from  w  ww.j  a v a  2s. c o  m
    paragraph.setSpacingAfter(0);
    paragraph.setSpacingBefore(0);
    // ?
    CTSpacing spacing = paragraph.getCTP().getPPr().getSpacing();
    spacing.setLineRule(STLineSpacingRule.EXACT);
    spacing.setLine(BigInteger.valueOf(360));
}

From source file:csv2docxconverter.DocumentGenerator.java

/**
* Set header cell style/*w ww  .  j a va2 s  . c  o  m*/
*/
private XWPFRun setHeaderCell(XWPFTableCell cell) {
    cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

    XWPFParagraph paragraph = cell.getParagraphArray(0);
    paragraph.setAlignment(ParagraphAlignment.CENTER);
    paragraph.setSpacingBefore(8);
    paragraph.setSpacingAfter(8);

    XWPFRun run = paragraph.createRun();
    run.setBold(true);

    return run;
}

From source file:csv2docxconverter.DocumentGenerator.java

/**
* Set body cell style//from  w w  w. j  av a 2 s.  c  o  m
*/
private XWPFRun setBodyCell(XWPFTableCell cell) {
    cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

    XWPFParagraph paragraph = cell.getParagraphArray(0);
    paragraph.setAlignment(ParagraphAlignment.CENTER);
    paragraph.setSpacingBefore(4);
    paragraph.setSpacingAfter(4);

    return paragraph.createRun();
}

From source file:export.TableFunctionalReq.java

protected static void createReqFuncTable(XWPFDocument doc, FunctionalRequirement funcReq) {

    int[] cols = { 2943, 6507 };

    XWPFTable rf = doc.createTable(9, 2);

    // Get a list of the rows in the table
    List<XWPFTableRow> rows = rf.getRows();
    int rowCt = 0;
    int colCt = 0;

    for (XWPFTableRow row : rows) {

        // get the cells in this row
        List<XWPFTableCell> cells = row.getTableCells();
        for (XWPFTableCell cell : cells) {
            // get a table cell properties element (tcPr)
            CTTcPr tcpr = cell.getCTTc().addNewTcPr();

            // create cell color element
            CTShd ctshd = tcpr.addNewShd();

            ctshd.setColor("auto");
            ctshd.setVal(STShd.CLEAR);/*w  w  w.j  a  v  a2  s. c  o m*/

            if (colCt == 0) {
                ctshd.setFill("5C7F92");
            }

            // get 1st paragraph in cell's paragraph list
            XWPFParagraph para = cell.getParagraphs().get(0);
            para.setStyle("AltranNormal");
            para.setSpacingAfter(120);
            para.setSpacingBefore(120);

            // create a run to contain the content
            XWPFRun rh = para.createRun();
            //rh.setFontSize(11);

            rh.setFontFamily("Lucida Sans Unicode");

            if (colCt == 0) {
                rh.setColor("FFFFFF");
            }

            if (rowCt == 0 && colCt == 0) {
                rh.setText("RF " + ((x < 9) ? "0" + x : x) + "- F");
                x++;
            } else if (rowCt == 1 && colCt == 0) {
                rh.setText("Use Case (se disponvel):");
            } else if (rowCt == 2 && colCt == 0) {
                rh.setText("Descrio:");
            } else if (rowCt == 3 && colCt == 0) {
                rh.setText("Fonte:");
            } else if (rowCt == 4 && colCt == 0) {
                rh.setText("Fundamento:");
            } else if (rowCt == 5 && colCt == 0) {
                rh.setText("Critrio de avaliao:");
            } else if (rowCt == 6 && colCt == 0) {
                rh.setText("Satisfao do cliente:");
            } else if (rowCt == 7 && colCt == 0) {
                rh.setText("Insatisfao do cliente:");
            } else if (rowCt == 8 && colCt == 0) {
                rh.setText("Histrico:");
            }

            if (rowCt == 0 && colCt == 1) {// Nome do requisito
                rh.setText(funcReq.getName());
                rh.setBold(true);
            } else if (rowCt == 1 && colCt == 1) { // UseCases
                String testUC = "";
                int cntUC = 0;
                for (UseCase uc : funcReq.getUseCaseCollection()) {

                    if (cntUC == 0) {
                        testUC = uc.getName();
                    } else {
                        testUC = testUC + ", " + uc.getName();
                    }
                    cntUC++;
                }

                rh.setText(testUC);
            } else if (rowCt == 2 && colCt == 1) {// Descrio
                rh.setText(funcReq.getDescription());
            } else if (rowCt == 3 && colCt == 1) {// Fonte
                rh.setText(funcReq.getSource());
            } else if (rowCt == 4 && colCt == 1) {// Fundamento
                rh.setText(funcReq.getReason());
            } else if (rowCt == 5 && colCt == 1) {// Criterio de Avalicao
                rh.setText(funcReq.getAvaliationCriteria());
            } else if (rowCt == 6 && colCt == 1) {// Prioridade
                rh.setText(funcReq.getClientPriority().toString());
            } else if (rowCt == 7 && colCt == 1) {// Insatisfao
                rh.setText(funcReq.getClientInsatisfaction().toString());
            } else if (rowCt == 8 && colCt == 1) {// Historico
                rh.setText("Histrico");
            }

            cell.getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(cols[colCt]));
            colCt++;
        }
        colCt = 0;
        rowCt++;

    }

    doc.createParagraph().createRun().addBreak();

}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.DocxGenerator.java

License:Open Source License

private void addCopyrights(XWPFDocument document, LicenseInfoParsingResult parsingResult) {
    XWPFRun copyrightTitleRun = document.createParagraph().createRun();
    addFormattedText(copyrightTitleRun, "Copyrights", FONT_SIZE, true);
    for (String copyright : getReleaseCopyrights(parsingResult)) {
        XWPFParagraph copyPara = document.createParagraph();
        copyPara.setSpacingAfter(0);
        setText(copyPara.createRun(), copyright);
    }//from  www.  j  ava  2  s.com
}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.DocxGenerator.java

License:Open Source License

private void addLicenses(XWPFDocument document, LicenseInfoParsingResult parsingResult,
        boolean includeObligations) throws TException {
    XWPFRun licensesTitleRun = document.createParagraph().createRun();
    addNewLines(licensesTitleRun, 1);//from  w ww  . ja va  2  s.  c  o  m
    addFormattedText(licensesTitleRun, "Licenses", FONT_SIZE, true);
    for (String licenseName : getReleasesLicenses(parsingResult)) {
        XWPFParagraph licensePara = document.createParagraph();
        licensePara.setSpacingAfter(0);
        addBookmarkHyperLink(licensePara, licenseName, licenseName);
        if (includeObligations) {
            addLicenseObligations(document, licenseName);
        }
    }
}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.DocxGenerator.java

License:Open Source License

private void addLicenseObligations(XWPFDocument document, String spdxLicense) throws TException {
    List<License> sw360Licenses = getLicenses();
    XWPFRun todoTitleRun = document.createParagraph().createRun();
    addNewLines(todoTitleRun, 0);/*from  w ww  .  j  a va 2s.com*/
    Set<String> todos = getTodosFromLicenses(spdxLicense, sw360Licenses);
    addFormattedText(todoTitleRun, "Obligations for license " + spdxLicense + ":", FONT_SIZE, true);
    for (String todo : todos) {
        XWPFParagraph copyPara = document.createParagraph();
        copyPara.setSpacingAfter(0);
        XWPFRun todoRun = copyPara.createRun();
        setText(todoRun, todo);
        addNewLines(todoRun, 1);
    }
}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.DocxUtils.java

License:Open Source License

public static void addBulletList(XWPFDocument document, List<String> bulletListItems,
        boolean bulletListItemsAsLink) throws XmlException {
    CTNumbering cTNumbering = CTNumbering.Factory.parse(cTAbstractNumBulletXML);
    CTAbstractNum cTAbstractNum = cTNumbering.getAbstractNumArray(0);
    XWPFAbstractNum abstractNum = new XWPFAbstractNum(cTAbstractNum);
    XWPFNumbering numbering = document.createNumbering();
    BigInteger abstractNumID = numbering.addAbstractNum(abstractNum);
    BigInteger numID = numbering.addNum(abstractNumID);

    for (int i = 0; i < bulletListItems.size(); i++) {
        String bulletItem = bulletListItems.get(i);
        XWPFParagraph paragraph = document.createParagraph();
        paragraph.setNumID(numID);//w  w w . ja  va2 s . co m
        if (bulletListItemsAsLink) {
            addBookmarkHyperLink(paragraph, bulletItem, bulletItem);
        } else {
            setText(paragraph.createRun(), bulletItem);
        }
        if (i < bulletListItems.size() - 1) {
            paragraph.setSpacingAfter(0);
        }
    }
}

From source file:org.obeonetwork.m2doc.generator.M2DocEvaluator.java

License:Open Source License

/**
 * Fill a newly created word table with the data from an MTable.
 * //from w  w  w. ja v  a 2s .c  o  m
 * @param table
 *            The newly created word table
 * @param mtable
 *            The MTable that describes the data and styles to insert
 */
private void fillTable(XWPFTable table, MTable mtable) {
    List<MRow> rows = mtable.getRows();
    // Iterate over the rows
    for (int rowIdx = 0; rowIdx < rows.size(); rowIdx++) {
        MRow mRow = rows.get(rowIdx);

        // Get or create XWPF row
        XWPFTableRow xwpfRow;
        if (table.getNumberOfRows() > rowIdx) {
            xwpfRow = table.getRow(rowIdx);
        } else {
            xwpfRow = table.createRow();
        }

        // Iterate over the columns
        for (int colIdx = 0; colIdx < mtable.getColumnsCount(); colIdx++) {
            // Get or create XWPF cell
            XWPFTableCell xwpfCell;
            if (xwpfRow.getTableCells().size() > colIdx) {
                xwpfCell = xwpfRow.getCell(colIdx);
            } else {
                xwpfCell = xwpfRow.createCell();
            }

            // Populate cell
            XWPFParagraph xwpfCellParagraph = xwpfCell.getParagraphs().get(0);
            xwpfCellParagraph.setSpacingBefore(0);
            xwpfCellParagraph.setSpacingAfter(0);
            MCell mCell = null;
            if (colIdx < mRow.getCells().size()) {
                mCell = mRow.getCells().get(colIdx);
            }
            setCellContent(xwpfCell, mCell);
        }
    }
}

From source file:org.obeonetwork.m2doc.generator.TableClientProcessor.java

License:Open Source License

/**
 * Create a table in a document.//from w  ww.j a  va 2  s .c om
 * 
 * @param tableRun
 *            the run after which the table must be created
 * @param first
 *            Whether it's the first table to insert or not
 * @param mtable
 *            The table description
 * @return The newly created table.
 */
private XWPFTable createTableInDocument(XWPFRun tableRun, boolean first, MTable mtable) {
    XWPFTable table;
    if (!first) {
        ((XWPFDocument) body).createParagraph();
    }
    if (showTitle() && mtable.getLabel() != null) {
        XWPFRun captionRun;
        if (first) {
            captionRun = tableRun;
            IRunBody runBody = captionRun.getParent();
            if (runBody instanceof XWPFParagraph) {
                ((XWPFParagraph) runBody).setSpacingAfter(0);
            }
        } else {
            XWPFParagraph captionParagraph = ((XWPFDocument) body).createParagraph();
            captionParagraph.setSpacingAfter(0);
            captionRun = captionParagraph.createRun();
        }
        captionRun.setText(mtable.getLabel());
        captionRun.setBold(true);
    }
    table = ((XWPFDocument) body).createTable();
    return table;
}