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

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

Introduction

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

Prototype

public void setStyle(String styleId) 

Source Link

Document

Set the style ID for the paragraph

Usage

From source file:com.siemens.sw360.licenseinfo.outputGenerators.DocxUtils.java

License:Open Source License

public static void addLicenseTextsHeader(XWPFDocument document, String header) {
    XWPFParagraph paragraph = document.createParagraph();
    XWPFRun run = paragraph.createRun();
    addPageBreak(run);//from   ww w  .j  a va  2 s.c  om
    XWPFParagraph textParagraph = document.createParagraph();
    XWPFRun textRun = textParagraph.createRun();
    textParagraph.setStyle("Heading1");
    textRun.setText(header);

    addNewLines(textRun, 1);
}

From source file:com.siemens.sw360.licenseinfo.outputGenerators.DocxUtils.java

License:Open Source License

public static void addLicenseTexts(XWPFDocument document,
        Collection<LicenseInfoParsingResult> projectLicenseInfoResults) {
    projectLicenseInfoResults.stream().map(LicenseInfoParsingResult::getLicenseInfo).filter(Objects::nonNull)
            .map(LicenseInfo::getLicenseNamesWithTexts).filter(Objects::nonNull).forEach(set -> {
                set.forEach(lt -> {/*  w  w w .j ava 2 s.c o m*/

                    XWPFParagraph licenseParagraph = document.createParagraph();
                    licenseParagraph.setStyle("Heading2");
                    XWPFRun licenseRun = licenseParagraph.createRun();
                    String licenseName = lt.isSetLicenseName() ? lt.getLicenseName() : "Unknown license name";
                    licenseRun.setText(licenseName);
                    addNewLines(licenseRun, 1);

                    XWPFParagraph licenseTextParagraph = document.createParagraph();
                    XWPFRun licenseTextRun = licenseTextParagraph.createRun();
                    addFormattedText(licenseTextRun, nullToEmptyString(lt.getLicenseText()), 12);
                    addNewLines(licenseTextRun, 1);
                });
            });
}

From source file:de.knowwe.include.export.FootnoteExporter.java

License:Open Source License

@Override
public void export(Section<FootnoteType> section, DocumentBuilder manager) throws ExportException {
    // find id for our footnote
    String refNumber = section.get().getFootnoteID(section);
    BigInteger noteId = getFootnoteIDInternal(manager, section.getArticle(), refNumber);

    // create footnote for that id
    CTFtnEdn ctNote = CTFtnEdn.Factory.newInstance();
    ctNote.setId(noteId);//from  w w  w  .j  av a 2  s .c  om
    ctNote.setType(STFtnEdn.NORMAL);
    XWPFFootnotes footnotes = manager.getDocument().createFootnotes();
    XWPFFootnote footnote = footnotes.addFootnote(ctNote);

    // add contents to footer
    XWPFParagraph footPara = footnote.addNewParagraph(CTP.Factory.newInstance());
    footPara.setStyle(Style.footnote.getStyleName());
    XWPFRun footRun = footPara.createRun();
    footRun.setSubscript(VerticalAlign.SUPERSCRIPT);
    footRun.setText(String.valueOf(noteId.intValue()));
    footRun = footPara.createRun();
    footRun.setSubscript(VerticalAlign.BASELINE);
    DocumentBuilder contentBuilder = new ListBuilder(manager, footPara, Style.text);
    contentBuilder.export(section.getChildren());
}

From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java

License:Apache License

/**
 * Fgt eine berschrift 1. Ebene ein//  w w  w . j  a v  a  2  s  .c  o m
 * 
 * @param heading
 *            der Titel
 */
private void addH1(String heading) {
    XWPFParagraph headPar = document.createParagraph();
    headPar.setStyle("berschrift1");
    XWPFRun run = headPar.createRun();
    run.setText(heading);
}

From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java

License:Apache License

/**
 * Fgt eine berschrift 2. Ebene ein//w  ww .  j  a v a 2s.  c o  m
 * 
 * @param heading
 *            der Titel
 */
