Search in sources :

Example 1 with STBorder

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

the class TableBordersTest method testTableBorderStyles.

@Test
public void testTableBorderStyles() throws Docx4JException {
    HashMap<String, STBorder> styles = new HashMap<String, STBorder>();
    styles.put("none", STBorder.NONE);
    styles.put("hidden", STBorder.NONE);
    styles.put("solid", STBorder.SINGLE);
    styles.put("dotted", STBorder.DOTTED);
    styles.put("dashed", STBorder.DASHED);
    styles.put("double", STBorder.DOUBLE);
    styles.put("inset", STBorder.INSET);
    styles.put("outset", STBorder.OUTSET);
    // no direct substitution
    styles.put("groove", STBorder.SINGLE);
    // no direct substitution
    styles.put("ridge", STBorder.SINGLE);
    styles.put("anyOther", STBorder.NONE);
    for (String style : styles.keySet()) {
        Tbl tbl = table("<table style='border: 1px " + style + " black;'><tr><td>1</td></tr></table>");
        TblBorders borders = tbl.getTblPr().getTblBorders();
        assertEquals(styles.get(style), borders.getTop().getVal());
    }
}
Also used : STBorder(org.docx4j.wml.STBorder) HashMap(java.util.HashMap) TblBorders(org.docx4j.wml.TblBorders) Tbl(org.docx4j.wml.Tbl) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 STBorder (org.docx4j.wml.STBorder)1 Tbl (org.docx4j.wml.Tbl)1 TblBorders (org.docx4j.wml.TblBorders)1 Test (org.junit.Test)1