use of org.apache.poi.ddf.EscherTertiaryOptRecord in project poi by apache.
the class OfficeDrawingsImpl method getOfficeDrawing.
private OfficeDrawing getOfficeDrawing(final FSPA fspa) {
return new OfficeDrawing() {
public HorizontalPositioning getHorizontalPositioning() {
int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSH, -1);
switch(value) {
case 0:
return HorizontalPositioning.ABSOLUTE;
case 1:
return HorizontalPositioning.LEFT;
case 2:
return HorizontalPositioning.CENTER;
case 3:
return HorizontalPositioning.RIGHT;
case 4:
return HorizontalPositioning.INSIDE;
case 5:
return HorizontalPositioning.OUTSIDE;
}
return HorizontalPositioning.ABSOLUTE;
}
public HorizontalRelativeElement getHorizontalRelative() {
int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSRELH, -1);
switch(value) {
case 1:
return HorizontalRelativeElement.MARGIN;
case 2:
return HorizontalRelativeElement.PAGE;
case 3:
return HorizontalRelativeElement.TEXT;
case 4:
return HorizontalRelativeElement.CHAR;
}
return HorizontalRelativeElement.TEXT;
}
public EscherContainerRecord getOfficeArtSpContainer() {
return getEscherShapeRecordContainer(getShapeId());
}
public byte[] getPictureData() {
EscherContainerRecord shapeDescription = getEscherShapeRecordContainer(getShapeId());
if (shapeDescription == null)
return null;
EscherOptRecord escherOptRecord = shapeDescription.getChildById(EscherOptRecord.RECORD_ID);
if (escherOptRecord == null)
return null;
EscherSimpleProperty escherProperty = escherOptRecord.lookup(EscherProperties.BLIP__BLIPTODISPLAY);
if (escherProperty == null)
return null;
int bitmapIndex = escherProperty.getPropertyValue();
EscherBlipRecord escherBlipRecord = getBitmapRecord(bitmapIndex);
if (escherBlipRecord == null)
return null;
return escherBlipRecord.getPicturedata();
}
public int getRectangleBottom() {
return fspa.getYaBottom();
}
public int getRectangleLeft() {
return fspa.getXaLeft();
}
public int getRectangleRight() {
return fspa.getXaRight();
}
public int getRectangleTop() {
return fspa.getYaTop();
}
public int getShapeId() {
return fspa.getSpid();
}
private int getTertiaryPropertyValue(int propertyId, int defaultValue) {
EscherContainerRecord shapeDescription = getEscherShapeRecordContainer(getShapeId());
if (shapeDescription == null)
return defaultValue;
EscherTertiaryOptRecord escherTertiaryOptRecord = shapeDescription.getChildById(EscherTertiaryOptRecord.RECORD_ID);
if (escherTertiaryOptRecord == null)
return defaultValue;
EscherSimpleProperty escherProperty = escherTertiaryOptRecord.lookup(propertyId);
if (escherProperty == null)
return defaultValue;
int value = escherProperty.getPropertyValue();
return value;
}
public VerticalPositioning getVerticalPositioning() {
int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSV, -1);
switch(value) {
case 0:
return VerticalPositioning.ABSOLUTE;
case 1:
return VerticalPositioning.TOP;
case 2:
return VerticalPositioning.CENTER;
case 3:
return VerticalPositioning.BOTTOM;
case 4:
return VerticalPositioning.INSIDE;
case 5:
return VerticalPositioning.OUTSIDE;
}
return VerticalPositioning.ABSOLUTE;
}
public VerticalRelativeElement getVerticalRelativeElement() {
int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSV, -1);
switch(value) {
case 1:
return VerticalRelativeElement.MARGIN;
case 2:
return VerticalRelativeElement.PAGE;
case 3:
return VerticalRelativeElement.TEXT;
case 4:
return VerticalRelativeElement.LINE;
}
return VerticalRelativeElement.TEXT;
}
@Override
public String toString() {
return "OfficeDrawingImpl: " + fspa;
}
};
}
Aggregations