Search in sources :

Example 1 with HSSFAnchor

use of org.apache.poi.hssf.usermodel.HSSFAnchor in project poi by apache.

the class TestDrawingShapes method checkWorkbookBack.

private void checkWorkbookBack(HSSFWorkbook wb) throws IOException {
    HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
    assertNotNull(wbBack);
    HSSFSheet sheetBack = wbBack.getSheetAt(0);
    assertNotNull(sheetBack);
    HSSFPatriarch patriarchBack = sheetBack.getDrawingPatriarch();
    assertNotNull(patriarchBack);
    List<HSSFShape> children = patriarchBack.getChildren();
    assertEquals(4, children.size());
    HSSFShape hssfShape = children.get(0);
    assertTrue(hssfShape instanceof HSSFSimpleShape);
    HSSFAnchor anchor = hssfShape.getAnchor();
    assertTrue(anchor instanceof HSSFClientAnchor);
    assertEquals(0, anchor.getDx1());
    assertEquals(512, anchor.getDx2());
    assertEquals(0, anchor.getDy1());
    assertEquals(100, anchor.getDy2());
    HSSFClientAnchor cAnchor = (HSSFClientAnchor) anchor;
    assertEquals(1, cAnchor.getCol1());
    assertEquals(1, cAnchor.getCol2());
    assertEquals(1, cAnchor.getRow1());
    assertEquals(1, cAnchor.getRow2());
    hssfShape = children.get(1);
    assertTrue(hssfShape instanceof HSSFSimpleShape);
    anchor = hssfShape.getAnchor();
    assertTrue(anchor instanceof HSSFClientAnchor);
    assertEquals(512, anchor.getDx1());
    assertEquals(1024, anchor.getDx2());
    assertEquals(0, anchor.getDy1());
    assertEquals(100, anchor.getDy2());
    cAnchor = (HSSFClientAnchor) anchor;
    assertEquals(1, cAnchor.getCol1());
    assertEquals(1, cAnchor.getCol2());
    assertEquals(1, cAnchor.getRow1());
    assertEquals(1, cAnchor.getRow2());
    hssfShape = children.get(2);
    assertTrue(hssfShape instanceof HSSFSimpleShape);
    anchor = hssfShape.getAnchor();
    assertTrue(anchor instanceof HSSFClientAnchor);
    assertEquals(0, anchor.getDx1());
    assertEquals(512, anchor.getDx2());
    assertEquals(0, anchor.getDy1());
    assertEquals(100, anchor.getDy2());
    cAnchor = (HSSFClientAnchor) anchor;
    assertEquals(2, cAnchor.getCol1());
    assertEquals(2, cAnchor.getCol2());
    assertEquals(2, cAnchor.getRow1());
    assertEquals(2, cAnchor.getRow2());
    hssfShape = children.get(3);
    assertTrue(hssfShape instanceof HSSFSimpleShape);
    anchor = hssfShape.getAnchor();
    assertTrue(anchor instanceof HSSFClientAnchor);
    assertEquals(0, anchor.getDx1());
    assertEquals(512, anchor.getDx2());
    assertEquals(100, anchor.getDy1());
    assertEquals(200, anchor.getDy2());
    cAnchor = (HSSFClientAnchor) anchor;
    assertEquals(2, cAnchor.getCol1());
    assertEquals(2, cAnchor.getCol2());
    assertEquals(2, cAnchor.getRow1());
    assertEquals(2, cAnchor.getRow2());
    wbBack.close();
}
Also used : HSSFPatriarch(org.apache.poi.hssf.usermodel.HSSFPatriarch) HSSFSimpleShape(org.apache.poi.hssf.usermodel.HSSFSimpleShape) HSSFClientAnchor(org.apache.poi.hssf.usermodel.HSSFClientAnchor) HSSFAnchor(org.apache.poi.hssf.usermodel.HSSFAnchor) HSSFShape(org.apache.poi.hssf.usermodel.HSSFShape) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Aggregations

HSSFAnchor (org.apache.poi.hssf.usermodel.HSSFAnchor)1 HSSFClientAnchor (org.apache.poi.hssf.usermodel.HSSFClientAnchor)1 HSSFPatriarch (org.apache.poi.hssf.usermodel.HSSFPatriarch)1 HSSFShape (org.apache.poi.hssf.usermodel.HSSFShape)1 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)1 HSSFSimpleShape (org.apache.poi.hssf.usermodel.HSSFSimpleShape)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1