Example #1
0
 public void testDefaultPictureSettings() {
   HSSFPicture picture = new HSSFPicture(null, new HSSFClientAnchor());
   assertEquals(picture.getLineWidth(), HSSFShape.LINEWIDTH_DEFAULT);
   assertEquals(picture.getFillColor(), HSSFShape.FILL__FILLCOLOR_DEFAULT);
   assertEquals(picture.getLineStyle(), HSSFShape.LINESTYLE_NONE);
   assertEquals(picture.getLineStyleColor(), HSSFShape.LINESTYLE__COLOR_DEFAULT);
   assertEquals(picture.isNoFill(), false);
   assertEquals(picture.getPictureIndex(), -1); // not set yet
 }
Example #2
0
  public void testReadExistingImage() {
    HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");
    HSSFSheet sheet = wb.getSheet("pictures");
    HSSFPatriarch drawing = sheet.getDrawingPatriarch();
    assertEquals(1, drawing.getChildren().size());
    HSSFPicture picture = (HSSFPicture) drawing.getChildren().get(0);

    assertEquals(picture.getPictureIndex(), 2);
    assertEquals(picture.getLineStyleColor(), HSSFShape.LINESTYLE__COLOR_DEFAULT);
    assertEquals(picture.getFillColor(), 0x5DC943);
    assertEquals(picture.getLineWidth(), HSSFShape.LINEWIDTH_DEFAULT);
    assertEquals(picture.getLineStyle(), HSSFShape.LINESTYLE_DEFAULT);
    assertEquals(picture.isNoFill(), false);

    picture.setPictureIndex(2);
    assertEquals(picture.getPictureIndex(), 2);
  }
Example #3
0
  /** No NullPointerException should appear */
  public void testDefaultSettingsWithEmptyContainer() {
    EscherContainerRecord container = new EscherContainerRecord();
    EscherOptRecord opt = new EscherOptRecord();
    opt.setRecordId(EscherOptRecord.RECORD_ID);
    container.addChildRecord(opt);
    ObjRecord obj = new ObjRecord();
    CommonObjectDataSubRecord cod = new CommonObjectDataSubRecord();
    cod.setObjectType(HSSFSimpleShape.OBJECT_TYPE_PICTURE);
    obj.addSubRecord(cod);
    HSSFPicture picture = new HSSFPicture(container, obj);

    assertEquals(picture.getLineWidth(), HSSFShape.LINEWIDTH_DEFAULT);
    assertEquals(picture.getFillColor(), HSSFShape.FILL__FILLCOLOR_DEFAULT);
    assertEquals(picture.getLineStyle(), HSSFShape.LINESTYLE_DEFAULT);
    assertEquals(picture.getLineStyleColor(), HSSFShape.LINESTYLE__COLOR_DEFAULT);
    assertEquals(picture.isNoFill(), HSSFShape.NO_FILL_DEFAULT);
    assertEquals(picture.getPictureIndex(), -1); // not set yet
  }