Search in sources :

Example 1 with TableShape

use of org.apache.poi.sl.usermodel.TableShape in project poi by apache.

the class TestTable method testTextDirection.

private void testTextDirection(SlideShow<?, ?> ppt1) throws IOException {
    TextDirection[] tds = { TextDirection.HORIZONTAL, TextDirection.VERTICAL, TextDirection.VERTICAL_270 };
    TableShape<?, ?> tbl1 = ppt1.createSlide().createTable(1, 3);
    tbl1.setAnchor(new Rectangle2D.Double(50, 50, 200, 200));
    int col = 0;
    for (TextDirection td : tds) {
        TableCell<?, ?> c = tbl1.getCell(0, col++);
        if (c != null) {
            c.setTextDirection(td);
            c.setText("bla");
        }
    }
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ppt1.write(bos);
    ppt1.close();
    InputStream is = new ByteArrayInputStream(bos.toByteArray());
    SlideShow<?, ?> ppt2 = SlideShowFactory.create(is);
    TableShape<?, ?> tbl2 = (TableShape<?, ?>) ppt2.getSlides().get(0).getShapes().get(0);
    col = 0;
    for (TextDirection td : tds) {
        TableCell<?, ?> c = tbl2.getCell(0, col++);
        assertEquals(td, c.getTextDirection());
    }
    ppt2.close();
}
Also used : TextDirection(org.apache.poi.sl.usermodel.TextShape.TextDirection) TableShape(org.apache.poi.sl.usermodel.TableShape) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Rectangle2D(java.awt.geom.Rectangle2D) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

Rectangle2D (java.awt.geom.Rectangle2D)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 TableShape (org.apache.poi.sl.usermodel.TableShape)1 TextDirection (org.apache.poi.sl.usermodel.TextShape.TextDirection)1