use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.
the class HSLFTextShape method getTextRotation.
@Override
public Double getTextRotation() {
// see 2.4.6 MSOCDIR
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__FONTROTATION);
return (prop == null) ? null : (90. * prop.getPropertyValue());
}
use of org.apache.poi.ddf.AbstractEscherOptRecord 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.AbstractEscherOptRecord 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.AbstractEscherOptRecord 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.AbstractEscherOptRecord in project poi by apache.
the class HSLFTextShape method setTextDirection.
@Override
public void setTextDirection(TextDirection orientation) {
AbstractEscherOptRecord opt = getEscherOptRecord();
int msotxfl;
if (orientation == null) {
msotxfl = -1;
} else {
switch(orientation) {
default:
case STACKED:
// not supported -> remove
msotxfl = -1;
break;
case HORIZONTAL:
msotxfl = 0;
break;
case VERTICAL:
msotxfl = 1;
break;
case VERTICAL_270:
// always interpreted as horizontal
msotxfl = 2;
break;
}
}
setEscherProperty(opt, EscherProperties.TEXT__TEXTFLOW, msotxfl);
}
Aggregations