org.apache.poi.hssf.record.TextObjectRecord Java Examples

The following examples show how to use org.apache.poi.hssf.record.TextObjectRecord. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordOrderer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return <code>true</code> if the specified record ID terminates a sequence of Row block records
 * It is assumed that at least one row or cell value record has been found prior to the current
 * record
 */
public static boolean isEndOfRowBlock(int sid) {
	switch(sid) {
		case ViewDefinitionRecord.sid:
			// should have been prefixed with DrawingRecord (0x00EC), but bug 46280 seems to allow this
		case DrawingRecord.sid:
		case DrawingSelectionRecord.sid:
		case ObjRecord.sid:
		case TextObjectRecord.sid:
           case ColumnInfoRecord.sid: // See Bugzilla 53984
           case GutsRecord.sid:   // see Bugzilla 50426
		case WindowOneRecord.sid:
			// should really be part of workbook stream, but some apps seem to put this before WINDOW2
		case WindowTwoRecord.sid:
			return true;

		case DVALRecord.sid:
			return true;
		case EOFRecord.sid:
			// WINDOW2 should always be present, so shouldn't have got this far
			throw new RuntimeException("Found EOFRecord before WindowTwoRecord was encountered");
	}
	return PageSettingsBlock.isComponentRecord(sid);
}
 
Example #2
Source File: RowBlock.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
/**
 * @return <code>true</code> if the specified record ID terminates a sequence of Row block records
 * It is assumed that at least one row or cell value record has been found prior to the current
 * record
 */
static boolean isEndOfRowBlock(int sid) {
  switch(sid) {
    case ViewDefinitionRecord.sid:
      // should have been prefixed with DrawingRecord (0x00EC), but bug 46280 seems to allow this
    case DrawingRecord.sid:
    case DrawingSelectionRecord.sid:
    case ObjRecord.sid:
    case TextObjectRecord.sid:
    case ColumnInfoRecord.sid: // See Bugzilla 53984
    case GutsRecord.sid:   // see Bugzilla 50426
    case WindowOneRecord.sid:
      // should really be part of workbook stream, but some apps seem to put this before WINDOW2
    case WindowTwoRecord.sid:
      return true;

    case DVALRecord.sid:
      return true;
    case EOFRecord.sid:
      // WINDOW2 should always be present, so shouldn't have got this far
      throw new RuntimeException("Found EOFRecord before WindowTwoRecord was encountered");
  }
  return PageSettingsBlock.isComponentRecord(sid);
}
 
Example #3
Source File: TextObjectRecordHandler.java    From easyexcel with Apache License 2.0 5 votes vote down vote up
@Override
public void processRecord(XlsReadContext xlsReadContext, Record record) {
    TextObjectRecord tor = (TextObjectRecord)record;
    XlsReadSheetHolder xlsReadSheetHolder = xlsReadContext.xlsReadSheetHolder();
    Integer tempObjectIndex = xlsReadSheetHolder.getTempObjectIndex();
    if (tempObjectIndex == null) {
        LOGGER.debug("tempObjectIndex is null.");
        return;
    }
    xlsReadSheetHolder.getObjectCacheMap().put(tempObjectIndex, tor.getStr().getString());
    xlsReadSheetHolder.setTempObjectIndex(null);
}
 
Example #4
Source File: HSSFComment.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected HSSFShape cloneShape() {
    TextObjectRecord txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
    EscherContainerRecord spContainer = new EscherContainerRecord();
    byte [] inSp = getEscherContainer().serialize();
    spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
    ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
    NoteRecord note = (NoteRecord) getNoteRecord().cloneViaReserialise();
    return new HSSFComment(spContainer, obj, txo, note);
}
 
Example #5
Source File: HSSFSimpleShape.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected TextObjectRecord createTextObjRecord(){
    TextObjectRecord obj = new TextObjectRecord();
    obj.setHorizontalTextAlignment(2);
    obj.setVerticalTextAlignment(2);
    obj.setTextLocked(true);
    obj.setTextOrientation(TextObjectRecord.TEXT_ORIENTATION_NONE);
    obj.setStr(new HSSFRichTextString(""));
    return obj;
}
 
Example #6
Source File: HSSFSimpleShape.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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()));
    }
}
 
Example #7
Source File: HSSFSimpleShape.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private TextObjectRecord getOrCreateTextObjRecord(){
    if (getTextObjectRecord() == null){
        _textObjectRecord = createTextObjRecord();
    }
    EscherTextboxRecord escherTextbox = getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID);
    if (null == escherTextbox){
        escherTextbox = new EscherTextboxRecord();
        escherTextbox.setRecordId(EscherTextboxRecord.RECORD_ID);
        escherTextbox.setOptions((short) 0x0000);
        getEscherContainer().addChildRecord(escherTextbox);
        getPatriarch().getBoundAggregate().associateShapeToObjRecord(escherTextbox, _textObjectRecord);
    }
    return _textObjectRecord;
}
 
Example #8
Source File: HSSFComment.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HSSFComment(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord textObjectRecord, NoteRecord note) {
    super(spContainer, objRecord, textObjectRecord);
    _note = note;
}
 
Example #9
Source File: HSSFComment.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected HSSFComment(NoteRecord note, TextObjectRecord txo) {
    this(null, new HSSFClientAnchor(), note);
}
 
Example #10
Source File: HSSFSimpleShape.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HSSFSimpleShape(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord textObjectRecord) {
    super(spContainer, objRecord);
    this._textObjectRecord = textObjectRecord;
}
 
Example #11
Source File: HSSFSimpleShape.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected TextObjectRecord getTextObjectRecord() {
    return _textObjectRecord;
}