use of org.docx4j.wml.Text in project docx4j-template by vindell.
the class Docx4j_替换模板 method replaceTcContent.
/**
* 替换单元格内容
*/
private void replaceTcContent(Tc tc, String value) {
List<Object> rtnList = getAllElementFromObject(tc, Text.class);
if (rtnList == null || rtnList.size() == 0) {
return;
}
Text textElement = (Text) rtnList.get(0);
textElement.setValue(value);
}
use of org.docx4j.wml.Text in project flexmark-java by vsch.
the class ComboDocxConverterSpecTest method addSpecExample.
@Override
public void addSpecExample(SpecExample example, Node node, DataHolder options, boolean ignoredCase, String actualHTML, String actualAST) {
if (!DUMP_ALL_TESTS_FILES)
return;
final boolean failed = !ignoredCase && !actualHTML.equals(example.getHtml());
// add source information
myDocxContext.createP("Heading3");
if (ignoredCase) {
// does not match, need more stuff
myDocxContext.createColor().setVal("BB002F");
myDocxContext.addBold();
Text text = myDocxContext.addWrappedText();
text.setValue("Ignored ");
text.setSpace(RunFormatProvider.SPACE_PRESERVE);
} else if (failed) {
// does not match, need more stuff
myDocxContext.createColor().setVal("BB002F");
myDocxContext.addBold();
Text text = myDocxContext.addWrappedText();
text.setValue("Failed ");
text.setSpace(RunFormatProvider.SPACE_PRESERVE);
} else {
// does not match, need more stuff
myDocxContext.createColor().setVal("008000");
myDocxContext.addBold();
Text text = myDocxContext.addWrappedText();
text.setValue("Passed ");
text.setSpace(RunFormatProvider.SPACE_PRESERVE);
}
StringBuilder header = new StringBuilder();
final String section = example.getSection();
header.append(section == null ? "" : section.trim()).append(": ").append(example.getExampleNumber());
final String optionsSet = example.getOptionsSet();
myDocxContext.text(header.toString());
if (optionsSet != null) {
myDocxContext.createHpsMeasure(28);
myDocxContext.createColor().setVal("7B56A0");
Text text = myDocxContext.addWrappedText();
text.setValue((SpecReader.OPTIONS_STRING + "(") + optionsSet + ")");
text.setSpace(RunFormatProvider.SPACE_PRESERVE);
}
myDocxContext.createHorizontalLine();
RENDERER.withOptions(options).render(node, myPackage);
myDocxContext.createHorizontalLine();
if (example.hasComment()) {
final String comment = example.getComment();
String[] lines = comment.split("\n\\s*\n");
for (String line : lines) {
String trimmed = line.trim();
if (!trimmed.isEmpty()) {
myDocxContext.createP(myDocxContext.getRenderingOptions().LOOSE_PARAGRAPH_STYLE);
myDocxContext.createColor().setVal("808080");
Text text = myDocxContext.addWrappedText();
text.setValue(trimmed);
}
}
}
myDocxContext.renderFencedCodeLines(example.getSource().split("\n"));
// noinspection StatementWithEmptyBody
if (failed) {
// could add expected and actual text but that would be too much
}
}
Aggregations