use of org.apache.poi.xwpf.usermodel.XWPFRun in project sw360portal by sw360.
the class DocxGenerator method fillLicenseList.
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);
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);
}
}
use of org.apache.poi.xwpf.usermodel.XWPFRun in project sw360portal by sw360.
the class DocxGenerator method fillReleaseDetailList.
private void fillReleaseDetailList(XWPFDocument document, Collection<LicenseInfoParsingResult> projectLicenseInfoResults, boolean includeObligations) throws TException {
addFormattedText(document.createParagraph().createRun(), "Detailed Releases Information", FONT_SIZE + 2, true);
setText(document.createParagraph().createRun(), "Please note the following license conditions and copyright " + "notices applicable to Open Source Software and/or other components (or parts thereof):");
addNewLines(document, 0);
for (LicenseInfoParsingResult parsingResult : projectLicenseInfoResults) {
addReleaseTitle(document, parsingResult);
if (parsingResult.getStatus() == LicenseInfoRequestStatus.SUCCESS) {
addCopyrights(document, parsingResult);
addLicenses(document, parsingResult, includeObligations);
} else {
XWPFRun errorRun = document.createParagraph().createRun();
String errorText = nullToEmptyString(parsingResult.getMessage());
String filename = getFilename(parsingResult);
addFormattedText(errorRun, String.format("Error reading license information: %s", errorText), FONT_SIZE, false, ALERT_COLOR);
addFormattedText(errorRun, String.format("Source file: %s", filename), FONT_SIZE, false, ALERT_COLOR);
}
addNewLines(document, 1);
}
addPageBreak(document);
}
use of org.apache.poi.xwpf.usermodel.XWPFRun in project sw360portal by sw360.
the class DocxGenerator method addLicenseObligations.
private void addLicenseObligations(XWPFDocument document, String spdxLicense) throws TException {
List<License> sw360Licenses = getLicenses();
XWPFRun todoTitleRun = document.createParagraph().createRun();
addNewLines(todoTitleRun, 0);
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);
}
}
use of org.apache.poi.xwpf.usermodel.XWPFRun in project tutorials by eugenp.
the class WordIntegrationTest method whenParsingOutputDocument_thenCorrect.
@Test
public void whenParsingOutputDocument_thenCorrect() throws Exception {
Path msWordPath = Paths.get(WordDocument.output);
XWPFDocument document = new XWPFDocument(Files.newInputStream(msWordPath));
List<XWPFParagraph> paragraphs = document.getParagraphs();
document.close();
XWPFParagraph title = paragraphs.get(0);
XWPFRun titleRun = title.getRuns().get(0);
assertEquals("Build Your REST API with Spring", title.getText());
assertEquals("009933", titleRun.getColor());
assertTrue(titleRun.isBold());
assertEquals("Courier", titleRun.getFontFamily());
assertEquals(20, titleRun.getFontSize());
assertEquals("from HTTP fundamentals to API Mastery", paragraphs.get(1).getText());
assertEquals("What makes a good API?", paragraphs.get(3).getText());
assertEquals(wordDocument.convertTextFileToString(WordDocument.paragraph1), paragraphs.get(4).getText());
assertEquals(wordDocument.convertTextFileToString(WordDocument.paragraph2), paragraphs.get(5).getText());
assertEquals(wordDocument.convertTextFileToString(WordDocument.paragraph3), paragraphs.get(6).getText());
}
Aggregations