CommentShapepublic class CommentShape extends TextboxShape Represents a cell comment.
This class converts highlevel model data from HSSFComment
to low-level records. |
Fields Summary |
---|
private NoteRecord | note |
Constructors Summary |
---|
public CommentShape(HSSFComment hssfShape, int shapeId)Creates the low-level records for a comment.
super(hssfShape, shapeId);
note = createNoteRecord(hssfShape, shapeId);
ObjRecord obj = getObjRecord();
List records = obj.getSubRecords();
int cmoIdx = 0;
for (int i = 0; i < records.size(); i++) {
Object r = records.get(i);
if (r instanceof CommonObjectDataSubRecord){
//modify autofill attribute inherited from <code>TextObjectRecord</code>
CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)r;
cmo.setAutofill(false);
cmoIdx = i;
}
}
//add NoteStructure sub record
//we don't know it's format, for now the record data is empty
NoteStructureSubRecord u = new NoteStructureSubRecord();
obj.addSubRecord(cmoIdx+1, u);
|
Methods Summary |
---|
protected int | addStandardOptions(org.apache.poi.hssf.usermodel.HSSFShape shape, org.apache.poi.ddf.EscherOptRecord opt)Sets standard escher options for a comment.
This method is responsible for setting default background,
shading and other comment properties.
super.addStandardOptions(shape, opt);
//remove unnecessary properties inherited from TextboxShape
java.util.List props = opt.getEscherProperties();
for ( Iterator iterator = props.iterator(); iterator.hasNext(); ) {
EscherProperty prop = (EscherProperty) iterator.next();
switch (prop.getId()){
case EscherProperties.TEXT__TEXTLEFT:
case EscherProperties.TEXT__TEXTRIGHT:
case EscherProperties.TEXT__TEXTTOP:
case EscherProperties.TEXT__TEXTBOTTOM:
case EscherProperties.GROUPSHAPE__PRINT:
case EscherProperties.FILL__FILLBACKCOLOR:
case EscherProperties.LINESTYLE__COLOR:
iterator.remove();
break;
}
}
HSSFComment comment = (HSSFComment)shape;
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.GROUPSHAPE__PRINT, comment.isVisible() ? 0x000A0000 : 0x000A0002) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x00030003 ) );
opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.SHADOWSTYLE__COLOR, 0x00000000 ) );
opt.sortProperties();
return opt.getEscherProperties().size(); // # options added
| private org.apache.poi.hssf.record.NoteRecord | createNoteRecord(org.apache.poi.hssf.usermodel.HSSFComment shape, int shapeId)Creates the low level NoteRecord
which holds the comment attributes.
NoteRecord note = new NoteRecord();
note.setColumn(shape.getColumn());
note.setRow((short)shape.getRow());
note.setFlags(shape.isVisible() ? NoteRecord.NOTE_VISIBLE : NoteRecord.NOTE_HIDDEN);
note.setShapeId((short)shapeId);
note.setAuthor(shape.getAuthor() == null ? "" : shape.getAuthor());
return note;
| public org.apache.poi.hssf.record.NoteRecord | getNoteRecord()Return the NoteRecord holding the comment attributes
return note;
|
|