Search in sources :

Example 61 with Text

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

Example 62 with Text

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

Aggregations

Text (org.docx4j.wml.Text)62 R (org.docx4j.wml.R)53 P (org.docx4j.wml.P)32 PPr (org.docx4j.wml.PPr)14 RPr (org.docx4j.wml.RPr)12 Jc (org.docx4j.wml.Jc)10 CTVerticalJc (org.docx4j.wml.CTVerticalJc)9 File (java.io.File)8 Tc (org.docx4j.wml.Tc)7 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)6 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)6 STVerticalJc (org.docx4j.wml.STVerticalJc)6 BigInteger (java.math.BigInteger)5 Br (org.docx4j.wml.Br)5 ObjectFactory (org.docx4j.wml.ObjectFactory)5 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)4 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)4 CTShd (org.docx4j.wml.CTShd)4 Ftr (org.docx4j.wml.Ftr)4 Tbl (org.docx4j.wml.Tbl)4