Search in sources :

Example 21 with Tc

use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.

the class ContainerParseTest method testParagraphInTableCellLayout.

@Test
public void testParagraphInTableCellLayout() throws Exception {
    String html = "<table><tbody><tr>" + "<td><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/>" + "<p><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/></p>" + "<img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/></td></tr></tbody></table>";
    List<Object> tConvert = convert(html);
    Assert.assertTrue(tConvert.size() == 1);
    for (Object t : tConvert) {
        Assert.assertTrue(t instanceof Tbl);
        Tbl table = (Tbl) t;
        List<Object> convert = ((Tc) ((Tr) table.getContent().get(0)).getContent().get(0)).getContent();
        Assert.assertTrue(convert.size() == 3);
        for (Object o : convert) {
            Assert.assertTrue(o instanceof P);
            P paragraph = (P) o;
            List<Object> content = paragraph.getContent();
            Assert.assertTrue(content.size() == 2);
            for (Object child : content) {
                Assert.assertTrue(child instanceof R);
                R run = ((R) child);
                List<Object> rContent = run.getContent();
                Assert.assertTrue(rContent.size() == 1);
                Assert.assertTrue(rContent.get(0) instanceof Drawing);
            }
        }
    }
}
Also used : P(org.docx4j.wml.P) Drawing(org.docx4j.wml.Drawing) R(org.docx4j.wml.R) Tr(org.docx4j.wml.Tr) Tbl(org.docx4j.wml.Tbl) Tc(org.docx4j.wml.Tc) Test(org.junit.Test)

Example 22 with Tc

use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.

the class ComplexTable method addTc.

private static void addTc(Tr tr, String label, String text, String width) {
    Tc tc = factory.createTc();
    TcPr tcPr = new TcPr();
    TblWidth tblwidth = new TblWidth();
    tblwidth.setType("dxa");
    tblwidth.setW(new BigInteger(width));
    tcPr.setTcW(tblwidth);
    tc.setTcPr(tcPr);
    tc.getEGBlockLevelElts().add(wordMLPackage.getMainDocumentPart().createParagraphOfText(text));
    tr.getEGContentCellContent().add(tc);
}
Also used : TblWidth(org.docx4j.wml.TblWidth) TcPr(org.docx4j.wml.TcPr) BigInteger(java.math.BigInteger) Tc(org.docx4j.wml.Tc)

Example 23 with Tc

use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.

the class Docx4jUtils method addTableCell.

private void addTableCell(Tr tableRow, String content, int width, DocxStyle style, int horizontalMergedCells, String verticalMergedVal) {
    Tc tableCell = factory.createTc();
    addCellStyle(tableCell, content, style);
    setCellWidth(tableCell, width);
    setCellVMerge(tableCell, verticalMergedVal);
    setCellHMerge(tableCell, horizontalMergedCells);
    if (style.isNoWrap()) {
        setCellNoWrap(tableCell);
    }
    tableRow.getContent().add(tableCell);
}
Also used : Tc(org.docx4j.wml.Tc)

Example 24 with Tc

use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.

the class Docx4jUtils method addTableCell.

private void addTableCell(Tr tableRow, P image, int width, DocxStyle style, int horizontalMergedCells, String verticalMergedVal) {
    Tc tableCell = factory.createTc();
    addImageCellStyle(tableCell, image, style);
    setCellWidth(tableCell, width);
    setCellVMerge(tableCell, verticalMergedVal);
    setCellHMerge(tableCell, horizontalMergedCells);
    tableRow.getContent().add(tableCell);
}
Also used : Tc(org.docx4j.wml.Tc)

Example 25 with Tc

use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.

the class NestedTable method addTc.

protected static void addTc(Tr tr, String text) {
    Tc tc = factory.createTc();
    TcPr tcPr = new TcPr();
    TblWidth width = new TblWidth();
    width.setType("dxa");
    width.setW(new BigInteger("3192"));
    tcPr.setTcW(width);
    tc.setTcPr(tcPr);
    tc.getEGBlockLevelElts().add(wordMLPackage.getMainDocumentPart().createParagraphOfText(text));
    tr.getEGContentCellContent().add(tc);
}
Also used : TblWidth(org.docx4j.wml.TblWidth) TcPr(org.docx4j.wml.TcPr) BigInteger(java.math.BigInteger) Tc(org.docx4j.wml.Tc)

Aggregations

Tc (org.docx4j.wml.Tc)53 TcPr (org.docx4j.wml.TcPr)22 Tr (org.docx4j.wml.Tr)17 P (org.docx4j.wml.P)11 R (org.docx4j.wml.R)10 Tbl (org.docx4j.wml.Tbl)9 BigInteger (java.math.BigInteger)7 TblWidth (org.docx4j.wml.TblWidth)7 VMerge (org.docx4j.wml.TcPrInner.VMerge)7 Text (org.docx4j.wml.Text)7 GridSpan (org.docx4j.wml.TcPrInner.GridSpan)6 CTVerticalJc (org.docx4j.wml.CTVerticalJc)5 TblPr (org.docx4j.wml.TblPr)5 ArrayList (java.util.ArrayList)4 CTShd (org.docx4j.wml.CTShd)4 File (java.io.File)3 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)3 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)3 ObjectFactory (org.docx4j.wml.ObjectFactory)3 PPr (org.docx4j.wml.PPr)3