use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFTextShape method getInset.
/**
* Returns the distance (in points) between the edge of the text frame
* and the edge of the inscribed rectangle of the shape that contains the text.
* Default value is 1/20 inch.
*
* @param propId the id of the inset edge
* @return the inset in points
*/
private double getInset(short propId, double defaultInch) {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, propId);
int val = prop == null ? (int) (Units.toEMU(Units.POINT_DPI) * defaultInch) : prop.getPropertyValue();
return Units.toPoints(val);
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFTextShape method getTextId.
/**
* @return id for the text.
*/
public int getTextId() {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__TEXTID);
return prop == null ? 0 : prop.getPropertyValue();
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFTextShape method getAlignment.
/**
* Returns the type of vertical alignment for the text.
* One of the <code>Anchor*</code> constants defined in this class.
*
* @return the type of alignment
*/
/* package */
HSLFTextAnchor getAlignment() {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
HSLFTextAnchor align = HSLFTextAnchor.TOP;
if (prop == null) {
/**
* If vertical alignment was not found in the shape properties then try to
* fetch the master shape and search for the align property there.
*/
int type = getRunType();
HSLFSheet sh = getSheet();
HSLFMasterSheet master = (sh != null) ? sh.getMasterSheet() : null;
HSLFTextShape masterShape = (master != null) ? master.getPlaceholderByTextType(type) : null;
if (masterShape != null && type != TextHeaderAtom.OTHER_TYPE) {
align = masterShape.getAlignment();
} else {
//not found in the master sheet. Use the hardcoded defaults.
switch(type) {
case TextHeaderAtom.TITLE_TYPE:
case TextHeaderAtom.CENTER_TITLE_TYPE:
align = HSLFTextAnchor.MIDDLE;
break;
default:
align = HSLFTextAnchor.TOP;
break;
}
}
} else {
align = HSLFTextAnchor.fromNativeId(prop.getPropertyValue());
}
if (align == null) {
align = HSLFTextAnchor.TOP;
}
return align;
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSSFSimpleShape method setString.
/**
* @param string Sets the rich text string used by this object.
*/
public void setString(RichTextString string) {
//TODO add other shape types which can not contain text
if (getShapeType() == 0 || getShapeType() == OBJECT_TYPE_LINE) {
throw new IllegalStateException("Cannot set text for shape type: " + getShapeType());
}
HSSFRichTextString rtr = (HSSFRichTextString) string;
// If font is not set we must set the default one
if (rtr.numFormattingRuns() == 0)
rtr.applyFont((short) 0);
TextObjectRecord txo = getOrCreateTextObjRecord();
txo.setStr(rtr);
if (string.getString() != null) {
setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, string.getString().hashCode()));
}
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSSFSimpleShape method createSpContainer.
@Override
protected EscherContainerRecord createSpContainer() {
EscherContainerRecord spContainer = new EscherContainerRecord();
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
spContainer.setOptions((short) 0x000F);
EscherSpRecord sp = new EscherSpRecord();
sp.setRecordId(EscherSpRecord.RECORD_ID);
sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
sp.setVersion((short) 0x2);
EscherClientDataRecord clientData = new EscherClientDataRecord();
clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
clientData.setOptions((short) (0x0000));
EscherOptRecord optRecord = new EscherOptRecord();
optRecord.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
optRecord.setEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
// optRecord.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
optRecord.setEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
optRecord.setEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
optRecord.setEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, NO_FILLHITTEST_FALSE));
optRecord.setEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
optRecord.setEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX));
optRecord.setEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
optRecord.setRecordId(EscherOptRecord.RECORD_ID);
EscherTextboxRecord escherTextbox = new EscherTextboxRecord();
escherTextbox.setRecordId(EscherTextboxRecord.RECORD_ID);
escherTextbox.setOptions((short) 0x0000);
spContainer.addChildRecord(sp);
spContainer.addChildRecord(optRecord);
spContainer.addChildRecord(getAnchor().getEscherAnchor());
spContainer.addChildRecord(clientData);
spContainer.addChildRecord(escherTextbox);
return spContainer;
}
Aggregations