private void addH2(String heading) {
    XWPFParagraph headPar = document.createParagraph();
    headPar.setStyle("berschrift2");
    XWPFRun run = headPar.createRun();
    run.setText(heading);
}

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);//from w  w  w  .java 2s . 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 addReleaseTitle(XWPFDocument document, LicenseInfoParsingResult parsingResult) {
    String releaseTitle = getComponentLongName(parsingResult);
    XWPFParagraph releaseTitleParagraph = document.createParagraph();
    releaseTitleParagraph.setStyle(STYLE_HEADING);
    addBookmark(releaseTitleParagraph, releaseTitle, releaseTitle);
    addNewLines(document, 0);//w  w  w  .  j a va2s . c o m
}

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

License:Open Source License

private void fillLicenseList(XWPFDocument document,
        Collection<LicenseInfoParsingResult> projectLicenseInfoResults) {
    List<LicenseNameWithText> licenseNameWithTexts = OutputGenerator
            .getSortedLicenseNameWithTexts(projectLicenseInfoResults);
    XWPFRun licenseHeaderRun = document.createParagraph().createRun();
    addFormattedText(licenseHeaderRun, "License texts", FONT_SIZE + 2, true);
    addNewLines(document, 0);/* w  w w .j  av  a  2  s. c o  m*/

    for (LicenseNameWithText licenseNameWithText : licenseNameWithTexts) {
        XWPFParagraph licenseParagraph = document.createParagraph();
        licenseParagraph.setStyle(STYLE_HEADING);
        String licenseName = licenseNameWithText.isSetLicenseName() ? licenseNameWithText.getLicenseName()
                : UNKNOWN_LICENSE_NAME;
        addBookmark(licenseParagraph, licenseName, licenseName);
        addNewLines(document, 0);
        setText(document.createParagraph().createRun(),
                nullToEmptyString(licenseNameWithText.getLicenseText()));
        addNewLines(document, 1);
    }
}

From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java

License:Open Source License

private static void addProperties(XWPFDocument wordDocument, OntClass ontClass) {
    Set<OntClass> equivalentClasses = ontClass.listEquivalentClasses().toSet();
    if (equivalentClasses.isEmpty())
        return;/*from w ww  . j a v  a 2 s  . c  o  m*/
    XWPFParagraph paragraph = wordDocument.createParagraph();
    paragraph.setStyle("style0");
    XWPFRun run = paragraph.createRun();
    run.setText("?: ");

    for (OntClass equivalentClass : equivalentClasses) {
        if (!equivalentClass.isRestriction())
            continue;
        AllValuesFromRestriction restriction = equivalentClass.asRestriction().asAllValuesFromRestriction();
        XWPFParagraph p = wordDocument.createParagraph();
        p.setIndentationLeft(1440);
        XWPFRun r = p.createRun();
        OntProperty onProperty = restriction.getOnProperty();
        OntClass toClass = restriction.getAllValuesFrom().as(OntClass.class);

        r.setText(format("%s: %s", formatPropertyURI(onProperty), formatURI(toClass)));
        r.setItalic(true);
    }
    wordDocument.createParagraph().setIndentationLeft(1440);
}

From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java

License:Open Source License

private static void addComment(XWPFDocument wordDocument, OntClass ontClass) {
    String comment = null;/*from  w  w  w .  j a  va  2 s  .c  o m*/
    if (ontClass.getComment(RU_LOCALE) != null) {
        comment = ontClass.getComment(RU_LOCALE);
    } else if (ontClass.getComment(EN_LOCALE) != null) {
        comment = ontClass.getComment(EN_LOCALE);
    } else {
        comment = ontClass.getComment(null);
    }
    if (comment == null || comment.isEmpty()) {
        classesWithEmptyComments.add(formatURI(ontClass));
        return;
    }
    XWPFParagraph paragraph = wordDocument.createParagraph();
    paragraph.setStyle("style0");
    XWPFRun run = paragraph.createRun();
    run.setText(format("?: \n%s",
            comment != null ? comment.replace("http://", ". http://").replace("www.", ". www.") : ""));
}