コード例 #1
0
  public void testShapeFlip() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

    HSSFSimpleShape rectangle = patriarch.createSimpleShape(new HSSFClientAnchor());
    rectangle.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);

    assertEquals(rectangle.isFlipVertical(), false);
    assertEquals(rectangle.isFlipHorizontal(), false);

    rectangle.setFlipVertical(true);
    assertEquals(rectangle.isFlipVertical(), true);
    rectangle.setFlipHorizontal(true);
    assertEquals(rectangle.isFlipHorizontal(), true);

    wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
    sheet = wb.getSheetAt(0);
    patriarch = sheet.getDrawingPatriarch();

    rectangle = (HSSFSimpleShape) patriarch.getChildren().get(0);

    assertEquals(rectangle.isFlipHorizontal(), true);
    rectangle.setFlipHorizontal(false);
    assertEquals(rectangle.isFlipHorizontal(), false);

    assertEquals(rectangle.isFlipVertical(), true);
    rectangle.setFlipVertical(false);
    assertEquals(rectangle.isFlipVertical(), false);

    wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
    sheet = wb.getSheetAt(0);
    patriarch = sheet.getDrawingPatriarch();

    rectangle = (HSSFSimpleShape) patriarch.getChildren().get(0);

    assertEquals(rectangle.isFlipVertical(), false);
    assertEquals(rectangle.isFlipHorizontal(), false);
  }