예제 #1
0
  public void testHSSFShapeCompatibility() {
    HSSFSimpleShape shape = new HSSFSimpleShape(null, new HSSFClientAnchor());
    shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
    assertEquals(0x08000040, shape.getLineStyleColor());
    assertEquals(0x08000009, shape.getFillColor());
    assertEquals(HSSFShape.LINEWIDTH_DEFAULT, shape.getLineWidth());
    assertEquals(HSSFShape.LINESTYLE_SOLID, shape.getLineStyle());
    assertFalse(shape.isNoFill());

    AbstractShape sp = AbstractShape.createShape(shape, 1);
    EscherContainerRecord spContainer = sp.getSpContainer();
    EscherOptRecord opt = spContainer.getChildById(EscherOptRecord.RECORD_ID);

    assertEquals(7, opt.getEscherProperties().size());
    assertEquals(
        true,
        ((EscherBoolProperty) opt.lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE)).isTrue());
    assertEquals(
        0x00000004,
        ((EscherSimpleProperty) opt.lookup(EscherProperties.GEOMETRY__SHAPEPATH))
            .getPropertyValue());
    assertEquals(
        0x08000009,
        ((EscherSimpleProperty) opt.lookup(EscherProperties.FILL__FILLCOLOR)).getPropertyValue());
    assertEquals(
        true, ((EscherBoolProperty) opt.lookup(EscherProperties.FILL__NOFILLHITTEST)).isTrue());
    assertEquals(
        0x08000040,
        ((EscherSimpleProperty) opt.lookup(EscherProperties.LINESTYLE__COLOR)).getPropertyValue());
    assertEquals(
        true,
        ((EscherBoolProperty) opt.lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).isTrue());
    assertEquals(
        true, ((EscherBoolProperty) opt.lookup(EscherProperties.GROUPSHAPE__PRINT)).isTrue());
  }
예제 #2
0
 /**
  * Return type of the shape. In most cases shape group type is {@link
  * org.apache.poi.hslf.model.ShapeTypes#NotPrimitive}
  *
  * @return type of the shape.
  */
 public int getShapeType() {
   EscherContainerRecord groupInfoContainer = (EscherContainerRecord) _escherContainer.getChild(0);
   EscherSpRecord spRecord = groupInfoContainer.getChildById(EscherSpRecord.RECORD_ID);
   return spRecord.getOptions() >> 4;
 }
예제 #3
-1
  public void testCorrectOrderInOptRecord() throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();

    try {
      HSSFSheet sheet = wb.createSheet();
      HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

      HSSFTextbox textbox = patriarch.createTextbox(new HSSFClientAnchor());
      EscherOptRecord opt = HSSFTestHelper.getOptRecord(textbox);

      String opt1Str = opt.toXml();

      textbox.setFillColor(textbox.getFillColor());
      EscherContainerRecord container = HSSFTestHelper.getEscherContainer(textbox);
      EscherOptRecord optRecord = container.getChildById(EscherOptRecord.RECORD_ID);
      assertEquals(opt1Str, optRecord.toXml());
      textbox.setLineStyle(textbox.getLineStyle());
      assertEquals(opt1Str, optRecord.toXml());
      textbox.setLineWidth(textbox.getLineWidth());
      assertEquals(opt1Str, optRecord.toXml());
      textbox.setLineStyleColor(textbox.getLineStyleColor());
      assertEquals(opt1Str, optRecord.toXml());
    } finally {
      wb.close();
    }
  }