Search in sources :

Example 11 with TextObjectRecord

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);
}
Also used : TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) DefaultEscherRecordFactory(org.apache.poi.ddf.DefaultEscherRecordFactory)

Example 12 with TextObjectRecord

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()));
    }
}
Also used : TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty)

Aggregations

TextObjectRecord (org.apache.poi.hssf.record.TextObjectRecord)12 ObjRecord (org.apache.poi.hssf.record.ObjRecord)10 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)7 NoteRecord (org.apache.poi.hssf.record.NoteRecord)7 Test (org.junit.Test)7 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)5 EscherRecord (org.apache.poi.ddf.EscherRecord)5 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)5 EOFRecord (org.apache.poi.hssf.record.EOFRecord)5 Record (org.apache.poi.hssf.record.Record)5 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)5 ContinueRecord (org.apache.poi.hssf.record.ContinueRecord)4 EscherAggregate (org.apache.poi.hssf.record.EscherAggregate)4 RecordBase (org.apache.poi.hssf.record.RecordBase)4 RowRecordsAggregate (org.apache.poi.hssf.record.aggregates.RowRecordsAggregate)4 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)4 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)4 DefaultEscherRecordFactory (org.apache.poi.ddf.DefaultEscherRecordFactory)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1