use of org.apache.poi.hssf.record.TextObjectRecord in project poi by apache.
the class HSSFSimpleShape method cloneShape.
@Override
protected HSSFShape cloneShape() {
TextObjectRecord txo = null;
EscherContainerRecord spContainer = new EscherContainerRecord();
byte[] inSp = getEscherContainer().serialize();
spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
if (getTextObjectRecord() != null && getString() != null && null != getString().getString()) {
txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
}
return new HSSFSimpleShape(spContainer, obj, txo);
}
use of org.apache.poi.hssf.record.TextObjectRecord 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()));
}
}
Aggregations