use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSSFComment method setBackgroundImage.
public void setBackgroundImage(int pictureIndex) {
setPropertyValue(new EscherSimpleProperty(EscherProperties.FILL__PATTERNTEXTURE, false, true, pictureIndex));
setPropertyValue(new EscherSimpleProperty(EscherProperties.FILL__FILLTYPE, false, false, FILL_TYPE_PICTURE));
EscherBSERecord bse = getPatriarch().getSheet().getWorkbook().getWorkbook().getBSERecord(pictureIndex);
bse.setRef(bse.getRef() + 1);
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSSFShape method getRotationDegree.
/**
* @return the rotation, in degrees, that is applied to a shape.
*/
public int getRotationDegree() {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TRANSFORM__ROTATION);
if (null == property) {
return 0;
}
try {
LittleEndian.putInt(property.getPropertyValue(), bos);
return LittleEndian.getShort(bos.toByteArray(), 2);
} catch (IOException e) {
LOG.log(POILogger.ERROR, "can't determine rotation degree", e);
return 0;
}
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class PPDrawing method create.
/**
* Create the Escher records associated with a new PPDrawing
*/
private void create() {
EscherContainerRecord dgContainer = new EscherContainerRecord();
dgContainer.setRecordId(EscherContainerRecord.DG_CONTAINER);
dgContainer.setOptions((short) 15);
dg = new EscherDgRecord();
dg.setOptions((short) 16);
dg.setNumShapes(1);
dgContainer.addChildRecord(dg);
EscherContainerRecord spgrContainer = new EscherContainerRecord();
spgrContainer.setOptions((short) 15);
spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
EscherContainerRecord spContainer = new EscherContainerRecord();
spContainer.setOptions((short) 15);
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
EscherSpgrRecord spgr = new EscherSpgrRecord();
spgr.setOptions((short) 1);
spContainer.addChildRecord(spgr);
EscherSpRecord sp = new EscherSpRecord();
sp.setOptions((short) ((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2));
sp.setFlags(EscherSpRecord.FLAG_PATRIARCH | EscherSpRecord.FLAG_GROUP);
spContainer.addChildRecord(sp);
spgrContainer.addChildRecord(spContainer);
dgContainer.addChildRecord(spgrContainer);
spContainer = new EscherContainerRecord();
spContainer.setOptions((short) 15);
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
sp = new EscherSpRecord();
sp.setOptions((short) ((ShapeType.RECT.nativeId << 4) + 2));
sp.setFlags(EscherSpRecord.FLAG_BACKGROUND | EscherSpRecord.FLAG_HASSHAPETYPE);
spContainer.addChildRecord(sp);
EscherOptRecord opt = new EscherOptRecord();
opt.setRecordId(EscherOptRecord.RECORD_ID);
opt.addEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 134217728));
opt.addEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLBACKCOLOR, 134217733));
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__RECTRIGHT, 10064750));
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__RECTBOTTOM, 7778750));
opt.addEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 1179666));
opt.addEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 524288));
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.SHAPE__BLACKANDWHITESETTINGS, 9));
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.SHAPE__BACKGROUNDSHAPE, 65537));
spContainer.addChildRecord(opt);
dgContainer.addChildRecord(spContainer);
childRecords.add(dgContainer);
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFTextShape method getTextDirection.
@Override
public TextDirection getTextDirection() {
// see 2.4.5 MSOTXFL
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__TEXTFLOW);
int msotxfl = (prop == null) ? 0 : prop.getPropertyValue();
switch(msotxfl) {
default:
// msotxflHorzN
case 0:
case // msotxflHorzA
4:
return TextDirection.HORIZONTAL;
// msotxflTtoBA
case 1:
// msotxflTtoBN
case 3:
case // msotxflVertN
5:
return TextDirection.VERTICAL;
case // msotxflBtoT
2:
return TextDirection.VERTICAL_270;
}
}
use of org.apache.poi.ddf.EscherSimpleProperty 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